Title: [167698] trunk/Source/WebKit2
Revision
167698
Author
benja...@webkit.org
Date
2014-04-22 22:53:05 -0700 (Tue, 22 Apr 2014)

Log Message

[iOS][WK2] Split iOS touch event dispatch for the regular touch event dispatch
https://bugs.webkit.org/show_bug.cgi?id=132033

Patch by Benjamin Poulain <bpoul...@apple.com> on 2014-04-22
Reviewed by Simon Fraser.

The generic touch event dispatching does not work well with iOS gesture recognizers.
Some events are required to be synchronous, while other needs can be asynchronous and
can even use event coalescing. We only need UI callback for the synchronous events.

Previously, that was implemented by changing the property ShouldSendEventsSynchronously
on WebPageProxy. That is causing issues when synchronous events are sent right after asynchronous
events because the responses in WebPageProxy::didReceiveEvent() easily get out of order.

This patch completely split the UIGestureRecognizerDispatching from the normal asynchronous event dispatching.

Synchronous events are sent directly to the WebProcess and report the result to the PageClient right away.

Asynchronous events are sent to the EventDispatcher where they are coalesced until the main thread is free
to process events.

There can be a race where a synchronous event comes before the asynchronous events are processed. In that case,
the synchronous event handler starts by getting the events out of the EventDispatcher and dispatch them first.

* Shared/NativeWebTouchEvent.h:
(WebKit::NativeWebTouchEvent::uniqueId): Deleted.
* Shared/ios/NativeWebTouchEventIOS.mm:
(WebKit::NativeWebTouchEvent::NativeWebTouchEvent):
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::handleSynchronousTouchEvent):
(WebKit::WebPageProxy::sendAsynchronousTouchEvent):
(WebKit::WebPageProxy::didReceiveEvent):
(WebKit::WebPageProxy::resetStateAfterProcessExited):
* UIProcess/WebPageProxy.h:
* UIProcess/ios/WKContentViewInteraction.h:
* UIProcess/ios/WKContentViewInteraction.mm:
(-[WKContentView _webTouchEventsRecognized:]):
(-[WKContentView _webTouchEvent:WebKit::preventsNativeGestures:]):
* WebProcess/WebPage/EventDispatcher.cpp:
(WebKit::EventDispatcher::EventDispatcher):
(WebKit::EventDispatcher::clearQueuedTouchEventsForPage):
(WebKit::EventDispatcher::getQueuedTouchEventsForPage):
(WebKit::EventDispatcher::touchEvent):
(WebKit::EventDispatcher::dispatchTouchEvents):
* WebProcess/WebPage/EventDispatcher.h:
* WebProcess/WebPage/EventDispatcher.messages.in:
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::dispatchTouchEvent):
(WebKit::WebPage::touchEventSync):
(WebKit::WebPage::touchEvent):
(WebKit::WebPage::touchEventSyncForTesting):
(WebKit::WebPage::didCommitLoad):
* WebProcess/WebPage/WebPage.h:
* WebProcess/WebPage/WebPage.messages.in:
* WebProcess/WebPage/ios/WebPageIOS.mm:
(WebKit::WebPage::dispatchAsynchronousTouchEventsQueue):

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (167697 => 167698)


