Skip to content

When moving past a left-hand scrollbar, don't jump way outside the content box #47344

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 28, 2025

a28f91d

When moving past a left-hand scrollbar, don't jump way outside the content box
https://bugs.webkit.org/show_bug.cgi?id=279324
rdar://136040116

Reviewed by NOBODY (OOPS!).

Merge (non-inline fix): https://source.chromium.org/chromium/chromium/src/+/d457f863f78941ed376b463ee39476b1a1852797
& https://chromium.googlesource.com/chromium/src.git/+/49858cc9147612da1e54a673147e8020c5d7b9f9

This patch fixes edge cases where scrollWidth can be messed up by left-hand
scroller leading to be outside of content box in case of a scrollbar being
wider than its containing block.

* Source/WebCore/rendering/RenderBlockFlow.cpp:
(WebCore::RenderBlockFlow::determineLogicalLeftPositionForChild):
* Source/WebCore/rendering/RenderBox.cpp:
(WebCore::RenderBox::verticalScrollbarWidthClampedToContentBox const):
* Source/WebCore/rendering/RenderBox.h:
* LayoutTests/fast/scrolling/content-box-smaller-than-scrollbar.html:
* LayoutTests/fast/table/cell-percent-padding-expected.txt:
* LayoutTests/fast/table/cell-percent-padding.html:
* LayoutTests/fast/scrolling/content-box-smaller-than-scrollbar-expected.txt:
* LayoutTests/platform/ios/TestExpectations: Add Platform Specific Expectation due to RTL scrollbars

a28f91d

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 loading-orange 🧪 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 28, 2025
@Ahmad-S792 Ahmad-S792 added the Scrolling Bugs related to main thread and off-main thread scrolling label Jun 28, 2025
@Ahmad-S792 Ahmad-S792 marked this pull request as draft June 28, 2025 21:03
@webkit-ews-buildbot webkit-ews-buildbot added the merging-blocked Applied to prevent a change from being merged label Jun 28, 2025
…ntent box

https://bugs.webkit.org/show_bug.cgi?id=279324
rdar://136040116

Reviewed by NOBODY (OOPS!).

Merge (non-inline fix): https://source.chromium.org/chromium/chromium/src/+/d457f863f78941ed376b463ee39476b1a1852797
& https://chromium.googlesource.com/chromium/src.git/+/49858cc9147612da1e54a673147e8020c5d7b9f9

This patch fixes edge cases where scrollWidth can be messed up by left-hand
scroller leading to be outside of content box in case of a scrollbar being
wider than its containing block.

* Source/WebCore/rendering/RenderBlockFlow.cpp:
(WebCore::RenderBlockFlow::determineLogicalLeftPositionForChild):
* Source/WebCore/rendering/RenderBox.cpp:
(WebCore::RenderBox::verticalScrollbarWidthClampedToContentBox const):
* Source/WebCore/rendering/RenderBox.h:
* LayoutTests/fast/scrolling/content-box-smaller-than-scrollbar.html:
* LayoutTests/fast/table/cell-percent-padding-expected.txt:
* LayoutTests/fast/table/cell-percent-padding.html:
* LayoutTests/fast/scrolling/content-box-smaller-than-scrollbar-expected.txt:
* LayoutTests/platform/ios/TestExpectations: Add Platform Specific Expectation due to RTL scrollbars
@Ahmad-S792 Ahmad-S792 removed the merging-blocked Applied to prevent a change from being merged label Jun 29, 2025
@Ahmad-S792 Ahmad-S792 force-pushed the eng/When-moving-past-a-left-hand-scrollbar-don-t-jump-way-outside-the-content-box branch from 78ab849 to a28f91d Compare June 29, 2025 14:53
@Ahmad-S792 Ahmad-S792 marked this pull request as ready for review June 29, 2025 15:26
@Ahmad-S792 Ahmad-S792 requested review from smfr and alanbaradlay June 29, 2025 15:27
@@ -1213,7 +1213,7 @@ void RenderBlockFlow::determineLogicalLeftPositionForChild(RenderBox& child, App
LayoutUnit startPosition = borderAndPaddingStart();
LayoutUnit initialStartPosition = startPosition;
if ((shouldPlaceVerticalScrollbarOnLeft() || style().scrollbarGutter().bothEdges) && isHorizontalWritingMode())
startPosition += (writingMode().isLogicalLeftInlineStart() ? 1 : -1) * verticalScrollbarWidth();
startPosition += (writingMode().isLogicalLeftInlineStart() ? 1 : -1) * verticalScrollbarWidthClampedToContentBox();
Copy link
Contributor

Choose a reason for hiding this comment

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

auto verticalScrollbarWidthClampedToContentBox = std::min(verticalScrollbarWidth(), std::max(0_lu, contentBoxLogicalWidth()))
would probably just work instead of introducing such specific function on RenderBox. -but even if we did introduce it , shouldn't it be on RenderBlockFlow? (I am also wondering if there's a reason for not using contentBoxLogicalWidth)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@alanbaradlay - I tried - it works but it fails:

auto verticalScrollbarWidthClampedToContentBox = std::min<LayoutUnit>(verticalScrollbarWidth(), std::max(0_lu, contentBoxLogicalWidth()));

It leads to failure:

FAIL RTL scrollable with block-level child assert_equals: expected 502 but got 504

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Scrolling Bugs related to main thread and off-main thread scrolling
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants