Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: a2bbea07fac66029451ba7bbcdf75419439b2282
      
https://github.com/WebKit/WebKit/commit/a2bbea07fac66029451ba7bbcdf75419439b2282
  Author: Ryosuke Niwa <[email protected]>
  Date:   2026-09-23 (Wed, 23 Sep 2026)

  Changed paths:
    A 
LayoutTests/http/tests/site-isolation/touch-events/resources/post-message-click-screen-coordinates.html
    A 
LayoutTests/http/tests/site-isolation/touch-events/tap-screen-coordinates-in-cross-origin-iframe-expected.txt
    A 
LayoutTests/http/tests/site-isolation/touch-events/tap-screen-coordinates-in-cross-origin-iframe.html
    M LayoutTests/platform/ios/TestExpectations
    M Source/WebKit/WebProcess/WebPage/Cocoa/WebPageCocoa.mm

  Log Message:
  -----------
  [Site Isolation] Mouse events dispatched from touch have incorrect screen 
coordinates on iOS
https://bugs.webkit.org/show_bug.cgi?id=324900
rdar://173883202

Reviewed by Sihui Liu and Abrar Rahman Protyasha.

On iOS a mouse event's globalPosition -- what becomes screenX/screenY -- is a 
point in the
top-level page's root view rather than device screen space: 
globalPointForEvent() in
PlatformEventFactoryIOS.mm returns the view point unchanged because iOS WebKit 
works as if it is
full screen. The synthetic click a tap produces is dispatched inside the 
process owning the tapped
frame, from a location already converted to that frame's root view, and passed 
that same point as
both position and globalPosition. With site isolation that frame can be a 
cross-origin iframe, so
a tap inside one reported screenX/screenY relative to the iframe while a tap on 
the main frame
reported page coordinates.

Add globalPositionForSyntheticMouseEvent(), which maps the local root view 
point up to the main
frame's root view with FrameView::convertToRootViewAcrossIsolatedFrames(), and 
use it for the
globalPosition argument of the synthetic mouse events a tap dispatches. 
position is untouched, so
clientX/pageX behavior is unchanged. convertToRootViewAcrossIsolatedFrames() 
walks the ancestor
chain through the parent RemoteFrameView and applies each frame's transform and 
scroll, so unlike
WebPage::remoteFrameOffsetInMainFrame() -- a plain translation that does not 
yet account for
scrolling of intermediate ancestor frames -- it stays correct for nested and 
transformed iframes.
It returns the point unchanged when there is no remote ancestor, leaving the 
main frame's process
unaffected.

handleDoubleTapForDoubleClickAtPoint() and 
dispatchSyntheticMouseEventsForSelectionGesture() pass
the local point twice as well, but both return early unless 
Page::localMainFrame() exists, so they
never run in a cross-origin iframe process and the offset there is always zero.

Pointer events from touch (PointerEventIOS.cpp) and drag 
(tryToBeginDragAtPoint() in
EventHandlerIOS.mm) still use iframe-relative screen coordinates. They will be 
fixed in a follow up.

Test: 
http/tests/site-isolation/touch-events/tap-screen-coordinates-in-cross-origin-iframe.html

* 
LayoutTests/http/tests/site-isolation/touch-events/resources/post-message-click-screen-coordinates.html:
 Added.
* 
LayoutTests/http/tests/site-isolation/touch-events/tap-screen-coordinates-in-cross-origin-iframe-expected.txt:
 Added.
* 
LayoutTests/http/tests/site-isolation/touch-events/tap-screen-coordinates-in-cross-origin-iframe.html:
 Added.
* LayoutTests/platform/ios/TestExpectations:
* Source/WebKit/WebProcess/WebPage/Cocoa/WebPageCocoa.mm:
(WebKit::globalPositionForSyntheticMouseEvent):
(WebKit::dispatchSyntheticMouseMove):
(WebKit::WebPage::completeSyntheticClick):

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



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

Reply via email to