diff --git a/Userland/Libraries/LibWeb/HTML/TraversableNavigable.cpp b/Userland/Libraries/LibWeb/HTML/TraversableNavigable.cpp
index 98b8dcba2b2..97f04d895b4 100644
--- a/Userland/Libraries/LibWeb/HTML/TraversableNavigable.cpp
+++ b/Userland/Libraries/LibWeb/HTML/TraversableNavigable.cpp
@@ -1190,7 +1190,7 @@ JS::GCPtr TraversableNavigable::currently_focused_area()
void TraversableNavigable::paint(DevicePixelRect const& content_rect, Painting::BackingStore& target, PaintOptions paint_options)
{
- Painting::DisplayList display_list;
+ auto display_list = Painting::DisplayList::create();
Painting::DisplayListRecorder display_list_recorder(display_list);
Gfx::IntRect bitmap_rect { {}, content_rect.size().to_type() };
diff --git a/Userland/Libraries/LibWeb/Painting/DisplayList.h b/Userland/Libraries/LibWeb/Painting/DisplayList.h
index 7bdb281239d..56cfa205dc1 100644
--- a/Userland/Libraries/LibWeb/Painting/DisplayList.h
+++ b/Userland/Libraries/LibWeb/Painting/DisplayList.h
@@ -73,8 +73,13 @@ private:
virtual bool would_be_fully_clipped_by_painter(Gfx::IntRect) const = 0;
};
-class DisplayList {
+class DisplayList : public RefCounted {
public:
+ static NonnullRefPtr create()
+ {
+ return adopt_ref(*new DisplayList());
+ }
+
void append(Command&& command, Optional scroll_frame_id);
void apply_scroll_offsets(Vector const& offsets_by_frame_id);
@@ -89,6 +94,8 @@ public:
AK::SegmentedVector const& commands() const { return m_commands; }
private:
+ DisplayList() = default;
+
AK::SegmentedVector m_commands;
};
diff --git a/Userland/Libraries/LibWeb/Painting/SVGMaskable.cpp b/Userland/Libraries/LibWeb/Painting/SVGMaskable.cpp
index b3fa199db60..16875022ede 100644
--- a/Userland/Libraries/LibWeb/Painting/SVGMaskable.cpp
+++ b/Userland/Libraries/LibWeb/Painting/SVGMaskable.cpp
@@ -81,8 +81,8 @@ RefPtr SVGMaskable::calculate_mask_of_svg(PaintContext& context, CS
if (mask_bitmap_or_error.is_error())
return {};
mask_bitmap = mask_bitmap_or_error.release_value();
- DisplayList display_list;
- DisplayListRecorder display_list_recorder(display_list);
+ auto display_list = DisplayList::create();
+ DisplayListRecorder display_list_recorder(*display_list);
display_list_recorder.translate(-mask_rect.location().to_type());
auto paint_context = context.clone(display_list_recorder);
paint_context.set_svg_transform(graphics_element.get_transform());
diff --git a/Userland/Libraries/LibWeb/SVG/SVGDecodedImageData.cpp b/Userland/Libraries/LibWeb/SVG/SVGDecodedImageData.cpp
index 24d588a8401..d098d6f76d1 100644
--- a/Userland/Libraries/LibWeb/SVG/SVGDecodedImageData.cpp
+++ b/Userland/Libraries/LibWeb/SVG/SVGDecodedImageData.cpp
@@ -92,7 +92,7 @@ RefPtr SVGDecodedImageData::render(Gfx::IntSize size) const
m_document->navigable()->set_viewport_size(size.to_type());
m_document->update_layout();
- Painting::DisplayList display_list;
+ auto display_list = Painting::DisplayList::create();
Painting::DisplayListRecorder display_list_recorder(display_list);
m_document->navigable()->record_display_list(display_list_recorder, {});