--- trunk/Source/WebKit2/ChangeLog	2014-04-23 05:28:20 UTC (rev 167697)
+++ trunk/Source/WebKit2/ChangeLog	2014-04-23 05:53:05 UTC (rev 167698)
@@ -1,3 +1,61 @@
+2014-04-22  Benjamin Poulain  <bpoul...@apple.com>
+
+        [iOS][WK2] Split iOS touch event dispatch for the regular touch event dispatch
+        https://bugs.webkit.org/show_bug.cgi?id=132033
+
+        Reviewed by Simon Fraser.
+
+        The generic touch event dispatching does not work well with iOS gesture recognizers.
+        Some events are required to be synchronous, while other needs can be asynchronous and
+        can even use event coalescing. We only need UI callback for the synchronous events.
+
+        Previously, that was implemented by changing the property ShouldSendEventsSynchronously
+        on WebPageProxy. That is causing issues when synchronous events are sent right after asynchronous
+        events because the responses in WebPageProxy::didReceiveEvent() easily get out of order.
+
+        This patch completely split the UIGestureRecognizerDispatching from the normal asynchronous event dispatching.
+
+        Synchronous events are sent directly to the WebProcess and report the result to the PageClient right away.
+
+        Asynchronous events are sent to the EventDispatcher where they are coalesced until the main thread is free
+        to process events.
+
+        There can be a race where a synchronous event comes before the asynchronous events are processed. In that case,
+        the synchronous event handler starts by getting the events out of the EventDispatcher and dispatch them first.
+
+        * Shared/NativeWebTouchEvent.h:
+        (WebKit::NativeWebTouchEvent::uniqueId): Deleted.
+        * Shared/ios/NativeWebTouchEventIOS.mm:
+        (WebKit::NativeWebTouchEvent::NativeWebTouchEvent):
+        * UIProcess/WebPageProxy.cpp:
+        (WebKit::WebPageProxy::handleSynchronousTouchEvent):
+        (WebKit::WebPageProxy::sendAsynchronousTouchEvent):
+        (WebKit::WebPageProxy::didReceiveEvent):
+        (WebKit::WebPageProxy::resetStateAfterProcessExited):
+        * UIProcess/WebPageProxy.h:
+        * UIProcess/ios/WKContentViewInteraction.h:
+        * UIProcess/ios/WKContentViewInteraction.mm:
+        (-[WKContentView _webTouchEventsRecognized:]):
+        (-[WKContentView _webTouchEvent:WebKit::preventsNativeGestures:]):
+        * WebProcess/WebPage/EventDispatcher.cpp:
+        (WebKit::EventDispatcher::EventDispatcher):
+        (WebKit::EventDispatcher::clearQueuedTouchEventsForPage):
+        (WebKit::EventDispatcher::getQueuedTouchEventsForPage):
+        (WebKit::EventDispatcher::touchEvent):
+        (WebKit::EventDispatcher::dispatchTouchEvents):
+        * WebProcess/WebPage/EventDispatcher.h:
+        * WebProcess/WebPage/EventDispatcher.messages.in:
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::dispatchTouchEvent):
+        (WebKit::WebPage::touchEventSync):
+        (WebKit::WebPage::touchEvent):
+        (WebKit::WebPage::touchEventSyncForTesting):
+        (WebKit::WebPage::didCommitLoad):
+        * WebProcess/WebPage/WebPage.h:
+        * WebProcess/WebPage/WebPage.messages.in:
+        * WebProcess/WebPage/ios/WebPageIOS.mm:
+        (WebKit::WebPage::dispatchAsynchronousTouchEventsQueue):
+
 2014-04-22  Chris Fleizach  <cfleiz...@apple.com>
 
         AX: iOS hit-testing does not work when page is zoomed

Modified: trunk/Source/WebKit2/Shared/NativeWebTouchEvent.h (167697 => 167698)


--- trunk/Source/WebKit2/Shared/NativeWebTouchEvent.h	2014-04-23 05:28:20 UTC (rev 167697)
+++ trunk/Source/WebKit2/Shared/NativeWebTouchEvent.h	2014-04-23 05:53:05 UTC (rev 167698)
@@ -48,7 +48,6 @@
 public:
 #if PLATFORM(IOS)
     explicit NativeWebTouchEvent(UIWebTouchEventsGestureRecognizer *);
-    unsigned uniqueId() const { return m_uniqueID; }
 #elif PLATFORM(GTK)
     NativeWebTouchEvent(const NativeWebTouchEvent&);
     NativeWebTouchEvent(GdkEvent*, WebCore::GtkTouchContextHelper&);
@@ -60,9 +59,7 @@
 #endif
 
 private:
-#if PLATFORM(IOS)
-    unsigned m_uniqueID;
-#elif PLATFORM(GTK)
+#if PLATFORM(GTK)
     GUniquePtr<GdkEvent> m_nativeEvent;
     const WebCore::GtkTouchContextHelper& m_touchContext;
 #elif PLATFORM(EFL)

Modified: trunk/Source/WebKit2/Shared/ios/NativeWebTouchEventIOS.mm (167697 => 167698)


