Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 9449d94cd8a3a294b2462c255d74e6f82b171e63
https://github.com/WebKit/WebKit/commit/9449d94cd8a3a294b2462c255d74e6f82b171e63
Author: Chris Dumez <[email protected]>
Date: 2026-04-06 (Mon, 06 Apr 2026)
Changed paths:
A
LayoutTests/imported/w3c/web-platform-tests/css/cssom/caretPositionFromPoint-in-flex-container-expected.txt
A
LayoutTests/imported/w3c/web-platform-tests/css/cssom/caretPositionFromPoint-in-flex-container.html
M Source/WebCore/rendering/RenderBox.cpp
Log Message:
-----------
Fix inverted Y-axis comparison in RenderBox::positionForPoint
https://bugs.webkit.org/show_bug.cgi?id=311543
Reviewed by Alan Baradlay.
The exact-hit check for whether a point falls inside a child's content
box had the Y comparisons swapped: it required point.y() <= top AND
point.y() >= bottom, which is impossible when bottom > top (always true
since contentBoxHeight() is non-negative). This meant the early return
never fired, and the function always fell through to the distance-based
closest-child search.
The distance fallback computes the distance from the point to each
child's nearest edge. When the point is inside a tall child near its
top edge, the distance to that child's bottom edge can be very large,
while the distance to a short preceding sibling's bottom edge is small.
This causes the wrong child to be selected, misplacing the caret.
This is observable via caretPositionFromPoint on flex/grid containers
when the hit-test returns the container rather than a child (e.g. when
children have pointer-events: none).
Test:
imported/w3c/web-platform-tests/css/cssom/caretPositionFromPoint-in-flex-container.html
- This test is failing in shipping Safari but passing in Chrome and Firefox.
*
LayoutTests/imported/w3c/web-platform-tests/css/cssom/caretPositionFromPoint-in-flex-container-expected.txt:
Added.
*
LayoutTests/imported/w3c/web-platform-tests/css/cssom/caretPositionFromPoint-in-flex-container.html:
Added.
* Source/WebCore/rendering/RenderBox.cpp:
(WebCore::RenderBox::positionForPoint):
Canonical link: https://commits.webkit.org/310626@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications