Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 192824c3316352ff5c7dce4c7852ef44c97e582b
https://github.com/WebKit/WebKit/commit/192824c3316352ff5c7dce4c7852ef44c97e582b
Author: Wenson Hsieh <[email protected]>
Date: 2026-01-07 (Wed, 07 Jan 2026)
Changed paths:
M Source/WebCore/page/text-extraction/TextExtraction.cpp
M Source/WebCore/page/text-extraction/TextExtraction.h
M Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm
M Source/WebKit/UIProcess/API/Cocoa/WKWebViewInternal.h
M Source/WebKit/UIProcess/API/Cocoa/_WKTextExtraction.h
M Source/WebKit/UIProcess/API/Cocoa/_WKTextExtraction.mm
M Source/WebKit/UIProcess/API/Cocoa/_WKTextExtractionInternal.h
M Source/WebKit/UIProcess/WebFrameProxy.cpp
M Source/WebKit/UIProcess/WebFrameProxy.h
M Source/WebKit/WebProcess/WebPage/WebFrame.cpp
M Source/WebKit/WebProcess/WebPage/WebFrame.h
M Source/WebKit/WebProcess/WebPage/WebFrame.messages.in
M Source/WebKit/WebProcess/WebPage/WebPage.cpp
M Tools/TestWebKitAPI/Tests/WebKitCocoa/TextExtractionTests.mm
Log Message:
-----------
[AutoFill Debugging] Add a way for clients to map node identifiers and/or
search text to _WKJSHandle
https://bugs.webkit.org/show_bug.cgi?id=305058
rdar://167703893
Reviewed by Tim Horton and Abrar Rahman Protyasha.
Add support for `-[_WKTextExtractionResult
requestJSHandleForNodeIdentifier:searchText:completionHandler:]`,
which asynchronously returns a JS handle pointing to the DOM element
represented by the node ID and
search text. See below for more details.
Test: TextExtractionTests.RequestJSHandleForNodeIdentifier
* Source/WebCore/page/text-extraction/TextExtraction.cpp:
(WebCore::TextExtraction::elementForExtractedText):
* Source/WebCore/page/text-extraction/TextExtraction.h:
* Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm:
(createEmptyTextExtractionResult):
Add a weak reference to `WKWebView` to `_WKTextExtractionResult`, so that the
result can call back
to its `WKWebView` to convert node ID / text to a JS handle.
(-[WKWebView
_extractDebugTextWithConfigurationWithoutUpdatingFilterRules:assertionScope:completionHandler:]):
(-[WKWebView _requestJSHandleForNodeIdentifier:searchText:completionHandler:]):
Add an internal helper method to handle the conversion by sending async IPC.
This currently only
supports main frame content, but we'll adjust this to message the appropriate
frame once node ID
strings support `subframe ID` + `nodeID` format.
* Source/WebKit/UIProcess/API/Cocoa/WKWebViewInternal.h:
* Source/WebKit/UIProcess/API/Cocoa/_WKTextExtraction.h:
* Source/WebKit/UIProcess/API/Cocoa/_WKTextExtraction.mm:
(-[_WKTextExtractionResult
initWithWebView:textContent:filteredOutAnyText:shortenedURLs:]):
(-[_WKTextExtractionResult
requestJSHandleForNodeIdentifier:searchText:completionHandler:]):
(-[_WKTextExtractionResult
initWithTextContent:filteredOutAnyText:shortenedURLs:]): Deleted.
* Source/WebKit/UIProcess/API/Cocoa/_WKTextExtractionInternal.h:
* Source/WebKit/UIProcess/WebFrameProxy.cpp:
(WebKit::WebFrameProxy::requestJSHandleForExtractedText):
* Source/WebKit/UIProcess/WebFrameProxy.h:
* Source/WebKit/WebProcess/WebPage/WebFrame.cpp:
(WebKit::WebFrame::createAndPrepareToSendJSHandle const):
Pull this logic to create a node `JSHandle` out into a common helper method, so
that we can use it
in `WebFrame` too.
(WebKit::WebFrame::requestJSHandleForExtractedText):
* Source/WebKit/WebProcess/WebPage/WebFrame.h:
* Source/WebKit/WebProcess/WebPage/WebFrame.messages.in:
* Source/WebKit/WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::hitTestAtPoint):
* Tools/TestWebKitAPI/Tests/WebKitCocoa/TextExtractionTests.mm:
(-[_WKTextExtractionResult jsHandleForNodeIdentifier:searchText:]):
(TestWebKitAPI::TEST(TextExtractionTests, RequestJSHandleForNodeIdentifier)):
Add an API test to exercise the change, by mapping node ID string to a
`_WKJSHandle`, and then
passing that handle to the `targetNode` property to re-extract text underneath
the subject heading.
Canonical link: https://commits.webkit.org/305247@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications