[webkit-changes] [WebKit/WebKit] 3aef7b: Add WebKit API scaffolding to request targeted ele...

Wenson Hsieh noreply at github.com
Thu Mar 21 10:48:28 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 3aef7bcbbd03300d317244630b68a512fbbf2cae
      https://github.com/WebKit/WebKit/commit/3aef7bcbbd03300d317244630b68a512fbbf2cae
  Author: Wenson Hsieh <wenson_hsieh at apple.com>
  Date:   2024-03-21 (Thu, 21 Mar 2024)

  Changed paths:
    M Source/WebCore/Headers.cmake
    M Source/WebCore/Sources.txt
    M Source/WebCore/WebCore.xcodeproj/project.pbxproj
    A Source/WebCore/page/ElementTargeting.cpp
    A Source/WebCore/page/ElementTargeting.h
    A Source/WebCore/page/ElementTargetingTypes.h
    M Source/WebKit/Scripts/webkit/messages.py
    M Source/WebKit/Shared/API/APIObject.h
    M Source/WebKit/Shared/API/Cocoa/WebKitPrivate.h
    M Source/WebKit/Shared/Cocoa/APIObject.mm
    M Source/WebKit/Shared/WebCoreArgumentCoders.serialization.in
    M Source/WebKit/Sources.txt
    M Source/WebKit/SourcesCocoa.txt
    A Source/WebKit/UIProcess/API/APITargetedElementInfo.cpp
    A Source/WebKit/UIProcess/API/APITargetedElementInfo.h
    M Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm
    M Source/WebKit/UIProcess/API/Cocoa/WKWebViewPrivate.h
    A Source/WebKit/UIProcess/API/Cocoa/_WKRectEdge.h
    A Source/WebKit/UIProcess/API/Cocoa/_WKTargetedElementInfo.h
    A Source/WebKit/UIProcess/API/Cocoa/_WKTargetedElementInfo.mm
    A Source/WebKit/UIProcess/API/Cocoa/_WKTargetedElementInfoInternal.h
    A Source/WebKit/UIProcess/API/Cocoa/_WKTargetedElementRequest.h
    A Source/WebKit/UIProcess/API/Cocoa/_WKTargetedElementRequest.mm
    M Source/WebKit/UIProcess/Cocoa/SOAuthorization/SubFrameSOAuthorizationSession.mm
    M Source/WebKit/UIProcess/Cocoa/VideoPresentationManagerProxy.mm
    M Source/WebKit/UIProcess/PageClient.h
    M Source/WebKit/UIProcess/WebPageProxy.cpp
    M Source/WebKit/UIProcess/WebPageProxy.h
    M Source/WebKit/UIProcess/ios/PageClientImplIOS.h
    M Source/WebKit/UIProcess/ios/PageClientImplIOS.mm
    M Source/WebKit/WebKit.xcodeproj/project.pbxproj
    M Source/WebKit/WebProcess/WebPage/WebPage.cpp
    M Source/WebKit/WebProcess/WebPage/WebPage.h
    M Source/WebKit/WebProcess/WebPage/WebPage.messages.in

  Log Message:
  -----------
  Add WebKit API scaffolding to request targeted elements for remote inspection
https://bugs.webkit.org/show_bug.cgi?id=271333

Reviewed by Aditya Keerthi.

Add WebKit API objects and SPI stubs to hit-test DOM elements for improved element targeting when
the web view is in element selection mode. See below for more details.

* Source/WebCore/Headers.cmake:
* Source/WebCore/Sources.txt:
* Source/WebCore/WebCore.xcodeproj/project.pbxproj:
* Source/WebCore/page/ElementTargeting.cpp: Copied from Source/WebKit/Shared/API/Cocoa/WebKitPrivate.h.
(WebCore::findTargetedElements):
* Source/WebCore/page/ElementTargeting.h: Copied from Source/WebKit/Shared/API/Cocoa/WebKitPrivate.h.
* Source/WebCore/page/ElementTargetingTypes.h: Copied from Source/WebKit/Shared/API/Cocoa/WebKitPrivate.h.

Add a header declaring the new core types in WebCore: `TargetedElementInfo` (which corresponds to
the API object of the same name in WebKit) and `TargetedElementRequest` (which corresponds to
`_WKTargetedElementRequest`).

* Source/WebKit/Scripts/webkit/messages.py:
(headers_for_type):
* Source/WebKit/Shared/API/APIObject.h:
* Source/WebKit/Shared/API/Cocoa/WebKitPrivate.h:

