1
0
Fork 0
mirror of https://github.com/LadybirdBrowser/ladybird.git synced 2025-06-11 18:20:43 +09:00

LibWeb: Use JS::HeapFunction for callbacks in SharedImageRequest

If a function that captures a GC-allocated object is owned by another
GC-allocated object, it is more preferable to use JS::HeapFunction.
This is because JS::HeapFunction is visited, unlike introducing a new
heap root as JS::SafeFunction does.
This commit is contained in:
Aliaksandr Kalenik 2023-09-25 14:27:11 +02:00 committed by Andreas Kling
parent 4f488f7e07
commit df86e52d75
Notes: sideshowbarker 2024-07-17 05:41:34 +09:00
4 changed files with 21 additions and 10 deletions

View file

@ -11,6 +11,7 @@
#include <AK/URL.h>
#include <LibGfx/Size.h>
#include <LibJS/Heap/Handle.h>
#include <LibJS/Heap/HeapFunction.h>
#include <LibJS/SafeFunction.h>
#include <LibWeb/Forward.h>
@ -33,7 +34,7 @@ public:
void fetch_image(JS::Realm&, JS::NonnullGCPtr<Fetch::Infrastructure::Request>);
void add_callbacks(JS::SafeFunction<void()> on_finish, JS::SafeFunction<void()> on_fail);
void add_callbacks(Function<void()> on_finish, Function<void()> on_fail);
bool is_fetching() const;
bool needs_fetching() const;
@ -58,8 +59,8 @@ private:
Page& m_page;
struct Callbacks {
JS::SafeFunction<void()> on_finish;
JS::SafeFunction<void()> on_fail;
JS::GCPtr<JS::HeapFunction<void()>> on_finish;
JS::GCPtr<JS::HeapFunction<void()>> on_fail;
};
Vector<Callbacks> m_callbacks;