--- trunk/Source/WebKit2/Shared/ios/NativeWebTouchEventIOS.mm	2014-04-23 05:28:20 UTC (rev 167697)
+++ trunk/Source/WebKit2/Shared/ios/NativeWebTouchEventIOS.mm	2014-04-23 05:53:05 UTC (rev 167698)
@@ -37,8 +37,6 @@
 
 namespace WebKit {
 
-static unsigned uniqueTouchEventIdIndex = 0;
-
 static inline WebEvent::Type webEventTypeForUIWebTouchEventType(UIWebTouchEventType type)
 {
     switch (type) {
@@ -99,7 +97,6 @@
 
 NativeWebTouchEvent::NativeWebTouchEvent(UIWebTouchEventsGestureRecognizer *gestureRecognizer)
     : WebTouchEvent(webEventTypeForUIWebTouchEventType(gestureRecognizer.type), static_cast<Modifiers>(0), WTF::currentTime(), extractWebTouchPoint(gestureRecognizer), positionForCGPoint(gestureRecognizer.locationInWindow), gestureRecognizer.inJavaScriptGesture, gestureRecognizer.scale, gestureRecognizer.rotation)
-    , m_uniqueID(uniqueTouchEventIdIndex++)
 {
 }
 

Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp (167697 => 167698)


--- trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp	2014-04-23 05:28:20 UTC (rev 167697)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp	2014-04-23 05:53:05 UTC (rev 167698)
@@ -1493,7 +1493,48 @@
 #endif // ENABLE(ASYNC_SCROLLING)
     return true;
 }
+#endif
 
+#if ENABLE(IOS_TOUCH_EVENTS)
+void WebPageProxy::handleTouchEventSynchronously(const NativeWebTouchEvent& event)
+{
+    if (!isValid())
+        return;
+
+    if (event.type() == WebEvent::TouchStart)
+        m_isTrackingTouchEvents = shouldStartTrackingTouchEvents(event);
+
+    if (!m_isTrackingTouchEvents)
+        return;
+
+    m_process->responsivenessTimer()->start();
+    bool handled = false;
+    m_process->sendSync(Messages::WebPage::TouchEventSync(event), Messages::WebPage::TouchEventSync::Reply(handled), m_pageID);
+    didReceiveEvent(event.type(), handled);
+    m_pageClient.doneWithTouchEvent(event, handled);
+    m_process->responsivenessTimer()->stop();
+
+    if (event.type() == WebEvent::TouchEnd || event.type() == WebEvent::TouchCancel)
+        m_isTrackingTouchEvents = false;
+}
+
+void WebPageProxy::handleTouchEventAsynchronously(const NativeWebTouchEvent& event)
+{
+    if (!isValid())
+        return;
+
+    ASSERT(event.type() != WebEvent::TouchStart);
+
+    if (!m_isTrackingTouchEvents)
+        return;
+
+    m_process->send(Messages::EventDispatcher::TouchEvent(m_pageID, event), 0);
+
+    if (event.type() == WebEvent::TouchEnd || event.type() == WebEvent::TouchCancel)
+        m_isTrackingTouchEvents = false;
+}
+
+#elif ENABLE(TOUCH_EVENTS)
 void WebPageProxy::handleTouchEvent(const NativeWebTouchEvent& event)
 {
     if (!isValid())
@@ -3797,10 +3838,16 @@
             m_uiClient->didNotHandleKeyEvent(this, event);
         break;
     }
-#if ENABLE(TOUCH_EVENTS)
+#if ENABLE(IOS_TOUCH_EVENTS)
     case WebEvent::TouchStart:
     case WebEvent::TouchMove:
     case WebEvent::TouchEnd:
+    case WebEvent::TouchCancel:
+        break;
+#elif ENABLE(TOUCH_EVENTS)
+    case WebEvent::TouchStart:
+    case WebEvent::TouchMove:
+    case WebEvent::TouchEnd:
     case WebEvent::TouchCancel: {
         MESSAGE_CHECK(!m_touchEventQueue.isEmpty());
         QueuedTouchEvents queuedEvents = m_touchEventQueue.takeFirst();
@@ -4153,7 +4200,7 @@
 
     m_processingMouseMoveEvent = false;
 
-#if ENABLE(TOUCH_EVENTS)
+#if ENABLE(TOUCH_EVENTS) && !ENABLE(IOS_TOUCH_EVENTS)
     m_touchEventQueue.clear();
 #endif
 

Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.h (167697 => 167698)


--- trunk/Source/WebKit2/UIProcess/WebPageProxy.h	2014-04-23 05:28:20 UTC (rev 167697)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.h	2014-04-23 05:53:05 UTC (rev 167698)
@@ -694,7 +694,10 @@
     void handleMouseEvent(const NativeWebMouseEvent&);
     void handleWheelEvent(const NativeWebWheelEvent&);
     void handleKeyboardEvent(const NativeWebKeyboardEvent&);
-#if ENABLE(TOUCH_EVENTS)
+#if ENABLE(IOS_TOUCH_EVENTS)
+    void handleTouchEventSynchronously(const NativeWebTouchEvent&);
+    void handleTouchEventAsynchronously(const NativeWebTouchEvent&);
+#elif ENABLE(TOUCH_EVENTS)
     void handleTouchEvent(const NativeWebTouchEvent&);
 #endif
 
@@ -1563,8 +1566,11 @@
 
 #if ENABLE(TOUCH_EVENTS)
     bool m_isTrackingTouchEvents;
+#endif
+#if ENABLE(TOUCH_EVENTS) && !ENABLE(IOS_TOUCH_EVENTS)
     Deque<QueuedTouchEvents> m_touchEventQueue;
 #endif
+
 #if ENABLE(INPUT_TYPE_COLOR)
     RefPtr<WebColorPicker> m_colorPicker;
 #endif

Modified: trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.h (167697 => 167698)


--- trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.h	2014-04-23 05:28:20 UTC (rev 167697)
+++ trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.h	2014-04-23 05:53:05 UTC (rev 167698)
@@ -80,7 +80,6 @@
     RetainPtr<UIWebTouchEventsGestureRecognizer> _touchEventGestureRecognizer;
 
     BOOL _canSendTouchEventsAsynchronously;
-    unsigned _nativeWebTouchEventUniqueIdBeingSentSynchronously;
 
     RetainPtr<UITapGestureRecognizer> _singleTapGestureRecognizer;
     RetainPtr<_UIWebHighlightLongPressGestureRecognizer> _highlightLongPressGestureRecognizer;

Modified: trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm (167697 => 167698)


--- trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm	2014-04-23 05:28:20 UTC (rev 167697)
+++ trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm	2014-04-23 05:53:05 UTC (rev 167698)
@@ -291,16 +291,13 @@
 - (void)_webTouchEventsRecognized:(UIWebTouchEventsGestureRecognizer *)gestureRecognizer
 {
     NativeWebTouchEvent nativeWebTouchEvent(gestureRecognizer);
-
     if (nativeWebTouchEvent.type() == WebKit::WebEvent::TouchStart)
         _canSendTouchEventsAsynchronously = NO;
 
-    if (!_canSendTouchEventsAsynchronously)
-        _nativeWebTouchEventUniqueIdBeingSentSynchronously = nativeWebTouchEvent.uniqueId();
-
-    _page->setShouldSendEventsSynchronously(!_canSendTouchEventsAsynchronously);
-    _page->handleTouchEvent(nativeWebTouchEvent);
-    _page->setShouldSendEventsSynchronously(false);
+    if (_canSendTouchEventsAsynchronously)
+        _page->handleTouchEventAsynchronously(nativeWebTouchEvent);
+    else
+        _page->handleTouchEventSynchronously(nativeWebTouchEvent);
 }
 
 static FloatQuad inflateQuad(const FloatQuad& quad, float inflateSize)
@@ -343,12 +340,6 @@
 - (void)_webTouchEvent:(const WebKit::NativeWebTouchEvent&)touchEvent preventsNativeGestures:(BOOL)preventsNativeGesture
 {
     if (preventsNativeGesture) {
-        // If we are dispatching events synchronously and the event coming back is not the one we are sending, it is a callback
-        // from an event sent asynchronously prior to the synchronous event. In that case, it should not use that information
-        // to update UIWebTouchEventsGestureRecognizer.
-        if (!_canSendTouchEventsAsynchronously && _nativeWebTouchEventUniqueIdBeingSentSynchronously != touchEvent.uniqueId())
-            return;
-
         _canSendTouchEventsAsynchronously = YES;
         [_touchEventGestureRecognizer setDefaultPrevented:YES];
     }

Modified: trunk/Source/WebKit2/WebProcess/WebPage/EventDispatcher.cpp (167697 => 167698)


--- trunk/Source/WebKit2/WebProcess/WebPage/EventDispatcher.cpp	2014-04-23 05:28:20 UTC (rev 167697)
+++ trunk/Source/WebKit2/WebProcess/WebPage/EventDispatcher.cpp	2014-04-23 05:53:05 UTC (rev 167698)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2011 Apple Inc. All rights reserved.
+ * Copyright (C) 2011, 2014 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -54,6 +54,9 @@
 EventDispatcher::EventDispatcher()
     : m_queue(WorkQueue::create("com.apple.WebKit.EventDispatcher"))
     , m_recentWheelEventDeltaTracker(adoptPtr(new WheelEventDeltaTracker))
+#if ENABLE(IOS_TOUCH_EVENTS)
+    , m_touchEventsLock(SPINLOCK_INITIALIZER)
+#endif
 {
 }
 
@@ -143,6 +146,61 @@
     RunLoop::main().dispatch(bind(&EventDispatcher::dispatchWheelEvent, this, pageID, wheelEvent));
 }
 
+#if ENABLE(IOS_TOUCH_EVENTS)
+void EventDispatcher::clearQueuedTouchEventsForPage(const WebPage& webPage)
+{
+    SpinLockHolder locker(&m_touchEventsLock);
+    m_touchEvents.remove(webPage.pageID());
+}
+
+void EventDispatcher::getQueuedTouchEventsForPage(const WebPage& webPage, TouchEventQueue& destinationQueue)
+{
+    SpinLockHolder locker(&m_touchEventsLock);
+    destinationQueue = std::move(m_touchEvents.take(webPage.pageID()));
+}
+
+void EventDispatcher::touchEvent(uint64_t pageID, const WebKit::WebTouchEvent& touchEvent)
+{
+    bool updateListWasEmpty;
+    {
+        SpinLockHolder locker(&m_touchEventsLock);
+        updateListWasEmpty = m_touchEvents.isEmpty();
+        auto addResult = m_touchEvents.add(pageID, std::move(TouchEventQueue()));
+        if (addResult.isNewEntry)
+            addResult.iterator->value.append(touchEvent);
+        else {
+            TouchEventQueue& queuedEvents = addResult.iterator->value;
+            ASSERT(!queuedEvents.isEmpty());
+            const WebTouchEvent& lastTouchEvent = queuedEvents.last();
+
+            // Coalesce touch move events.
+            WebEvent::Type type = lastTouchEvent.type();
+            if (type == WebEvent::TouchMove)
+                queuedEvents.last() = touchEvent;
+            else
+                queuedEvents.append(touchEvent);
+        }
+    }
+
+    if (updateListWasEmpty)
+        RunLoop::main().dispatch(bind(&EventDispatcher::dispatchTouchEvents, this));
+}
+
+void EventDispatcher::dispatchTouchEvents()
+{
+    HashMap<uint64_t, TouchEventQueue> localCopy;
+    {
+        SpinLockHolder locker(&m_touchEventsLock);
+        localCopy.swap(m_touchEvents);
+    }
+
+    for (auto& slot : localCopy) {
+        if (WebPage* webPage = WebProcess::shared().webPage(slot.key))
+            webPage->dispatchAsynchronousTouchEvents(slot.value);
+    }
+}
+#endif
+
 void EventDispatcher::dispatchWheelEvent(uint64_t pageID, const WebWheelEvent& wheelEvent)
 {
     ASSERT(RunLoop::isMain());

Modified: trunk/Source/WebKit2/WebProcess/WebPage/EventDispatcher.h (167697 => 167698)


--- trunk/Source/WebKit2/WebProcess/WebPage/EventDispatcher.h	2014-04-23 05:28:20 UTC (rev 167697)
+++ trunk/Source/WebKit2/WebProcess/WebPage/EventDispatcher.h	2014-04-23 05:53:05 UTC (rev 167698)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2011 Apple Inc. All rights reserved.
+ * Copyright (C) 2011, 2014 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -29,9 +29,11 @@
 #include "Connection.h"
 
 #include <WebCore/WheelEventDeltaTracker.h>
+#include <WebEvent.h>
 #include <wtf/HashMap.h>
 #include <wtf/Noncopyable.h>
 #include <wtf/RefPtr.h>
+#include <wtf/TCSpinLock.h>
 #include <wtf/ThreadingPrimitives.h>
 
 namespace WebCore {
@@ -54,6 +56,13 @@
     void removeScrollingTreeForPage(WebPage*);
 #endif
 
+#if ENABLE(IOS_TOUCH_EVENTS)
+    typedef Vector<WebTouchEvent, 1> TouchEventQueue;
+
+    void clearQueuedTouchEventsForPage(const WebPage&);
+    void getQueuedTouchEventsForPage(const WebPage&, TouchEventQueue&);
+#endif
+
     void initializeConnection(IPC::Connection*);
 
 private:
@@ -64,9 +73,16 @@
 
     // Message handlers
     void wheelEvent(uint64_t pageID, const WebWheelEvent&, bool canRubberBandAtLeft, bool canRubberBandAtRight, bool canRubberBandAtTop, bool canRubberBandAtBottom);
+#if ENABLE(IOS_TOUCH_EVENTS)
+    void touchEvent(uint64_t pageID, const WebTouchEvent&);
+#endif
 
+
     // This is called on the main thread.
     void dispatchWheelEvent(uint64_t pageID, const WebWheelEvent&);
+#if ENABLE(IOS_TOUCH_EVENTS)
+    void dispatchTouchEvents();
+#endif
 
 #if ENABLE(ASYNC_SCROLLING)
     void sendDidReceiveEvent(uint64_t pageID, const WebEvent&, bool didHandleEvent);
@@ -79,6 +95,10 @@
     HashMap<uint64_t, RefPtr<WebCore::ThreadedScrollingTree>> m_scrollingTrees;
 #endif
     OwnPtr<WebCore::WheelEventDeltaTracker> m_recentWheelEventDeltaTracker;
+#if ENABLE(IOS_TOUCH_EVENTS)
+    SpinLock m_touchEventsLock;
+    HashMap<uint64_t, TouchEventQueue> m_touchEvents;
+#endif
 };
 
 } // namespace WebKit

Modified: trunk/Source/WebKit2/WebProcess/WebPage/EventDispatcher.messages.in (167697 => 167698)


--- trunk/Source/WebKit2/WebProcess/WebPage/EventDispatcher.messages.in	2014-04-23 05:28:20 UTC (rev 167697)
+++ trunk/Source/WebKit2/WebProcess/WebPage/EventDispatcher.messages.in	2014-04-23 05:53:05 UTC (rev 167698)
@@ -22,4 +22,7 @@
 
 messages -> EventDispatcher {
     WheelEvent(uint64_t pageID, WebKit::WebWheelEvent event, bool canRubberBandAtLeft, bool canRubberBandAtRight, bool canRubberBandAtTop, bool canRubberBandAtBottom)
+#if ENABLE(IOS_TOUCH_EVENTS)
+    TouchEvent(uint64_t pageID, WebKit::WebTouchEvent event)
+#endif
 }

Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp (167697 => 167698)


--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp	2014-04-23 05:28:20 UTC (rev 167697)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp	2014-04-23 05:53:05 UTC (rev 167698)
@@ -1948,12 +1948,28 @@
 
     return page->mainFrame().eventHandler().handleTouchEvent(platform(touchEvent));
 }
+#endif
 
+#if ENABLE(IOS_TOUCH_EVENTS)
+void WebPage::dispatchTouchEvent(const WebTouchEvent& touchEvent, bool& handled)
+{
+    m_lastInteractionLocation = touchEvent.position();
+    CurrentEvent currentEvent(touchEvent);
+    handled = handleTouchEvent(touchEvent, m_page.get());
+}
+
+void WebPage::touchEventSync(const WebTouchEvent& touchEvent, bool& handled)
+{
+    EventDispatcher::TouchEventQueue queuedEvents;
+    WebProcess::shared().eventDispatcher().getQueuedTouchEventsForPage(*this, queuedEvents);
+    dispatchAsynchronousTouchEvents(queuedEvents);
+
+    dispatchTouchEvent(touchEvent, handled);
+}
+#elif ENABLE(TOUCH_EVENTS)
 void WebPage::touchEvent(const WebTouchEvent& touchEvent)
 {
-#if PLATFORM(IOS)
-    m_lastInteractionLocation = touchEvent.position();
-#endif
+
     bool handled = false;
     if (canHandleUserEvents()) {
         CurrentEvent currentEvent(touchEvent);
@@ -1965,9 +1981,6 @@
 
 void WebPage::touchEventSyncForTesting(const WebTouchEvent& touchEvent, bool& handled)
 {
-#if PLATFORM(IOS)
-    m_lastInteractionLocation = touchEvent.position();
-#endif
     CurrentEvent currentEvent(touchEvent);
     handled = handleTouchEvent(touchEvent, m_page.get());
 }
@@ -4239,6 +4252,8 @@
     m_hasReceivedVisibleContentRectsAfterDidCommitLoad = false;
     m_userHasChangedPageScaleFactor = false;
 
+    WebProcess::shared().eventDispatcher().clearQueuedTouchEventsForPage(*this);
+
     Document* document = frame->coreFrame()->document();
     if (document->isImageDocument())
         m_viewportConfiguration.setDefaultConfiguration(ViewportConfiguration::imageDocumentParameters());

Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h (167697 => 167698)


--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h	2014-04-23 05:28:20 UTC (rev 167697)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h	2014-04-23 05:53:05 UTC (rev 167698)
@@ -478,6 +478,7 @@
     void setAssistedNodeSelectedIndex(uint32_t index, bool allowMultipleSelection);
     WebCore::IntRect rectForElementAtInteractionLocation();
 
+    void dispatchAsynchronousTouchEvents(const Vector<WebTouchEvent, 1>& queue);
 #if ENABLE(INSPECTOR)
     void showInspectorIndication();
     void hideInspectorIndication();
@@ -705,6 +706,7 @@
     void applicationWillEnterForeground();
     void applicationDidBecomeActive();
     void zoomToRect(WebCore::FloatRect, double minimumScale, double maximumScale);
+    void dispatchTouchEvent(const WebTouchEvent&, bool& handled);
 #endif
 
 #if PLATFORM(GTK) && USE(TEXTURE_MAPPER_GL)
@@ -855,7 +857,9 @@
     void wheelEventSyncForTesting(const WebWheelEvent&, bool&);
     void keyEvent(const WebKeyboardEvent&);
     void keyEventSyncForTesting(const WebKeyboardEvent&, bool&);
-#if ENABLE(TOUCH_EVENTS)
+#if ENABLE(IOS_TOUCH_EVENTS)
+    void touchEventSync(const WebTouchEvent&, bool& handled);
+#elif ENABLE(TOUCH_EVENTS)
     void touchEvent(const WebTouchEvent&);
     void touchEventSyncForTesting(const WebTouchEvent&, bool& handled);
 #endif

Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in (167697 => 167698)


--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in	2014-04-23 05:28:20 UTC (rev 167697)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in	2014-04-23 05:53:05 UTC (rev 167698)
@@ -81,7 +81,10 @@
     SetAllowsRemoteInspection(bool allow)
 #endif
 
-#if ENABLE(TOUCH_EVENTS)
+#if ENABLE(IOS_TOUCH_EVENTS)
+    TouchEventSync(WebKit::WebTouchEvent event) -> (bool handled)
+#endif
+#if !ENABLE(IOS_TOUCH_EVENTS) && ENABLE(TOUCH_EVENTS)
     TouchEvent(WebKit::WebTouchEvent event)
     TouchEventSyncForTesting(WebKit::WebTouchEvent event) -> (bool handled)
 #endif

Modified: trunk/Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm (167697 => 167698)


--- trunk/Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm	2014-04-23 05:28:20 UTC (rev 167697)
+++ trunk/Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm	2014-04-23 05:53:05 UTC (rev 167698)
@@ -2059,6 +2059,13 @@
     send(Messages::WebPageProxy::ZoomToRect(rect, minimumScale, maximumScale));
 }
 
+void WebPage::dispatchAsynchronousTouchEvents(const Vector<WebTouchEvent, 1>& queue)
+{
+    bool ignored;
+    for (const WebTouchEvent& event : queue)
+        dispatchTouchEvent(event, ignored);
+}
+
 } // namespace WebKit
 
 #endif // PLATFORM(IOS)
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to