Skip to content

Avoid over-eager clipping of child layers in multicolumn #47276

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Ahmad-S792
Copy link
Contributor

@Ahmad-S792 Ahmad-S792 commented Jun 27, 2025

53e4565

Avoid over-eager clipping of child layers in multicolumn
https://bugs.webkit.org/show_bug.cgi?id=272280
rdar://126413036

Reviewed by NOBODY (OOPS!).

This patch aligns WebKit with Gecko / Firefox and Blink / Chromium.

Merge: https://chromium.googlesource.com/chromium/src.git/+/e500cbd3ba36bf3216087481790f5aece0e778a5

Self-painting layers (caused by e.g. position:relative) don't contribute to
visual overflow in their parent layout object; see
RenderBox::addOverflowFromChild(). We cannot use the visual overflow rectangle
set on the flow thread when calculating the bounding box of a fragment
established by a child layer.

Therefore, only clip in the flow thread's block direction in
overflowRectForFragmentedFlowPortion(), and leave the inline axis alone. I
simplified the implementation, since it's now way easier to start with an
infinite rectangle, and just limit the dimensions that need it afterwards.

Also got rid of an old check for shouldClipFragmentedFlowContent(), which
must have been residue from the CSS regions implementation.

This also happened to fix some inaccuracies mostly invisible to the naked
eye, when it comes to transform:scale()d text with glyphs that have negative
left bearing or overflow the line box vertically. It looks like we measure and
lay out with the CSS computed font, and then switch to a scaled font when
painting, so that it looks crisp and nice.

In WebKit, we didn't had equivalent to `infiniteIntRect` so introduce
'renderableInfiniteRect' and use it for our use case similar to other cases
in WebKit.

* Source/WebCore/rendering/RenderFragmentContainer.cpp:
(WebCore::RenderFragmentContainer::overflowRectForFragmentedFlowPortion const):

> Local Tests:
* LayoutTests/fast/multicol/scale-transform-text.html: Add Test Case
* LayoutTests/fast/multicol/scale-transform-text-expected.html: Add Test Case Expectation
* LayoutTests/fast/multicol/overflowing-relpos.html: Add Test Case
* LayoutTests/fast/multicol/overflowing-relpos-expected.html: Add Test Case Expectation

> WPT Progressions:
* LayoutTests/TestExpectations:
* LayoutTests/imported/w3c/web-platform-tests/css/css-break/relpos-inline-hit-testing-expected.txt:

> Rebaselines:
* LayoutTests/imported/blink/fast/multicol/unbreakable-block-too-tall-at-column-start.html: WPE & GTK Specific Pixel Failures
* LayoutTests/imported/w3c/web-platform-tests/css/css-anchor-position/anchor-scroll-003-expected.txt:
* LayoutTests/fast/multicol/client-rects.html: GTK specific

53e4565

Misc iOS, visionOS, tvOS & watchOS macOS Linux Windows
✅ 🧪 style ✅ 🛠 ios ✅ 🛠 mac ✅ 🛠 wpe ✅ 🛠 win
✅ 🧪 bindings ✅ 🛠 ios-sim ✅ 🛠 mac-AS-debug ✅ 🧪 wpe-wk2 ⏳ 🧪 win-tests
✅ 🧪 webkitperl ✅ 🧪 ios-wk2 ✅ 🧪 api-mac ✅ 🧪 api-wpe
✅ 🧪 ios-wk2-wpt ✅ 🧪 mac-wk1 ✅ 🛠 wpe-cairo
✅ 🧪 api-ios ✅ 🧪 mac-wk2 ✅ 🛠 gtk
✅ 🛠 vision ✅ 🧪 mac-AS-debug-wk2 ✅ 🧪 gtk-wk2
✅ 🛠 vision-sim ✅ 🧪 mac-wk2-stress ✅ 🧪 api-gtk
✅ 🧪 vision-wk2 ✅ 🧪 mac-intel-wk2 ✅ 🛠 playstation
✅ 🛠 tv ✅ 🛠 mac-safer-cpp
✅ 🛠 tv-sim
✅ 🛠 watch
✅ 🛠 watch-sim

@Ahmad-S792 Ahmad-S792 self-assigned this Jun 27, 2025
@Ahmad-S792 Ahmad-S792 added the Layout and Rendering For bugs with layout and rendering of Web pages. label Jun 27, 2025
@webkit-ews-buildbot webkit-ews-buildbot added the merging-blocked Applied to prevent a change from being merged label Jun 27, 2025
@Ahmad-S792 Ahmad-S792 removed the merging-blocked Applied to prevent a change from being merged label Jun 27, 2025
@Ahmad-S792 Ahmad-S792 force-pushed the eng/Avoid-over-eager-clipping-of-child-layers-in-multicolumn branch from daf5431 to 7ea91dd Compare June 27, 2025 06:35
@Ahmad-S792 Ahmad-S792 requested a review from alanbaradlay June 27, 2025 06:36
@webkit-ews-buildbot webkit-ews-buildbot added the merging-blocked Applied to prevent a change from being merged label Jun 27, 2025
https://bugs.webkit.org/show_bug.cgi?id=272280
rdar://126413036

