Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: c643bce4539bffffa90d6dec05b4053ecdbf132e
      
https://github.com/WebKit/WebKit/commit/c643bce4539bffffa90d6dec05b4053ecdbf132e
  Author: Timothy Hatcher <[email protected]>
  Date:   2026-10-09 (Fri, 09 Oct 2026)

  Changed paths:
    M Source/WebCore/page/text-extraction/TextExtraction.cpp
    M Source/WebCore/page/text-extraction/TextExtractionTypes.h
    M Source/WebKit/Shared/WebCoreArgumentCoders.serialization.in
    M Source/WebKit/UIProcess/API/Cocoa/WKWebView+TextExtraction.mm
    M Source/WebKit/UIProcess/API/Cocoa/_WKTextExtraction.h
    M Source/WebKit/UIProcess/API/Cocoa/_WKTextExtraction.mm
    M Tools/TestWebKitAPI/Tests/WebKit/WKWebView/TextExtractionTests.swift

  Log Message:
  -----------
  [Text Extraction] Add an option to exclude same-origin subframes from 
_WKTextExtractionConfiguration.
https://webkit.org/b/326837
rdar://problem/189536237

Reviewed by Wenson Hsieh.

Text extraction always inlines the content of same-origin subframes into the 
result for their
parent frame, so a client can't limit extraction to one frame's own document.

Add includeSameOriginSubframes to _WKTextExtractionConfiguration, defaulting to 
YES so existing
clients are unchanged. When it's NO, same-origin subframes are left out unless 
they're listed in
additionalFrames, which no longer skips them as already included.

Extracting a same-origin subframe in its own request also exposed a target node 
bug.
jsHandleIdentifierInFrame matches by process, and a same-origin subframe shares 
the main frame's
process, so the subframe request was given the main frame's target node and 
extracted that subtree
instead. A frame other than the main frame now only gets the target node when 
the node belongs to
that frame.

Tests: Tools/TestWebKitAPI/Tests/WebKit/WKWebView/TextExtractionTests.swift

* Source/WebCore/page/text-extraction/TextExtraction.cpp:
(WebCore::TextExtraction::extractRecursive): Only inline a same-origin iframe's 
content when the
request asks for it.
* Source/WebCore/page/text-extraction/TextExtractionTypes.h:
* Source/WebKit/Shared/WebCoreArgumentCoders.serialization.in:
* Source/WebKit/UIProcess/API/Cocoa/WKWebView+TextExtraction.mm:
(-[WKWebView _requestTextExtractionInternal:completion:]): Pass the option 
through, give a frame
the target node only when the node belongs to it, and stop skipping same-origin 
frames in
additionalFrames when the option is off.
* Source/WebKit/UIProcess/API/Cocoa/_WKTextExtraction.h:
* Source/WebKit/UIProcess/API/Cocoa/_WKTextExtraction.mm:
(-[_WKTextExtractionConfiguration init]): Default includeSameOriginSubframes to 
YES.
* Tools/TestWebKitAPI/Tests/WebKit/WKWebView/TextExtractionTests.swift:
(TextExtractionTests.excludingSameOriginSubframesLeavesOutTheirContent): Added.
(TextExtractionTests.sameOriginSubframeInAdditionalFramesIsExtractedWhenNotIncludedByDefault):
 Added.
(TextExtractionTests.excludingSameOriginSubframesStillExtractsListedCrossOriginSubframes):
 Added.
(TextExtractionTests.sameOriginSubframesAreInlinedByDefaultAlongsideCrossOriginSubframes):
 Added.
(TextExtractionTests.listingSameOriginSubframeExtractsItOnceWhenSameOriginSubframesAreExcluded):
 Added.

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



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

Reply via email to