Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 46bfd8e48d3814386f441244ce11ea5651450343
https://github.com/WebKit/WebKit/commit/46bfd8e48d3814386f441244ce11ea5651450343
Author: Wenson Hsieh <[email protected]>
Date: 2025-10-17 (Fri, 17 Oct 2025)
Changed paths:
A
LayoutTests/editing/selection/ios/caret-rect-inside-scrollable-fixed-container-expected.txt
A
LayoutTests/editing/selection/ios/caret-rect-inside-scrollable-fixed-container.html
M Source/WebCore/platform/graphics/FloatPoint.h
M Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm
Log Message:
-----------
REGRESSION (295783@main): [iOS] Caret rect in fixed-position containers may
appear in the wrong place when the page's scroll offset is very large
https://bugs.webkit.org/show_bug.cgi?id=300952
rdar://162158640
Reviewed by Abrar Rahman Protyasha.
The changes in 295783@main were meant to clamp the `layoutViewportRect`'s
position to the
`unobscuredContentRect`'s position, only in the case where the difference
between the two positions
is due to rounding errors when converting floating point values to layout units
— at most,
`2 / kFixedPointDenominator`.
However, the logic to try and achieve this result uses
`WTF::areEssentiallyEqual` with an epsilon of
`2 / kFixedPointDenominator` (roughly 3%). This function interprets the
`epsilon` argument as a
maximum _ratio_ of the difference to the first argument (the unobscured content
rect's location)
rather than the maximum absolute difference between the two values.
Thus, during UI-driven scrolling as a result of bringing up the keyboard,
differences of ~300 px
between the `unobscuredContentRect` and `layoutViewportRect` when the
unobscured content rect's
scroll position is very large (~10000 px) cause us to incorrectly believe the
two rects' positions
are nearly equivalent because the 300 px difference is only 3% of 10000,
leading to the layout
viewport being incorrectly shifted upwards.
This breaks hit-testing, caret/selection geometry calculations, and even the
node highlight rect
when using Web Inspector to target individual elements.
To fix this, we instead check whether the maximum absolute difference in `x` or
`y` is less than or
equal to an `epsilon` that's clamped at a (fairly small) maximum value of 5 px.
Test: editing/selection/ios/caret-rect-inside-scrollable-fixed-container.html
*
LayoutTests/editing/selection/ios/caret-rect-inside-scrollable-fixed-container-expected.txt:
Added.
*
LayoutTests/editing/selection/ios/caret-rect-inside-scrollable-fixed-container.html:
Added.
* Source/WebCore/platform/graphics/FloatPoint.h:
(WebCore::areEssentiallyEqual):
Also remove the optional `epsilon` argument, since `updateVisibleContentRects`
was the only call
site that passed in a non-default `epsilon`.
* Source/WebCore/platform/graphics/FloatSize.h:
(WebCore::FloatSize::maxAbsoluteDimension const):
* Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm:
(WebKit::WebPage::updateVisibleContentRects):
Canonical link: https://commits.webkit.org/301719@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes