Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 015f01aa94e28b9a5456a1ac192a877fbcad5f46
      
https://github.com/WebKit/WebKit/commit/015f01aa94e28b9a5456a1ac192a877fbcad5f46
  Author: Ruthvik Konda <[email protected]>
  Date:   2026-10-14 (Wed, 14 Oct 2026)

  Changed paths:
    M Source/WebKit/WebProcess/Plugins/PDF/PDFPluginBase.h
    M 
Source/WebKit/WebProcess/Plugins/PDF/UnifiedPDF/PDFDataDetectorOverlayController.mm
    M Source/WebKit/WebProcess/Plugins/PDF/UnifiedPDF/UnifiedPDFPlugin.h
    M Source/WebKit/WebProcess/Plugins/PDF/UnifiedPDF/UnifiedPDFPlugin.mm
    M Tools/TestWebKitAPI/Helpers/cocoa/SiteIsolationTestUtilities.h
    A Tools/TestWebKitAPI/Helpers/mac/DataDetectorHighlightTestUtilities.h
    A Tools/TestWebKitAPI/Helpers/mac/DataDetectorHighlightTestUtilities.mm
    M Tools/TestWebKitAPI/SourcesCocoa.txt
    M Tools/TestWebKitAPI/Tests/WebKit/WKWebView/UnifiedPDFTests.mm

  Log Message:
  -----------
  [Site Isolation] Data detector highlights and menus do not work on cross 
origin iframe src=pdf
https://bugs.webkit.org/show_bug.cgi?id=326759
rdar://188242058

Reviewed by Alex Christensen.

Hovering a phone number in a PDF in a cross-origin iframe showed no data 
detector highlight, and
clicking where the highlight's button should be did nothing.

Under site isolation, the iframe is the root frame of its own web process, and 
the main frame there
is a RemoteFrame. PDFDataDetectorOverlayController did its geometry in the main 
frame's view, and its
page overlay was installed without an associated frame:

- PageOverlayController hosts an overlay without an associated frame only under 
the local main
  frame's root, so in the iframe's process the highlight was never in a layer 
tree.
- The main frame's view there is a RemoteFrameView with an empty visible rect, 
so DataDetectors put
  the highlight's button outside the iframe, and clicks on the button missed it.
- The element bounds and click location sent to the UI process were relative to 
the iframe.

Associate the overlay with the plugin's root frame, so that this frame's layer 
tree hosts it, like
the Web Inspector's frame overlays. Do the highlight and hit testing geometry 
in the plugin's root
view, the top of its widget tree, which is the root frame's view. Convert the 
element bounds and the
click location sent to the UI process with 
convertFromRootViewToMainFrameView(), like the plugin's
other geometry sent there (322581@main).

Without site isolation, or for a PDF in the main frame's process, the root 
frame is the main frame
and the root view is its view, so the same frame and view are used as before. 
The selection rect is
now rounded once in the root view instead of in the PDF frame's contents, which 
can move it by a
pixel for a PDF in a subframe at a fractional offset or on a magnified page.

Under site isolation, the highlight is now part of the iframe's layer tree, so 
it is clipped at the
iframe's edges, and its button picks a side using the iframe's visible rect.

Move SiteIsolationParams from UnifiedPDFTests.mm to 
SiteIsolationTestUtilities.h, and the data
detector highlight geometry, visible layer and hover helpers to new
DataDetectorHighlightTestUtilities.h and DataDetectorHighlightTestUtilities.mm 
files, so that the
data detector tests for subframes in DataDetection.mm can share them.

Test: Tools/TestWebKitAPI/Tests/WebKit/WKWebView/UnifiedPDFTests.mm

* Source/WebKit/WebProcess/Plugins/PDF/PDFPluginBase.h:
Make rootView() public.
* 
Source/WebKit/WebProcess/Plugins/PDF/UnifiedPDF/PDFDataDetectorOverlayController.mm:
(WebKit::PDFDataDetectorOverlayController::createPlatformDataDetectorHighlight 
const):
(WebKit::PDFDataDetectorOverlayController::handleMouseEvent):
(WebKit::PDFDataDetectorOverlayController::handleDataDetectorAction):
* Source/WebKit/WebProcess/Plugins/PDF/UnifiedPDF/UnifiedPDFPlugin.h:
Name the click point's coordinate space, and declare 
rectForSelectionInRootViewContentsSpace().
* Source/WebKit/WebProcess/Plugins/PDF/UnifiedPDF/UnifiedPDFPlugin.mm:
(WebKit::UnifiedPDFPlugin::handleClickForDataDetectionResult):
(WebKit::UnifiedPDFPlugin::installDataDetectorOverlay):
(WebKit::UnifiedPDFPlugin::rectForSelectionInRootViewContentsSpace const):
* Tools/TestWebKitAPI/Helpers/cocoa/SiteIsolationTestUtilities.h:
Move SiteIsolationParams here so that the data detector tests for subframes can 
share it, and give
its members default values.
(TestWebKitAPI::SiteIsolationParams::isCrossOriginWithSiteIsolation const):
(TestWebKitAPI::SiteIsolationParams::subframeURL const):
(TestWebKitAPI::SiteIsolationParams::applyTo const):
(TestWebKitAPI::SiteIsolationParams::testName const):
* Tools/TestWebKitAPI/Helpers/mac/DataDetectorHighlightTestUtilities.h: Added.
* Tools/TestWebKitAPI/Helpers/mac/DataDetectorHighlightTestUtilities.mm: Added.
(TestWebKitAPI::dataDetectorHighlightGeometry):
(TestWebKitAPI::rectsAreNear):
(TestWebKitAPI::visibleLayersAndFrames):
(TestWebKitAPI::visibleLayerNear):
(TestWebKitAPI::hasVisibleLayerNear):
(TestWebKitAPI::hoverUntilHighlightIsShown):
* Tools/TestWebKitAPI/SourcesCocoa.txt:
* Tools/TestWebKitAPI/Tests/WebKit/WKWebView/UnifiedPDFTests.mm:
(TestWebKitAPI::TEST_P):
(TestWebKitAPI::pdfWithPhoneNumber):
(TestWebKitAPI::EmbeddedPDFDataDetection::loadAndFindPhoneNumber):
(TestWebKitAPI::EmbeddedPDFDataDetection::moveMouse):
(TestWebKitAPI::EmbeddedPDFDataDetection::rootViewVisibleRect):
(TestWebKitAPI::EmbeddedPDFDataDetection::clickButton):
(TestWebKitAPI::EmbeddedPDFDataDetection::showHighlightAndMenu):
(TestWebKitAPI::EmbeddedPDFDataDetection::testNameGenerator):
(TestWebKitAPI::EmbeddedPDFHUDSiteIsolation::mainHTML const):
(TestWebKitAPI::SiteIsolationParams::pdfURL const): Deleted.
(TestWebKitAPI::SiteIsolationParams::applyTo const): Deleted.
(TestWebKitAPI::SiteIsolationParams::testName const): Deleted.

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



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

Reply via email to