1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 04:17:35 +00:00

LibWeb: Make HTML::SharedImageRequest GC allocated

This allows to partially solve the problem of cyclic dependency between
HTMLImageElement and SharedImageRequest that prevents all image
elements from being deallocated.
This commit is contained in:
Aliaksandr Kalenik 2023-08-18 14:11:55 +02:00 committed by Andreas Kling
parent bbfedf2e5a
commit 934afcb9d5
9 changed files with 46 additions and 18 deletions

View file

@ -16,9 +16,12 @@
namespace Web::HTML {
class SharedImageRequest : public RefCounted<SharedImageRequest> {
class SharedImageRequest : public JS::Cell {
JS_CELL(ImageRequest, JS::Cell);
public:
static ErrorOr<NonnullRefPtr<SharedImageRequest>> get_or_create(Page&, AK::URL const&);
[[nodiscard]] static JS::NonnullGCPtr<SharedImageRequest> get_or_create(JS::Realm&, Page&, AK::URL const&);
~SharedImageRequest();
AK::URL const& url() const { return m_url; }
@ -35,6 +38,8 @@ public:
bool is_fetching() const;
bool needs_fetching() const;
virtual void visit_edges(JS::Cell::Visitor&) override;
private:
explicit SharedImageRequest(Page&, AK::URL);
@ -60,7 +65,7 @@ private:
AK::URL m_url;
RefPtr<DecodedImageData const> m_image_data;
JS::Handle<Fetch::Infrastructure::FetchController> m_fetch_controller;
JS::GCPtr<Fetch::Infrastructure::FetchController> m_fetch_controller;
};
}