1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 19:47:44 +00:00

LibWeb: Apply overflow: hidden to all (relevant) child paint phases

Previously, before/after_children_paint() was only called for the
"Foreground" paint phase, this meant the backgrounds and other
features of child nodes of a element with overflow: hidden were
not clipped.
This commit is contained in:
MacDue 2022-07-19 11:02:56 +01:00 committed by Andreas Kling
parent d0e614c045
commit f079214b18
2 changed files with 30 additions and 10 deletions

View file

@ -48,12 +48,27 @@ void StackingContext::sort()
child->sort();
}
static PaintPhase to_paint_phase(StackingContext::StackingContextPaintPhase phase)
{
// There are not a fully correct mapping since some stacking context phases are combind.
switch (phase) {
case StackingContext::StackingContextPaintPhase::Floats:
case StackingContext::StackingContextPaintPhase::BackgroundAndBordersForInlineLevelAndReplaced:
case StackingContext::StackingContextPaintPhase::BackgroundAndBorders:
return PaintPhase::Background;
case StackingContext::StackingContextPaintPhase::Foreground:
return PaintPhase::Foreground;
case StackingContext::StackingContextPaintPhase::FocusAndOverlay:
return PaintPhase::Overlay;
default:
VERIFY_NOT_REACHED();
}
}
void StackingContext::paint_descendants(PaintContext& context, Layout::Node& box, StackingContextPaintPhase phase) const
{
if (phase == StackingContextPaintPhase::Foreground) {
if (auto* paintable = box.paintable())
paintable->before_children_paint(context, PaintPhase::Foreground);
}
if (auto* paintable = box.paintable())
paintable->before_children_paint(context, to_paint_phase(phase));
box.for_each_child([&](auto& child) {
// If `child` establishes its own stacking context, skip over it.
@ -104,10 +119,8 @@ void StackingContext::paint_descendants(PaintContext& context, Layout::Node& box
}
});
if (phase == StackingContextPaintPhase::Foreground) {
if (auto* paintable = box.paintable())
paintable->after_children_paint(context, PaintPhase::Foreground);
}
if (auto* paintable = box.paintable())
paintable->after_children_paint(context, to_paint_phase(phase));
}
void StackingContext::paint_internal(PaintContext& context) const