The Paintable tree and its supplemental painting data structures were GC allocated because that was the easiest way to manage it and avoid leaks introduced by ref cycles. This included the Paintable subclasses themselves plus StackingContext, ChromeWidget, Scrollbar, ResizeHandle, and scroll-frame state. We are now trying to reduce GC allocation churn on layout and painting updates, so keeping this short-lived rendering tree outside the JS heap is a better fit. Move Paintable to RefCountedTreeNode, make painting helpers ref-counted or weakly reference Paintables, and update the layout and event-handler call sites to use RefPtr/WeakPtr ownership.
48 lines
1.5 KiB
C++
48 lines
1.5 KiB
C++
/*
|
|
* Copyright (c) 2018-2022, Andreas Kling <andreas@ladybird.org>
|
|
* Copyright (c) 2021, Tobias Christiansen <tobyase@serenityos.org>
|
|
* Copyright (c) 2025, Sam Atkins <sam@ladybird.org>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <LibWeb/Layout/Box.h>
|
|
|
|
namespace Web::Layout {
|
|
|
|
class ListItemMarkerBox final : public Box {
|
|
GC_CELL(ListItemMarkerBox, Box);
|
|
GC_DECLARE_ALLOCATOR(ListItemMarkerBox);
|
|
|
|
public:
|
|
static bool counter_style_is_rendered_with_custom_image(RefPtr<CSS::CounterStyle const> const& counter_style);
|
|
|
|
explicit ListItemMarkerBox(DOM::Document&, CSS::ListStyleType, CSS::ListStylePosition, GC::Ref<DOM::Element>, GC::Ref<CSS::ComputedProperties>);
|
|
virtual ~ListItemMarkerBox() override;
|
|
|
|
Optional<String> text() const;
|
|
|
|
virtual RefPtr<Painting::Paintable> create_paintable() const override;
|
|
|
|
CSS::ListStyleType const& list_style_type() const { return m_list_style_type; }
|
|
CSS::ListStylePosition list_style_position() const { return m_list_style_position; }
|
|
|
|
CSSPixels relative_size() const;
|
|
|
|
private:
|
|
virtual void visit_edges(Cell::Visitor&) override;
|
|
|
|
virtual bool is_list_item_marker_box() const final { return true; }
|
|
virtual bool can_have_children() const override { return false; }
|
|
|
|
CSS::ListStyleType m_list_style_type;
|
|
CSS::ListStylePosition m_list_style_position { CSS::ListStylePosition::Outside };
|
|
GC::Ref<DOM::Element> m_list_item_element;
|
|
};
|
|
|
|
template<>
|
|
inline bool Node::fast_is<ListItemMarkerBox>() const { return is_list_item_marker_box(); }
|
|
|
|
}
|