Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: bf83909d56bdefe29b4fa8cfc3233a34eea16b9b
https://github.com/WebKit/WebKit/commit/bf83909d56bdefe29b4fa8cfc3233a34eea16b9b
Author: Tim Horton <[email protected]>
Date: 2026-09-25 (Fri, 25 Sep 2026)
Changed paths:
M Source/WebCore/page/IntersectionObserver.cpp
M Source/WebCore/page/LargestContentfulPaintData.cpp
M Source/WebCore/page/ViewportProximityInfo.cpp
M Source/WebCore/rendering/RenderBox.cpp
M Source/WebCore/rendering/RenderObject.cpp
M Source/WebCore/rendering/RenderObject.h
M Source/WebCore/rendering/RenderObjectInlines.h
M Source/WebCore/rendering/VisibleRectContext.h
Log Message:
-----------
Share element intersection computation code between various clients, and
prepare it for further reuse
https://bugs.webkit.org/show_bug.cgi?id=325068
rdar://188231988
Reviewed by Abrar Rahman Protyasha.
No new tests, just refactoring, should be covered by existing tests for
relevant features.
Factor out of IntersectionObserver the gold-standard version of "give me the
rect
for this element with all scrolls/clips applied", and re-use it in LCP and
borderAndTextRects code that have similar pieces. We'll add another client
shortly.
To keep IntersectionObserver-specific logic out of the rendering code, the
hoisted
main-frame computation no longer knows about scroll margin or security origins.
Instead, it takes a ClipRectAdjuster, which is given the chance to adjust each
clip rect along the way. IntersectionObserver supplies one that expands clips
by its scroll margin, and stops doing so once it encounters a cross-origin
frame.
* Source/WebCore/rendering/RenderObject.h:
* Source/WebCore/rendering/RenderObject.cpp:
(WebCore::RenderObject::localBoundsForIntersection const):
(WebCore::clippedRectInContentsSpace):
(WebCore::RenderObject::computeClippedRectInContentCoordinates const):
(WebCore::computeClippedRectInMainFrameContentCoordinates):
(WebCore::RenderObject::computeClippedRectInMainFrameContentCoordinates const):
Hoist these out of the clients.
(WebCore::RenderObject::hasEmptyVisibleRectRespectingParentFrames const):
(WebCore::borderAndTextRects):
Adopt one of the hoisted methods. This adds a isSkippedContent check, but that
seems correct.
* Source/WebCore/rendering/VisibleRectContext.h:
(WebCore::VisibleRectContext::adjustScrollContainerClipRect const):
Replace scrollMargin with scrollContainerClipRectAdjuster, a nullable pointer
to a
ClipRectAdjuster that is applied to scroll container clips.
* Source/WebCore/rendering/RenderBox.cpp:
(WebCore::RenderBox::applyCachedClipAndScrollPosition const):
Let the ClipRectAdjuster apply the scroll margin as needed.
* Source/WebCore/rendering/RenderObjectInlines.h:
(WebCore::RenderObject::visibleRectContextForRepaint):
(WebCore::RenderObject::visibleRectContextForSpatialNavigation):
(WebCore::RenderObject::visibleRectContextForRenderTreeAsText):
* Source/WebCore/page/ViewportProximityInfo.cpp:
(WebCore::visibleAbsoluteRect):
* Source/WebCore/page/IntersectionObserver.cpp:
(WebCore::IntersectionObserver::computeIntersectionState const):
(WebCore::computeClippedRectInRootContentsSpace): Deleted.
Adopt one of the hoisted methods, providing a ClipRectAdjuster that applies
scroll
margin up to the first cross-origin frame.
* Source/WebCore/page/LargestContentfulPaintData.cpp:
(WebCore::LargestContentfulPaintData::computeViewportIntersectionRect):
Adopt one of the hoisted methods.
Canonical link: https://commits.webkit.org/321931@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications