Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: daa83dc8ed6a2a6c6364b9c6de5e024649c4d842
https://github.com/WebKit/WebKit/commit/daa83dc8ed6a2a6c6364b9c6de5e024649c4d842
Author: Ahmad Saleem <[email protected]>
Date: 2026-08-05 (Wed, 05 Aug 2026)
Changed paths:
A
LayoutTests/fast/backgrounds/obscured-background-css-clipped-child-expected.html
A LayoutTests/fast/backgrounds/obscured-background-css-clipped-child.html
A
LayoutTests/fast/backgrounds/obscured-background-css-clipped-grandchild-expected.html
A
LayoutTests/fast/backgrounds/obscured-background-css-clipped-grandchild.html
M Source/WebCore/rendering/RenderBox.cpp
Log Message:
-----------
CSS clip on a child is ignored when determining whether an ancestor's
background is obscured
https://bugs.webkit.org/show_bug.cgi?id=320829
rdar://183841775
Reviewed by Antti Koivisto.
This patch aligns WebKit with Gecko / Firefox and Blink / Chromium.
Merge:
https://chromium.googlesource.com/chromium/src.git/+/f3d25d319c4feb8ad68c6fde2b3ef3972384f1fe
RenderBox::foregroundIsKnownToBeOpaqueInRect() computes whether a box's
background is obscured by recursively checking if any descendant fully
covers it, letting BackgroundPainter skip painting the background. The
recursion did not account for descendants with CSS clip, so an ancestor
could be treated as obscured even though the covering descendant only
painted part of its border box.
RenderBox::backgroundIsKnownToBeOpaqueInRect() already bails out on
hasClip(), so a directly clipped child was handled. The gap was one level
down: a clipped child with no background of its own was still recursed
into, and an opaque grandchild filling that child was taken as covering
the ancestor. The clip on the intermediate child was never consulted.
Reject clipped boxes in isCandidateForOpaquenessTest() instead of in
backgroundIsKnownToBeOpaqueInRect(), since CSS clip applies to a box's
foreground as well as its background. hasClip() is
isOutOfFlowPositioned() && !style().clip().isAuto(), so it already
encodes that clip only applies to out-of-flow boxes.
This makes the obscuration optimization fire less often and so paints
some backgrounds that were previously skipped. The compositing path is
unaffected: RenderLayerBacking::setContentsOpaque() reaches
RenderBox::backgroundIsKnownToBeOpaqueInRect(), which already checked
hasClip().
Tests: fast/backgrounds/obscured-background-css-clipped-child.html
fast/backgrounds/obscured-background-css-clipped-grandchild.html
*
LayoutTests/fast/backgrounds/obscured-background-css-clipped-child-expected.html:
Added.
* LayoutTests/fast/backgrounds/obscured-background-css-clipped-child.html:
Added.
*
LayoutTests/fast/backgrounds/obscured-background-css-clipped-grandchild-expected.html:
Added.
* LayoutTests/fast/backgrounds/obscured-background-css-clipped-grandchild.html:
Added.
* Source/WebCore/rendering/RenderBox.cpp:
(WebCore::isCandidateForOpaquenessTest):
Canonical link: https://commits.webkit.org/318636@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications