Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 1b90f5339ab042ec882acaed926f8bd0acc2d74c
https://github.com/WebKit/WebKit/commit/1b90f5339ab042ec882acaed926f8bd0acc2d74c
Author: Wenson Hsieh <[email protected]>
Date: 2024-03-29 (Fri, 29 Mar 2024)
Changed paths:
M Source/WebCore/dom/Element.cpp
M Source/WebCore/dom/Element.h
M Source/WebCore/dom/ElementRareData.h
M Source/WebCore/page/ElementTargetingController.cpp
M Source/WebCore/page/ElementTargetingController.h
M Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm
M Source/WebKit/UIProcess/API/Cocoa/WKWebViewPrivate.h
M Source/WebKit/UIProcess/WebPageProxy.cpp
M Source/WebKit/UIProcess/WebPageProxy.h
M Source/WebKit/WebProcess/WebPage/WebPage.cpp
M Source/WebKit/WebProcess/WebPage/WebPage.h
M Source/WebKit/WebProcess/WebPage/WebPage.messages.in
M Tools/TestWebKitAPI/Tests/WebKitCocoa/ElementTargetingTests.mm
Log Message:
-----------
[Remote Inspection] Add some more SPI to reset visibility adjustment and
count adjustment rects
https://bugs.webkit.org/show_bug.cgi?id=271901
Reviewed by Aditya Keerthi.
Add support for a couple of new methods on `WKWebView`. See below for more
detail.
* Source/WebCore/dom/Element.cpp:
(WebCore::Element::setVisibilityAdjustment):
(WebCore::Element::addVisibilityAdjustment): Deleted.
Rename `addVisibilityAdjustment` -> `setVisibilityAdjustment`, and make it
replace the rare data's
visibility adjustment flags (instead of only adding to them). This is
necessary, since we now need
a way to reset this flag and restore the original element state.
* Source/WebCore/dom/Element.h:
* Source/WebCore/dom/ElementRareData.h:
(WebCore::ElementRareData::setVisibilityAdjustment):
(WebCore::ElementRareData::addVisibilityAdjustment): Deleted.
More renaming — see above.
* Source/WebCore/page/ElementTargetingController.cpp:
(WebCore::inflatedClientRectForAdjustmentRegionTracking):
Pull this out into a static helper, so that we can also use it in
`resetVisibilityAdjustments` to
update the current visibility adjustment regions, to leave out elements that
are no longer adjusted.
(WebCore::adjustVisibilityIfNeeded):
Adopt `setVisibilityAdjustment`.
(WebCore::ElementTargetingController::adjustVisibility):
(WebCore::ElementTargetingController::adjustVisibilityInRepeatedlyTargetedRegions):
Keep track of all the elements in the top document that have been adjusted,
with a new member
`m_adjustedElements`. This is updated when the client explicitly triggers
visibility adjustment
through API, and also when we adjust visibility automatically for repeatedly
targeted regions.
(WebCore::ElementTargetingController::resetAdjustmentRegions):
Also reset `m_adjustedElements`.
(WebCore::ElementTargetingController::resetVisibilityAdjustments):
Use `m_adjustedElements` to undo any visibility adjustments for elements that
correspond to the list
of element identifiers (or, if the list is empty, all current adjusted
elements).
(WebCore::ElementTargetingController::numberOfVisibilityAdjustmentRects const):
Use `m_adjustedElements` to estimate the number of visually distinct adjustment
rects, relative to
client coordinates. Note that this intentionally treats fully overlapped
element regions as the same
rect, for the purposes of reporting the final count.
* Source/WebCore/page/ElementTargetingController.h:
* Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm:
(elementsFromWKElements):
(-[WKWebView
_resetVisibilityAdjustmentsForTargetedElements:completionHandler:]):
(-[WKWebView _adjustVisibilityForTargetedElements:completionHandler:]):
(-[WKWebView _numberOfVisibilityAdjustmentRectsWithCompletionHandler:]):
Add plumbing for these new methods.
* Source/WebKit/UIProcess/API/Cocoa/WKWebViewPrivate.h:
* Source/WebKit/UIProcess/WebPageProxy.cpp:
(WebKit::extractIdentifiers):
(WebKit::WebPageProxy::resetVisibilityAdjustmentsForTargetedElements):
(WebKit::WebPageProxy::adjustVisibilityForTargetedElements):
(WebKit::WebPageProxy::numberOfVisibilityAdjustmentRects):
* Source/WebKit/UIProcess/WebPageProxy.h:
* Source/WebKit/WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::resetVisibilityAdjustmentsForTargetedElements):
(WebKit::WebPage::numberOfVisibilityAdjustmentRects):
* Source/WebKit/WebProcess/WebPage/WebPage.h:
* Source/WebKit/WebProcess/WebPage/WebPage.messages.in:
* Tools/TestWebKitAPI/Tests/WebKitCocoa/ElementTargetingTests.mm:
(-[WKWebView numberOfVisibilityAdjustmentRects]):
(-[WKWebView resetVisibilityAdjustmentsForTargets:]):
(TestWebKitAPI::TEST(ElementTargeting, NearbyOutOfFlowElements)):
Augment an existing API test to cover these two new methods.
Canonical link: https://commits.webkit.org/276850@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