Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 4bdaf7c934c05858d156f56ccd622a734986e9a5
      
https://github.com/WebKit/WebKit/commit/4bdaf7c934c05858d156f56ccd622a734986e9a5
  Author: Wenson Hsieh <[email protected]>
  Date:   2025-11-03 (Mon, 03 Nov 2025)

  Changed paths:
    M Source/WebCore/page/text-extraction/TextExtraction.cpp
    M Source/WebCore/page/text-extraction/TextExtractionTypes.h
    M Source/WebKit/Shared/TextExtractionToStringConversion.cpp
    M Source/WebKit/Shared/WebCoreArgumentCoders.serialization.in
    M Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm
    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 Tools/TestWebKitAPI/Tests/WebKitCocoa/TextExtractionTests.mm
    M Tools/TestWebKitAPI/cocoa/TestWKWebView.mm

  Log Message:
  -----------
  [AutoFill Debugging] Add a way for text extraction clients to include 
additional node attributes
https://bugs.webkit.org/show_bug.cgi?id=301895
rdar://163978127

Reviewed by Abrar Rahman Protyasha.

Add support for new method on the text extraction configuration:

> `-addClientAttribute:value:forNode:`

...which allows clients to append additional attributes for a given node 
(identified by JS handle).
These attributes are appended to the text extraction output as long as the 
given node is traversed
during the extraction process.

* Source/WebCore/page/text-extraction/TextExtraction.cpp:
(WebCore::TextExtraction::extractRecursive):
(WebCore::TextExtraction::nodeFromJSHandle):
(WebCore::TextExtraction::extractItem):
* Source/WebCore/page/text-extraction/TextExtractionTypes.h:
* Source/WebKit/Shared/TextExtractionToStringConversion.cpp:
(WebKit::sortedKeys):
(WebKit::partsForItem):
* Source/WebKit/Shared/WebCoreArgumentCoders.serialization.in:
* Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm:
(extractClientNodeAttributes):
(-[WKWebView _requestTextExtractionInternal:completion:]):
* Source/WebKit/UIProcess/API/Cocoa/_WKTextExtraction.h:
* Source/WebKit/UIProcess/API/Cocoa/_WKTextExtraction.mm:
(-[_WKTextExtractionConfiguration addClientAttribute:value:forNode:]):

Maintain nested hashmaps of `[attribute_name : [node_id : attribute_value]]`, 
which are then
converted into nested hashmaps of `[node : [attribute_name : attribute_value]]` 
in the web process
during traversal (for fast lookup per element).

(-[_WKTextExtractionConfiguration forEachClientNodeAttribute:]):
* Source/WebKit/UIProcess/API/Cocoa/_WKTextExtractionInternal.h:
* Tools/TestWebKitAPI/Tests/WebKitCocoa/TextExtractionTests.mm:
(TestWebKitAPI::TEST(TextExtractionTests, TargetNodeAndClientAttributes)):
(TestWebKitAPI::TEST(TextExtractionTests, TargetNode)): Deleted.
* Tools/TestWebKitAPI/cocoa/TestWKWebView.mm:
(-[WKWebView querySelector:frame:world:]):

Drive-by fix: use backticks (`) to wrap the query selector string, so that 
callers can use double or
single quotes without having to escape those characters.

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



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

Reply via email to