1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 18:28:12 +00:00

LibWeb: Fix overflow: hidden not applying to positioned descendants

This now calls before/after_child_paint() on the parent paintable
of a positioned child. This allows the parent's overflow clipping
to apply to the child.
This commit is contained in:
MacDue 2022-07-19 11:06:21 +01:00 committed by Andreas Kling
parent f079214b18
commit 0b0a691ecd

View file

@ -129,11 +129,23 @@ void StackingContext::paint_internal(PaintContext& context) const
// Draw the background and borders for the context root (steps 1, 2)
paint_node(m_box, context, PaintPhase::Background);
paint_node(m_box, context, PaintPhase::Border);
auto paint_child = [&](auto* child) {
auto parent = child->m_box.parent();
auto* paintable = parent ? parent->paintable() : nullptr;
if (paintable)
paintable->before_children_paint(context, PaintPhase::Foreground);
child->paint(context);
if (paintable)
paintable->after_children_paint(context, PaintPhase::Foreground);
};
// Draw positioned descendants with negative z-indices (step 3)
for (auto* child : m_children) {
if (child->m_box.computed_values().z_index().has_value() && child->m_box.computed_values().z_index().value() < 0)
child->paint(context);
paint_child(child);
}
// Draw the background and borders for block-level children (step 4)
paint_descendants(context, m_box, StackingContextPaintPhase::BackgroundAndBorders);
// Draw the non-positioned floats (step 5)
@ -146,7 +158,7 @@ void StackingContext::paint_internal(PaintContext& context) const
for (auto* child : m_children) {
if (child->m_box.computed_values().z_index().has_value() && child->m_box.computed_values().z_index().value() < 0)
continue;
child->paint(context);
paint_child(child);
}
paint_node(m_box, context, PaintPhase::FocusOutline);