mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2026-04-18 09:50:27 +00:00
We were misaligning <fieldset>'s bounds, painting and <legend> layout in many cases. This reworks both the layout and painting code to the point where we render many cases practically identical to Firefox and Chrome.
45 lines
1.4 KiB
C++
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, 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;
|
|
}
|
|
|
|
GC::Ptr<Painting::Paintable> FieldSetBox::create_paintable() const
|
|
{
|
|
return Painting::FieldSetPaintable::create(*this);
|
|
}
|
|
|
|
}
|