ladybird/Libraries/LibWeb/Layout/ListItemMarkerBox.h
Andreas Kling 9340d2d1a3 LibWeb: Make layout nodes refcounted
Move the layout tree from GC allocation to refcounted ownership so
removed layout and paint subtrees are destroyed synchronously instead
of waiting for the next GC sweep. This dramatically reduces GC memory
usage peaks after layout tree churn and makes it easier for memory use
to fall back after large document updates.

Update layout factories, tree traversal, SVG layout node creation,
paintable back-pointers, and pseudo-element layout links to use RefPtr
ownership.

Make display: contents follow the same shape as Blink and WebKit: the
element itself does not create a layout node, and its children are
flattened into the nearest layout parent. Wrap direct non-whitespace
text in an anonymous inline node when the boxless element contributes
inherited style to that text.

Use an internal inline wrapper for display: contents pseudo-elements
so generated content can still participate in layout, painting, hit
testing, and pseudo-element queries. Keep CSSOM reporting the computed
display value from the pseudo style, not the internal wrapper.

Remove the retained out-of-tree layout node list and its testing hook,
since the flattened model does not need a side owner for boxless
elements. Add coverage for inherited text style, dynamic insertion
order, pseudo-element hit testing, and computed style queries.
2026-06-07 20:52:49 +02:00

45 lines
1.4 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 {
LAYOUT_NODE(ListItemMarkerBox, Box);
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>, CSS::ComputedProperties const&);
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 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::Weak<DOM::Element> m_list_item_element;
};
template<>
inline bool Node::fast_is<ListItemMarkerBox>() const { return is_list_item_marker_box(); }
}