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

LibWeb: Make HTML::DecodedImageData to be GC-allocated

This change fixes GC-leak caused by following mutual dependency:
- SVGDecodedImageData owns JS::Handle for Page.
- SVGDecodedImageData is owned by visited objects.
by making everything inherited from HTML::DecodedImageData and
ListOfAvailableImages to be GC-allocated.

Generally, if visited object has a handle, very likely we leak
everything visited from object in a handle.
This commit is contained in:
Aliaksandr Kalenik 2023-12-12 20:07:19 +01:00 committed by Andreas Kling
parent 57a04c536c
commit 41a3c19cfe
18 changed files with 100 additions and 54 deletions

View file

@ -43,8 +43,8 @@ public:
AK::URL const& current_url() const;
void set_current_url(JS::Realm&, AK::URL);
[[nodiscard]] RefPtr<DecodedImageData const> image_data() const;
void set_image_data(RefPtr<DecodedImageData const>);
[[nodiscard]] JS::GCPtr<DecodedImageData> image_data() const;
void set_image_data(JS::GCPtr<DecodedImageData>);
[[nodiscard]] float current_pixel_density() const { return m_current_pixel_density; }
void set_current_pixel_density(float density) { m_current_pixel_density = density; }
@ -76,7 +76,7 @@ private:
AK::URL m_current_url;
// https://html.spec.whatwg.org/multipage/images.html#img-req-data
RefPtr<DecodedImageData const> m_image_data;
JS::GCPtr<DecodedImageData> m_image_data;
// https://html.spec.whatwg.org/multipage/images.html#current-pixel-density
// Each image request has a current pixel density, which must initially be 1.