Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 355bf0478f6ed4d5f7bbb0543140776b8af74dea
      
https://github.com/WebKit/WebKit/commit/355bf0478f6ed4d5f7bbb0543140776b8af74dea
  Author: Charlie Wolfe <[email protected]>
  Date:   2023-11-19 (Sun, 19 Nov 2023)

  Changed paths:
    M LayoutTests/TestExpectations
    A 
LayoutTests/http/tests/site-isolation/touch-events/resources/post-message-coordinates.html
    A 
LayoutTests/http/tests/site-isolation/touch-events/touch-event-coordinates-expected.txt
    A 
LayoutTests/http/tests/site-isolation/touch-events/touch-event-coordinates.html
    M Source/WebCore/page/EventHandler.cpp
    M Source/WebCore/page/EventHandler.h
    M Source/WebCore/page/ios/EventHandlerIOS.mm
    M Source/WebKit/Shared/WebTouchEvent.h
    M Source/WebKit/UIProcess/WebPageProxy.cpp
    M Source/WebKit/UIProcess/WebPageProxy.h
    M Source/WebKit/WebProcess/WebPage/EventDispatcher.cpp
    M Source/WebKit/WebProcess/WebPage/EventDispatcher.h
    M Source/WebKit/WebProcess/WebPage/EventDispatcher.messages.in
    M Source/WebKit/WebProcess/WebPage/WebPage.cpp
    M Source/WebKit/WebProcess/WebPage/WebPage.h
    M Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm

  Log Message:
  -----------
  [Site Isolation][iOS] Send touch events to isolated frames
https://bugs.webkit.org/show_bug.cgi?id=264998
rdar://116837559

Reviewed by Alex Christensen.

This patch makes changes to send touch events to isolated frames with corrected 
coordinates.

Similar to mouse and drag events, IPC will be sent between the UI process and 
web processes until the
target frame is reached. More details below.

* Source/WebCore/page/EventHandler.cpp:
(WebCore::EventHandler::userInputEventDataForRemoteFrame):
(WebCore::EventHandler::handleMousePressEvent):
(WebCore::EventHandler::handleMouseMoveEvent):
(WebCore::EventHandler::handleMouseReleaseEvent):
(WebCore::EventHandler::handleTouchEvent):
(WebCore::EventHandler::dispatchSyntheticTouchEventIfEnabled):
(WebCore::EventHandler::mouseEventDataForRemoteFrame): Deleted.
* Source/WebCore/page/EventHandler.h:
(WebCore::EventHandler::touchEventTargetSubframe const):

I renamed `mouseEventDataForRemoteFrame()` to 
`userInputEventDataForRemoteFrame()` since this function
won’t only be used for mouse events.

* Source/WebCore/page/ios/EventHandlerIOS.mm:
(WebCore::EventHandler::dispatchSimulatedTouchEvent):
(WebCore::EventHandler::touchEvent):

* Source/WebKit/Shared/WebTouchEvent.h:
(WebKit::WebTouchEvent::setPosition):

We need `setPosition()` to correct the coordinates of the touch event before 
forwarding it to the iframe
process.

* Source/WebKit/UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::sendPreventableTouchEvent):
(WebKit::WebPageProxy::handlePreventableTouchEvent):
(WebKit::WebPageProxy::sendUnpreventableTouchEvent):
(WebKit::WebPageProxy::handleUnpreventableTouchEvent):
* Source/WebKit/UIProcess/WebPageProxy.h:

I added `sendPreventableTouchEvent()` and `sendUnpreventableTouchEvent()` so we 
can specify a frame to
send the touch event to. If the touch event needs to be forwarded to an iframe 
process the event
coordinates will be corrected and we’ll send another IPC call to the target 
frame.

* Source/WebKit/WebProcess/WebPage/EventDispatcher.cpp:
(WebKit::EventDispatcher::touchEvent):
(WebKit::EventDispatcher::touchEventWithoutCallback): Deleted.
* Source/WebKit/WebProcess/WebPage/EventDispatcher.h:
* Source/WebKit/WebProcess/WebPage/EventDispatcher.messages.in:

We now need a completion handler even if the touch event is unpreventable, so I 
removed
`touchEventWithoutCallback()` and made both preventable and unpreventable touch 
events call directly
into `touchEvent()`. If the touch event is unpreventable the `handled` bool 
passed back through the
completion handler will be ignored. I also needed to store the completion 
handler for unpreventable
touch events in the touch event queue.

I added a frame identifier to be associated with each queued touch event. Also 
store these values in a
new struct.

* Source/WebKit/WebProcess/WebPage/WebPage.cpp:
(WebKit::handleTouchEvent):
(WebKit::WebPage::dispatchTouchEvent):
(WebKit::WebPage::touchEvent):
(WebKit::WebPage::updatePotentialTapSecurityOrigin):
* Source/WebKit/WebProcess/WebPage/WebPage.h:

Change these functions to expect a frame identifier to be passed, and use the 
event handler associated
with that frame to handle touch events.

* Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm:
(WebKit::WebPage::dispatchAsynchronousTouchEvents):
(WebKit::WebPage::cancelAsynchronousTouchEvents):

* LayoutTests/TestExpectations:
* 
LayoutTests/http/tests/site-isolation/touch-events/resources/post-message-coordinates.html:
 Added.
* 
LayoutTests/http/tests/site-isolation/touch-events/touch-event-coordinates-expected.txt:
 Added.
* 
LayoutTests/http/tests/site-isolation/touch-events/touch-event-coordinates.html:
 Added.

This test verifies the isolated iframe receives the touch events with the 
expected coordinates. Also
make sure touch event listeners on the main frame are not called.

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


_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to