Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 9ecfd550499977ec42beb807070ba9d50bef4537
      
https://github.com/WebKit/WebKit/commit/9ecfd550499977ec42beb807070ba9d50bef4537
  Author: Wenson Hsieh <[email protected]>
  Date:   2025-11-30 (Sun, 30 Nov 2025)

  Changed paths:
    M Source/WebCore/page/text-extraction/TextExtraction.cpp
    M Source/WebCore/page/text-extraction/TextExtraction.h
    M Source/WebCore/page/text-extraction/TextExtractionTypes.h
    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/WebPageProxy.cpp
    M Source/WebKit/UIProcess/WebPageProxy.h
    M Source/WebKit/WebProcess/WebPage/WebPage.cpp
    M Source/WebKit/WebProcess/WebPage/WebPage.h
    M Source/WebKit/WebProcess/WebPage/WebPage.messages.in

  Log Message:
  -----------
  [AutoFill Debugging] Add infrastructure for JavaScript-based text extraction 
filtering rules
https://bugs.webkit.org/show_bug.cgi?id=303277
rdar://165583914

Reviewed by Abrar Rahman Protyasha.

Add basic infrastructure to plumb and evaluate JavaScript-based text extraction 
filtering rules in a
separate, internal script world as a part of text extraction filtering. Note 
that there is no change
in behavior yet, since there's no logic to fetch the remotely updatable rule 
list yet.

* Source/WebCore/page/text-extraction/TextExtraction.cpp:
(WebCore::TextExtraction::extractRules):

Add a helper method to convert a list of `FilterRuleData` to `FilterRule`, by 
initializing the URL
regex (if specified).

(WebCore::TextExtraction::filteringWorld):

Set up an internal script world for evaluating text extraction filtering rules.

(WebCore::TextExtraction::applyRules):

Add a helper method that takes a list of text extraction rules, and applies the 
rules to the `input`
text, each of which consists of a JavaScript snippets to evaluate in the above 
internal script
world, as well as an optional regex to match against the URL of the given frame.

Each JavaScript snippet takes as arguments the original text, and the container 
node enclosing the
text; it asynchronously resolves to either a filtered version of the text, or 
`null` (indicating
that filtering is not necessary).

All snippets are evaluated in parallel, and (to err on the side of the most 
restrictive rule) the
shortest result is surfaced back through the final completion handler.

* Source/WebCore/page/text-extraction/TextExtraction.h:
* Source/WebCore/page/text-extraction/TextExtractionTypes.h:

Add a couple new structs, representing data used to initialize filtering rules, 
and the filtering
rules themselves.

* Source/WebKit/Shared/WebCoreArgumentCoders.serialization.in:
* Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView _extractDebugTextWithConfiguration:completionHandler:]):

If the below option flag is set, add another callback to the filtering pipeline 
that calls out to
the web process to evaluate the extracted text against filtering rules.

* Source/WebKit/UIProcess/API/Cocoa/_WKTextExtraction.h:

Add a new option, `_WKTextExtractionFilterRules`, which controls whether or not 
to enable rule-based
text filtering.

* Source/WebKit/UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::updateTextExtractionFilterRules):
(WebKit::WebPageProxy::applyTextExtractionFilter):
* Source/WebKit/UIProcess/WebPageProxy.h:

Add plumbing from the UI -> web process (see above).

* Source/WebKit/WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::updateTextExtractionFilterRules):
(WebKit::WebPage::applyTextExtractionFilter):
* Source/WebKit/WebProcess/WebPage/WebPage.h:
* Source/WebKit/WebProcess/WebPage/WebPage.messages.in:

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



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

Reply via email to