mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-05-11 17:37:33 +02:00
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.
46 lines
1.4 KiB
C++
46 lines
1.4 KiB
C++
/*
|
|
* Copyright (c) 2024, Kostya Farber <kostya.farber@gmail.com>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#include <LibWeb/Forward.h>
|
|
#include <LibWeb/Layout/FieldSetBox.h>
|
|
#include <LibWeb/Painting/FieldSetPaintable.h>
|
|
|
|
namespace Web::Layout {
|
|
|
|
GC_DEFINE_ALLOCATOR(FieldSetBox);
|
|
|
|
FieldSetBox::FieldSetBox(DOM::Document& document, DOM::Element& element, GC::Ref<CSS::ComputedProperties> style)
|
|
: BlockContainer(document, &element, style)
|
|
{
|
|
}
|
|
|
|
FieldSetBox::~FieldSetBox() = default;
|
|
|
|
GC::Ptr<LegendBox const> FieldSetBox::rendered_legend() const
|
|
{
|
|
// https://html.spec.whatwg.org/multipage/rendering.html#rendered-legend
|
|
// If the element's box has a child box that matches the conditions in the list below, then the first such child box
|
|
// is the 'fieldset' element's rendered legend:
|
|
// * The child is a legend element.
|
|
// * The child's used value of 'float' is 'none'.
|
|
// * The child's used value of 'position' is not 'absolute' or 'fixed'.
|
|
GC::Ptr<LegendBox const> legend;
|
|
for_each_child_of_type<Box>([&](Box const& child) {
|
|
if (!child.is_legend_box() || !child.is_in_flow())
|
|
return IterationDecision::Continue;
|
|
legend = static_cast<LegendBox const&>(child);
|
|
return IterationDecision::Break;
|
|
});
|
|
return legend;
|
|
}
|
|
|
|
RefPtr<Painting::Paintable> FieldSetBox::create_paintable() const
|
|
{
|
|
return Painting::FieldSetPaintable::create(*this);
|
|
}
|
|
|
|
}
|