Reviewed by NOBODY (OOPS!).

This patch aligns WebKit with Gecko / Firefox and Blink / Chromium.

Merge: https://chromium.googlesource.com/chromium/src.git/+/e500cbd3ba36bf3216087481790f5aece0e778a5

Self-painting layers (caused by e.g. position:relative) don't contribute to
visual overflow in their parent layout object; see
RenderBox::addOverflowFromChild(). We cannot use the visual overflow rectangle
set on the flow thread when calculating the bounding box of a fragment
established by a child layer.

Therefore, only clip in the flow thread's block direction in
overflowRectForFragmentedFlowPortion(), and leave the inline axis alone. I
simplified the implementation, since it's now way easier to start with an
infinite rectangle, and just limit the dimensions that need it afterwards.

Also got rid of an old check for shouldClipFragmentedFlowContent(), which
must have been residue from the CSS regions implementation.

This also happened to fix some inaccuracies mostly invisible to the naked
eye, when it comes to transform:scale()d text with glyphs that have negative
left bearing or overflow the line box vertically. It looks like we measure and
lay out with the CSS computed font, and then switch to a scaled font when
painting, so that it looks crisp and nice.

In WebKit, we didn't had equivalent to `infiniteIntRect` so introduce
'renderableInfiniteRect' and use it for our use case similar to other cases
in WebKit.

* Source/WebCore/rendering/RenderFragmentContainer.cpp:
(WebCore::RenderFragmentContainer::overflowRectForFragmentedFlowPortion const):

> Local Tests:
* LayoutTests/fast/multicol/scale-transform-text.html: Add Test Case
* LayoutTests/fast/multicol/scale-transform-text-expected.html: Add Test Case Expectation
* LayoutTests/fast/multicol/overflowing-relpos.html: Add Test Case
* LayoutTests/fast/multicol/overflowing-relpos-expected.html: Add Test Case Expectation

> WPT Progressions:
* LayoutTests/TestExpectations:
* LayoutTests/imported/w3c/web-platform-tests/css/css-break/relpos-inline-hit-testing-expected.txt:

> Rebaselines:
* LayoutTests/imported/blink/fast/multicol/unbreakable-block-too-tall-at-column-start.html: WPE & GTK Specific Pixel Failures
* LayoutTests/imported/w3c/web-platform-tests/css/css-anchor-position/anchor-scroll-003-expected.txt:
* LayoutTests/fast/multicol/client-rects.html: GTK specific
@Ahmad-S792 Ahmad-S792 removed the merging-blocked Applied to prevent a change from being merged label Jun 27, 2025
@Ahmad-S792 Ahmad-S792 force-pushed the eng/Avoid-over-eager-clipping-of-child-layers-in-multicolumn branch from 7ea91dd to 53e4565 Compare June 27, 2025 08:00
@Ahmad-S792 Ahmad-S792 added the request-merge-queue Request a pull request to be added to merge-queue once ready label Jun 28, 2025
Comment on lines +161 to +164
auto renderableInfiniteRect = [] {
// Return a infinite-like rect whose values are such that, when converted to float pixel values, they can reasonably represent device pixels.
return LayoutRect(LayoutUnit::nearlyMin() / 32, LayoutUnit::nearlyMin() / 32, LayoutUnit::nearlyMax() / 16, LayoutUnit::nearlyMax() / 16);
}();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

any particular reason for not using LayoutRect's infiniteRect?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It leads to WPT failure - css/css-break/out-of-flow-in-multicolumn-018.htm.

Copy link
Contributor Author

@Ahmad-S792 Ahmad-S792 Jun 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@alanbaradlay - I noticed that Blink has infiniteIntRect, which is different from our infiniteRect. I think either we update our or introduce newer helper. I copied this one from Simon's from here - https://searchfox.org/wubkat/rev/4e9806c2e7f7c29e4a6d87ebeca603c4cc8f080c/Source/WebCore/rendering/RenderLayerCompositor.cpp#3630 to workaround here.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let me debug this.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am going to defer to @smfr on this, but 1, it does not scale well 2, technically we now return a non-infinite rect even when there's no clipping at all (so comparing to LayoutRect::infiniteRect() will return false)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Layout and Rendering For bugs with layout and rendering of Web pages. request-merge-queue Request a pull request to be added to merge-queue once ready
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants