1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 16:17:45 +00:00

LibWeb: Paint fragments contained by inline node as part of this node

Fragments contained by the inline node should be painted in the
foreground phase for this node, instead of being painted as a part of
the containing PaintableWithLines. This change implements that by
marking all fragments contained by inline nodes so they can be skipped
while painting the content of PaintableWithLines. This is an ugly way,
and instead, we should make InlinePaintables own all fragments
contained by them.
This commit is contained in:
Aliaksandr Kalenik 2024-01-03 19:00:04 +01:00 committed by Andreas Kling
parent c5187c6bb3
commit 6c645f3a9f
6 changed files with 45 additions and 3 deletions

View file

@ -146,6 +146,13 @@ void InlinePaintable::paint(PaintContext& context, PaintPhase phase) const
}
}
if (phase == PaintPhase::Foreground) {
for_each_fragment([&](auto const& fragment, bool, bool) {
if (is<Layout::TextNode>(fragment.layout_node()))
paint_text_fragment(context, static_cast<Layout::TextNode const&>(fragment.layout_node()), fragment, phase);
});
}
if (phase == PaintPhase::Overlay && layout_node().document().inspected_layout_node() == &layout_node()) {
// FIXME: This paints a double-thick border between adjacent fragments, where ideally there
// would be none. Once we implement non-rectangular outlines for the `outline` CSS
@ -173,6 +180,15 @@ void InlinePaintable::for_each_fragment(Callback callback) const
}
}
void InlinePaintable::mark_contained_fragments()
{
verify_cast<PaintableWithLines>(*containing_block()->paintable_box()).for_each_fragment([&](auto& fragment) {
if (layout_node().is_inclusive_ancestor_of(fragment.layout_node()))
const_cast<Layout::LineBoxFragment&>(fragment).set_contained_by_inline_node();
return IterationDecision::Continue;
});
}
CSSPixelRect InlinePaintable::bounding_rect() const
{
auto top = CSSPixels::max();