Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: b3af678a6b3af26aa1cd01bb4fd277ac9d4d8047
      
https://github.com/WebKit/WebKit/commit/b3af678a6b3af26aa1cd01bb4fd277ac9d4d8047
  Author: Wenson Hsieh <[email protected]>
  Date:   2026-07-22 (Wed, 22 Jul 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/WKWebViewInternal.h
    M 
Source/WebKit/UIProcess/Cocoa/TextExtraction/WKWebView+TextExtraction.swift
    M Source/WebKit/UIProcess/ios/WKContentViewInteraction.h
    M Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm

  Log Message:
  -----------
  [UIIntelligenceSupport] iOS: Mark elements that are being previewed by a 
context menu with `isContextMenuSource`
https://bugs.webkit.org/show_bug.cgi?id=320003
rdar://182923758

Reviewed by Abrar Rahman Protyasha.

On iOS, add plumbing to surface an image element or link that we're currently 
showing the context
menu for as the "context menu source", when creating 
`UIIntelligenceSupport.IntelligenceElement`.

To do this, we add a new optional `contextMenuTargetNodeIdentifier` node ID in 
the text extraction
request, which corresponds to the actively previewed element at the time of the 
extraction request;
we then use this to identify the context menu target node at extraction time, 
ensure that that
element's unique ID is propagated in text extraction results via 
`nodeIdentifier`, and finally set
`isContextMenuSource` only if an item's `nodeIdentifier` is equal to the active
`contextMenuTargetNodeIdentifier`, when assembling the final 
`IntelligenceElement` hierarchy.

* Source/WebCore/page/text-extraction/TextExtraction.cpp:
(WebCore::TextExtraction::extractRecursive):
(WebCore::TextExtraction::extractItem):
* Source/WebCore/page/text-extraction/TextExtractionTypes.h:
* Source/WebKit/Shared/WebCoreArgumentCoders.serialization.in:
* Source/WebKit/UIProcess/API/Cocoa/WKWebView+TextExtraction.mm:
(activeContextMenuTargetNodeIdentifier):
(-[WKWebView _activeContextMenuTargetNodeIdentifier]):
(-[WKWebView _requestTextExtractionInternal:completion:]):
* Source/WebKit/UIProcess/API/Cocoa/WKWebViewInternal.h:
* Source/WebKit/UIProcess/Cocoa/TextExtraction/WKWebView+TextExtraction.swift:
(createIntelligenceElement(_:contextMenuTargetNodeIdentifier:)):
(createIntelligenceElement(_:)): Deleted.
* Source/WebKit/UIProcess/ios/WKContentViewInteraction.h:
* Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm:
(-[WKContentView activeContextMenuElementContext]):

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



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

Reply via email to