Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 60ad4ce2c9dba49e168cb8048022d1e9baf67afc
      
https://github.com/WebKit/WebKit/commit/60ad4ce2c9dba49e168cb8048022d1e9baf67afc
  Author: Wenson Hsieh <[email protected]>
  Date:   2024-04-03 (Wed, 03 Apr 2024)

  Changed paths:
    M Source/WebCore/loader/DocumentLoader.h
    M Source/WebCore/page/ElementTargetingController.cpp
    M Source/WebCore/page/ElementTargetingController.h
    M Source/WebCore/page/ElementTargetingTypes.h
    M Source/WebCore/page/Page.cpp
    M Source/WebKit/Shared/WebCoreArgumentCoders.serialization.in
    M Source/WebKit/Shared/WebsitePoliciesData.cpp
    M Source/WebKit/Shared/WebsitePoliciesData.h
    M Source/WebKit/Shared/WebsitePoliciesData.serialization.in
    M Source/WebKit/UIProcess/API/APITargetedElementInfo.h
    M Source/WebKit/UIProcess/API/APIWebsitePolicies.h
    M Source/WebKit/UIProcess/API/Cocoa/WKWebpagePreferences.mm
    M Source/WebKit/UIProcess/API/Cocoa/WKWebpagePreferencesPrivate.h
    M Source/WebKit/UIProcess/API/Cocoa/_WKTargetedElementInfo.h
    M Source/WebKit/UIProcess/API/Cocoa/_WKTargetedElementInfo.mm
    M Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj
    M Tools/TestWebKitAPI/Tests/WebKitCocoa/ElementTargetingTests.mm
    A Tools/TestWebKitAPI/Tests/WebKitCocoa/element-targeting-3.html
    M Tools/TestWebKitAPI/cocoa/TestWKWebView.h
    M Tools/TestWebKitAPI/cocoa/TestWKWebView.mm

  Log Message:
  -----------
  [Remote Inspection] Add a way to immediately apply visibility adjustment 
based on CSS selectors when loading
https://bugs.webkit.org/show_bug.cgi?id=272060

Reviewed by Aditya Keerthi.

Add a mechanism which allows WebKit clients to eagerly apply visibility 
adjustment to elements per
navigation, based on sets of CSS selectors. See below for more details.

* Source/WebCore/loader/DocumentLoader.h:
(WebCore::DocumentLoader::visibilityAdjustmentSelectors const):
(WebCore::DocumentLoader::setVisibilityAdjustmentSelectors):

Add plumbing from `WebsitePoliciesData` down into `DocumentLoader`, like all of 
the other per-load
website policies.

* Source/WebCore/page/ElementTargetingController.cpp:
(WebCore::computeClientRect):
(WebCore::targetedElementInfo):
(WebCore::ElementTargetingController::adjustVisibilityInRepeatedlyTargetedRegions):
(WebCore::ElementTargetingController::applyVisibilityAdjustmentFromSelectors):

If we haven't already done so yet, pull `visibilityAdjustmentSelectors` from 
the `DocumentLoader`
into `ElementTargetingController`. For up to 30 seconds after committing the 
load, continually look
for elements that correspond to these selectors, and immediately adjust 
visibility for them if
found.

(WebCore::ElementTargetingController::reset):
(WebCore::ElementTargetingController::resetAdjustmentRegions): Deleted.

Rename `resetAdjustmentRegions` to just `reset`, since it now clears out more 
state than just what's
necessary for tracking adjustment regions.

* Source/WebCore/page/ElementTargetingController.h:
* Source/WebCore/page/ElementTargetingTypes.h:
* Source/WebCore/page/Page.cpp:
(WebCore::Page::didCommitLoad):
* Source/WebKit/Shared/WebCoreArgumentCoders.serialization.in:
* Source/WebKit/Shared/WebsitePoliciesData.cpp:
(WebKit::WebsitePoliciesData::applyToDocumentLoader):
* Source/WebKit/Shared/WebsitePoliciesData.h:
* Source/WebKit/Shared/WebsitePoliciesData.serialization.in:

Add more plumbing for CSS selectors from the client down into WebCore.

* Source/WebKit/UIProcess/API/APITargetedElementInfo.h:
* Source/WebKit/UIProcess/API/APIWebsitePolicies.h:
* Source/WebKit/UIProcess/API/Cocoa/WKWebpagePreferences.mm:
(-[WKWebpagePreferences _setVisibilityAdjustmentSelectors:]):
(-[WKWebpagePreferences _visibilityAdjustmentSelectors]):

Add support for the new SPI. See above for more details.

* Source/WebKit/UIProcess/API/Cocoa/WKWebpagePreferencesPrivate.h:
* Source/WebKit/UIProcess/API/Cocoa/_WKTargetedElementInfo.h:
* Source/WebKit/UIProcess/API/Cocoa/_WKTargetedElementInfo.mm:
(-[_WKTargetedElementInfo boundsInWebView]):
(-[_WKTargetedElementInfo boundsInClientCoordinates]):

Also, clean up this `bounds` SPI property — currently, the `-bounds` property 
returns the bounds of
the element in root view coordinates, while the targeted element request 
expects a point in the web
view's coordinate space. To address this inconsistency and clarify the behavior 
of the API, add
alternatives to `bounds`: `boundsInWebView` and `boundsInClientCoordinates` 
that explicitly indicate
which coordinate space the bounds are in. Depending on the purpose, the client 
can use either.

* Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* Tools/TestWebKitAPI/Tests/WebKitCocoa/ElementTargetingTests.mm:
(TestWebKitAPI::setUpWebViewForSnapshotting):

Factor this setup code into a common helper to reduce code duplication.

(TestWebKitAPI::TEST(ElementTargeting, AdjustVisibilityForUnparentedElement)):
(TestWebKitAPI::TEST(ElementTargeting, AdjustVisibilityFromSelectors)):
(TestWebKitAPI::TEST(ElementTargeting, AdjustVisibilityFromPseudoSelectors)):

Add an API test to exercise the new SPI, and verify that it works well with the 
rest of the existing
SPI surface around visibility adjustment.

* Tools/TestWebKitAPI/Tests/WebKitCocoa/element-targeting-3.html: Added.
* Tools/TestWebKitAPI/cocoa/TestWKWebView.h:
* Tools/TestWebKitAPI/cocoa/TestWKWebView.mm:

(-[WKWebView synchronouslyLoadTestPageNamed:preferences:]):

Canonical link: https://commits.webkit.org/276990@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

Reply via email to