Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 39a323e0f73673f8bf83f701cf6ee83a130d7cbe
https://github.com/WebKit/WebKit/commit/39a323e0f73673f8bf83f701cf6ee83a130d7cbe
Author: Simon Fraser <[email protected]>
Date: 2023-07-31 (Mon, 31 Jul 2023)
Changed paths:
M Source/WebCore/page/IntersectionObserver.cpp
M Source/WebCore/page/IntersectionObserver.h
Log Message:
-----------
Optimize Intersection Observer computations slightly
https://bugs.webkit.org/show_bug.cgi?id=259630
rdar://113083595
Reviewed by Ryosuke Niwa.
Refactor computeIntersectionState() so that we can lazily compute
intersectionState.absoluteRootBounds()
only when we know we're going to fire an observation.
This requires passing the IntersectionObserverRegistration to
computeIntersectionState(), which now
makes more sense as a member function, and moving the computation of
thresholdIndex into this
function, so we can compute absoluteRootBounds and absoluteTargetRect lazily
when we know we're going
to fire the observation.
IntersectionObservationState becomes a class-private struct since the member
function returns it.
To make it clearer which rectangles have valid values in
IntersectionObservationState, use
std::optional<FloatRect>s. Rename "localRootBounds" to "rootBounds" because the
"local" there didn't
add any information.
Make extensive use of lambda functions in
IntersectionObserver::computeIntersectionState() to
group related code and allow for early returns for clarity.
For RenderInlines, replace a call to target.boundingAbsoluteRectWithoutLayout()
by code that
calls absoluteQuads() directly, since this is what
boundingAbsoluteRectWithoutLayout() does for
inlines. Add a note about how inefficient this is.
There should be no behavior change here. Tested by WPT Intersection Observer
tests.
* Source/WebCore/page/IntersectionObserver.cpp:
(WebCore::expandRootBoundsWithRootMargin):
(WebCore::IntersectionObserver::computeIntersectionState const):
(WebCore::IntersectionObserver::updateObservations):
(): Deleted.
(WebCore::computeIntersectionState): Deleted.
* Source/WebCore/page/IntersectionObserver.h:
Canonical link: https://commits.webkit.org/266458@main
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes