Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 9b7b8ded8fa6f6aa85d72ec5f68bee3252c00a81
      
https://github.com/WebKit/WebKit/commit/9b7b8ded8fa6f6aa85d72ec5f68bee3252c00a81
  Author: Wenson Hsieh <wenson_hs...@apple.com>
  Date:   2024-05-22 (Wed, 22 May 2024)

  Changed paths:
    M Source/WebCore/page/ElementTargetingController.cpp
    M Source/WebCore/page/ElementTargetingController.h
    M Source/WebCore/page/ElementTargetingTypes.h
    M Source/WebKit/Shared/WebCoreArgumentCoders.serialization.in
    M Source/WebKit/UIProcess/API/APITargetedElementInfo.h
    M Source/WebKit/UIProcess/API/APITargetedElementRequest.cpp
    M Source/WebKit/UIProcess/API/APITargetedElementRequest.h
    M Source/WebKit/UIProcess/API/Cocoa/_WKTargetedElementInfo.h
    M Source/WebKit/UIProcess/API/Cocoa/_WKTargetedElementInfo.mm
    M Source/WebKit/UIProcess/API/Cocoa/_WKTargetedElementRequest.h
    M Source/WebKit/UIProcess/API/Cocoa/_WKTargetedElementRequest.mm
    M Tools/TestWebKitAPI/Tests/WebKitCocoa/ElementTargetingTests.mm

  Log Message:
  -----------
  [Remote Inspection] Add the ability to target elements based on selector 
information
https://bugs.webkit.org/show_bug.cgi?id=274532

Reviewed by Aditya Keerthi.

Add the ability to target elements based on compound selectors (i.e. selectors 
including all shadow
hosts). Additionally, expose a new property on targeted element info to 
indicate whether or not the
element is inside of an adjustment subtree.

See below for more details.

Test: ElementTargeting.RequestElementsFromSelectors

* Source/WebCore/page/ElementTargetingController.cpp:
(WebCore::targetedElementInfo):
(WebCore::ElementTargetingController::findTargets):
(WebCore::ElementTargetingController::findNodes):

Add `WebCore::TargetedElementSelectors` as a new type of targeted element 
request data, alongside
a point in root view coordinates and a search string. Add a new `findNodes()` 
implementation for
this targeted element selectors list. Build on top of the 
`findElementFromSelectors` method (see
below for more details).

(WebCore::ElementTargetingController::extractTargets):

Drive-by adjustment: only target elements if they're non-empty. This can 
otherwise happen in the
case where the list of candidates was derived from ascending the DOM when 
performing a text search.

(WebCore::ElementTargetingController::adjustVisibilityInRepeatedlyTargetedRegions):
(WebCore::resolveSelectorToQuery):

Pull this out into a separate static helper function, so we can use it from 
both methods below.

(WebCore::ElementTargetingController::applyVisibilityAdjustmentFromSelectors):

Pull logic out of this method, and into `findElementFromSelectors`. Also, 
remove the document
argument (which was only ever the main document), and instead just retrieve the 
main document from
the `m_page` (or exit early if it's null).

(WebCore::ElementTargetingController::findElementFromSelectors):

Factor out logic for mapping a list of compound selectors (including all shadow 
hosts) into a
separate private method, so that it can be reused in multiple places in this 
class.

(WebCore::ElementTargetingController::mainDocument const):

Avoid some code duplication by adding a private helper method to return the 
main document, through
`m_page`.

(WebCore::ElementTargetingController::selectorBasedVisibilityAdjustmentTimerFired):
* Source/WebCore/page/ElementTargetingController.h:
* Source/WebCore/page/ElementTargetingTypes.h:
* Source/WebKit/Shared/WebCoreArgumentCoders.serialization.in:

Add the new IPC types.

* Source/WebKit/UIProcess/API/APITargetedElementInfo.h:
* Source/WebKit/UIProcess/API/APITargetedElementRequest.cpp:
(API::TargetedElementRequest::setSelectors):
(API::TargetedElementRequest::searchText const): Deleted.

Remove an unused getter for `-searchText`, along with support in the API object.

* Source/WebKit/UIProcess/API/APITargetedElementRequest.h:
* Source/WebKit/UIProcess/API/Cocoa/_WKTargetedElementInfo.h:
* Source/WebKit/UIProcess/API/Cocoa/_WKTargetedElementInfo.mm:
(-[_WKTargetedElementInfo isInVisibilityAdjustmentSubtree]):
* Source/WebKit/UIProcess/API/Cocoa/_WKTargetedElementRequest.h:
* Source/WebKit/UIProcess/API/Cocoa/_WKTargetedElementRequest.mm:
(-[_WKTargetedElementRequest initWithSelectors:]):

Add a new initializer that takes a compound selector representing the element 
to target.

(-[_WKTargetedElementRequest searchText]): Deleted.
(-[_WKTargetedElementRequest point]): Deleted.
* Tools/TestWebKitAPI/Tests/WebKitCocoa/ElementTargetingTests.mm:
(-[WKWebView targetedElementInfoWithSelectors:]):
(TestWebKitAPI::TEST(ElementTargeting, RequestElementsFromSelectors)):

Add a new API test to exercise the change.

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

Canonical link: https://commits.webkit.org/279178@main



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to