mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 08:58:11 +00:00
LibWeb: Clip hidden overflow by absolute rect of containing block
Since handling overflow: hidden in PaintableBox::before_children_paint while following paint traversal order can't result in correctly computed clip rectangle for elements that create their own stacking context (because before_children_paint is called only for parent but overflow: hidden can be set somewhere deeper but not in direct ancestor), here introduced new function PaintableBox::clip_rect() that computes clip rectangle by looking into containing block. should_clip_overflow flag that disables clip for absolutely positioned elements in before_children_paint and after_children_paint is removed because after changing clip rectangle to be computed from not parent but containing block it is not needed anymore (absolutely positioned item is clipped if it's containing block has hidden overflow)
This commit is contained in:
parent
c1401b37c4
commit
f3d57e1157
10 changed files with 55 additions and 40 deletions
|
@ -72,7 +72,7 @@ static PaintPhase to_paint_phase(StackingContext::StackingContextPaintPhase phas
|
|||
void StackingContext::paint_descendants(PaintContext& context, Layout::Node const& box, StackingContextPaintPhase phase) const
|
||||
{
|
||||
if (auto* paintable = box.paintable())
|
||||
paintable->before_children_paint(context, to_paint_phase(phase), Paintable::ShouldClipOverflow::Yes);
|
||||
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.
|
||||
|
@ -125,7 +125,7 @@ void StackingContext::paint_descendants(PaintContext& context, Layout::Node cons
|
|||
});
|
||||
|
||||
if (auto* paintable = box.paintable())
|
||||
paintable->after_children_paint(context, to_paint_phase(phase), Paintable::ShouldClipOverflow::Yes);
|
||||
paintable->after_children_paint(context, to_paint_phase(phase));
|
||||
}
|
||||
|
||||
void StackingContext::paint_internal(PaintContext& context) const
|
||||
|
@ -137,13 +137,12 @@ void StackingContext::paint_internal(PaintContext& context) const
|
|||
|
||||
auto paint_child = [&](auto* child) {
|
||||
auto parent = child->m_box.parent();
|
||||
auto should_clip_overflow = child->m_box.is_absolutely_positioned() ? Paintable::ShouldClipOverflow::No : Paintable::ShouldClipOverflow::Yes;
|
||||
auto* paintable = parent ? parent->paintable() : nullptr;
|
||||
if (paintable)
|
||||
paintable->before_children_paint(context, PaintPhase::Foreground, should_clip_overflow);
|
||||
paintable->before_children_paint(context, PaintPhase::Foreground);
|
||||
child->paint(context);
|
||||
if (paintable)
|
||||
paintable->after_children_paint(context, PaintPhase::Foreground, should_clip_overflow);
|
||||
paintable->after_children_paint(context, PaintPhase::Foreground);
|
||||
};
|
||||
|
||||
// Draw positioned descendants with negative z-indices (step 3)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue