ladybird/Libraries/LibWeb/Layout/FieldSetBox.cpp
Andreas Kling 7c06c3fd14 LibWeb: Make computed style data refcounted
Move ComputedProperties and CascadedProperties out of the GC. They no
longer contain strong references to GC-managed data.

Keep computed styles alive from DOM elements and animation updates with
RefPtr. Pass style into layout constructors by reference, since layout
only copies the values it needs while building nodes.

Use GC::Weak for cascade source links, so entries no longer keep the
style declaration or shadow root alive.
2026-06-06 23:29:48 +02:00

45 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, CSS::ComputedProperties const& 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);
}
}