Add the new private headers to the umbrella.

* Source/WebKit/Shared/Cocoa/APIObject.mm:
(API::Object::newObject):
* Source/WebKit/Shared/WebCoreArgumentCoders.serialization.in:
* Source/WebKit/Sources.txt:
* Source/WebKit/SourcesCocoa.txt:
* Source/WebKit/UIProcess/API/APITargetedElementInfo.cpp: Copied from Source/WebKit/Shared/API/Cocoa/WebKitPrivate.h.
(API::TargetedElementInfo::TargetedElementInfo):

Add an API object to represent a single targeted element retrieved via the new SPI, which is wrapped
by the Objective-C SPI object `_WKTargetedElementInfo`.

(API::TargetedElementInfo::isSameElement const):
(API::TargetedElementInfo::boundsInWebView const):
* Source/WebKit/UIProcess/API/APITargetedElementInfo.h: Added.
* Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView _requestTargetedElementInfo:completionHandler:]):
* Source/WebKit/UIProcess/API/Cocoa/WKWebViewPrivate.h:
* Source/WebKit/UIProcess/API/Cocoa/_WKRectEdge.h: Copied from Source/WebKit/Shared/API/Cocoa/WebKitPrivate.h.

Move the existing macOS-specific declaration of `_WKRectEdge` out to a separate header, and make it
available on iOS as well. This allows us to reuse this type for the new property on
`_WKTargetedElementInfo`.

* Source/WebKit/UIProcess/API/Cocoa/_WKTargetedElementInfo.h: Copied from Source/WebKit/Shared/API/Cocoa/WebKitPrivate.h.
* Source/WebKit/UIProcess/API/Cocoa/_WKTargetedElementInfo.mm: Added.
(-[_WKTargetedElementInfo dealloc]):
(-[_WKTargetedElementInfo _apiObject]):
(-[_WKTargetedElementInfo positionType]):
(-[_WKTargetedElementInfo bounds]):
(-[_WKTargetedElementInfo selectors]):
(-[_WKTargetedElementInfo renderedText]):
(-[_WKTargetedElementInfo offsetEdges]):
(-[_WKTargetedElementInfo hasBottomOffset]):
(-[_WKTargetedElementInfo hasLeftOffset]):
(-[_WKTargetedElementInfo hasRightOffset]):
(-[_WKTargetedElementInfo isSameElement:]):
* Source/WebKit/UIProcess/API/Cocoa/_WKTargetedElementInfoInternal.h: Copied from Source/WebKit/Shared/API/Cocoa/WebKitPrivate.h.
* Source/WebKit/UIProcess/API/Cocoa/_WKTargetedElementRequest.h: Copied from Source/WebKit/Shared/API/Cocoa/WebKitPrivate.h.
* Source/WebKit/UIProcess/API/Cocoa/_WKTargetedElementRequest.mm: Copied from Source/WebKit/Shared/API/Cocoa/WebKitPrivate.h.

I opted to avoid making a new API object to represent the request object, since it's only a single
`CGPoint` (and may include another boolean parameter in the future). If these request options become
more complex, we can consider introducing an intermediate `API::TargetedElementRequest` class to
represent this.

* Source/WebKit/UIProcess/Cocoa/SOAuthorization/SubFrameSOAuthorizationSession.mm:
* Source/WebKit/UIProcess/Cocoa/VideoPresentationManagerProxy.mm:

Some build fixes here, due to unified source order changes.

* Source/WebKit/UIProcess/PageClient.h:
(WebKit::PageClient::rootViewToWebView const):

Add a client helper method to map the given rect from root view coordinates to web view coordinates.
On iOS, this maps from `WKContentView`'s coordinate space to `WKWebView`.

* Source/WebKit/UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::requestTargetedElement):
* Source/WebKit/UIProcess/WebPageProxy.h:
* Source/WebKit/UIProcess/ios/PageClientImplIOS.h:
* Source/WebKit/UIProcess/ios/PageClientImplIOS.mm:
(WebKit::PageClientImpl::rootViewToWebView const):
* Source/WebKit/WebKit.xcodeproj/project.pbxproj:
* Source/WebKit/WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::requestTargetedElement):
* Source/WebKit/WebProcess/WebPage/WebPage.h:
* Source/WebKit/WebProcess/WebPage/WebPage.messages.in:

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



To unsubscribe from these emails, change your notification settings at https://github.com/WebKit/WebKit/settings/notifications


More information about the webkit-changes mailing list