/* * Copyright (c) 2024, Kostya Farber * * SPDX-License-Identifier: BSD-2-Clause */ #include #include #include namespace Web::Layout { GC_DEFINE_ALLOCATOR(FieldSetBox); FieldSetBox::FieldSetBox(DOM::Document& document, DOM::Element& element, GC::Ref style) : BlockContainer(document, &element, style) { } FieldSetBox::~FieldSetBox() = default; GC::Ptr 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 legend; for_each_child_of_type([&](Box const& child) { if (!child.is_legend_box() || !child.is_in_flow()) return IterationDecision::Continue; legend = static_cast(child); return IterationDecision::Break; }); return legend; } GC::Ptr FieldSetBox::create_paintable() const { return Painting::FieldSetPaintable::create(*this); } }