Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: d9fb21138389734dcd9e38f4729d55333ba13562
      
https://github.com/WebKit/WebKit/commit/d9fb21138389734dcd9e38f4729d55333ba13562
  Author: Wenson Hsieh <[email protected]>
  Date:   2026-02-27 (Fri, 27 Feb 2026)

  Changed paths:
    M 
LayoutTests/fast/text-extraction/debug-text-extraction-form-controls-expected.txt
    M Source/WebKit/Shared/TextExtractionToStringConversion.cpp
    M Source/WebKit/Shared/TextExtractionToStringConversion.h
    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

  Log Message:
  -----------
  [AutoFill Debugging] Add a way for clients to extract only plain text while 
maintaining DOM structure
https://bugs.webkit.org/show_bug.cgi?id=308832
rdar://171240021

Reviewed by Abrar Rahman Protyasha.

Make some adjustments to the `_WKTextExtraction` SPI surface; see below for 
more details.

Test: TextExtractionTests.MinimalHTMLOutput

* Source/WebKit/Shared/TextExtractionToStringConversion.cpp:
(WebKit::TextExtractionAggregator::addResult):
(WebKit::TextExtractionAggregator::includeRects const):
(WebKit::TextExtractionAggregator::includeURLs const):
(WebKit::TextExtractionAggregator::usePlainTextOutput const):
(WebKit::TextExtractionAggregator::addNativeMenuItemsIfNeeded):

Rename several helper methods, in light of the new plain text output type.

(WebKit::addPartsForItem):
(WebKit::addTextRepresentationRecursive):
(WebKit::TextExtractionAggregator::onlyIncludeText const): Deleted.
* Source/WebKit/Shared/TextExtractionToStringConversion.h:
* Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm:
(textExtractionOutputFormat):
(-[WKWebView 
_extractDebugTextWithConfigurationWithoutUpdatingFilterRules:assertionScope:completionHandler:]):
* Source/WebKit/UIProcess/API/Cocoa/_WKTextExtraction.h:

Deprecate `+configurationForVisibleTextOnly`, and replace it with a new enum 
value which represents
only plain text: `_WKTextExtractionOutputFormatPlainText`. Previously, making a 
new configuration
with `configurationForVisibleTextOnly` would yield a configuration that only 
supported _some_ of
the relevant configuration options. However, this is inconsistent with how the 
rest of the
extraction formatting options work, such as markdown — configuration flags that 
don't make sense for
the output format are simply ignored.

* Source/WebKit/UIProcess/API/Cocoa/_WKTextExtraction.mm:
(-[_WKTextExtractionConfiguration init]):
(+[_WKTextExtractionConfiguration configurationForVisibleTextOnly]):
(-[_WKTextExtractionConfiguration configureForMinimalOutput]):

Add a convenience method to reset all extraction configuration parameters back 
to values that ensure
minimal output text. For clients that need to ensure minimal output, but still 
might want to
preserve specific types of data, they can use `-configureForMinimalOutput` and 
then enable only what
they need.

In the future, we should consider making the default initialized 
`_WKTextExtractionConfiguration`
start at this minimal output, rather than defaulting to text tree (with various 
bits of information
included, such as bounding rects and URLs).

(-[_WKTextExtractionConfiguration setIncludeEventListeners:]):
(-[_WKTextExtractionConfiguration _initForOnlyVisibleText:]): Deleted.
(-[_WKTextExtractionConfiguration setIncludeURLs:]): Deleted.
(-[_WKTextExtractionConfiguration setIncludeRects:]): Deleted.
(-[_WKTextExtractionConfiguration setNodeIdentifierInclusion:]): Deleted.
(-[_WKTextExtractionConfiguration setEventListenerCategories:]): Deleted.
(-[_WKTextExtractionConfiguration setIncludeAccessibilityAttributes:]): Deleted.
(-[_WKTextExtractionConfiguration setIncludeTextInAutoFilledControls:]): 
Deleted.
(-[_WKTextExtractionConfiguration setOutputFormat:]): Deleted.
(-[_WKTextExtractionConfiguration setShortenURLs:]): Deleted.
* Source/WebKit/UIProcess/API/Cocoa/_WKTextExtractionInternal.h:
* Tools/TestWebKitAPI/Tests/WebKitCocoa/TextExtractionTests.mm:
(TestWebKitAPI::TEST(TextExtractionTests, VisibleTextOnly)):
(TestWebKitAPI::TEST(TextExtractionTests, MinimalHTMLOutput)):

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



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

Reply via email to