Title: [102963] trunk/Source
Revision
102963
Author
[email protected]
Date
2011-12-15 10:56:16 -0800 (Thu, 15 Dec 2011)

Log Message

EventDispatcher should handle wheel events on the connection queue
https://bugs.webkit.org/show_bug.cgi?id=74627

Reviewed by Andreas Kling.

Source/_javascript_Core:

Add a BoundFunctionImpl specialization that takes three parameters.

* wtf/Functional.h:
(WTF::C::):
(WTF::R):
(WTF::bind):

Source/WebKit2:

Send wheel events to the EventDispatcher, which handles them on the connection work queue, and
immediately bounces them to the main thread (for now).

* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::handleWheelEvent):
(WebKit::WebPageProxy::didReceiveEvent):
* WebProcess/WebPage/EventDispatcher.cpp:
(WebKit::EventDispatcher::wheelEvent):
(WebKit::EventDispatcher::dispatchWheelEvent):
* WebProcess/WebPage/EventDispatcher.h:
* WebProcess/WebPage/EventDispatcher.messages.in:
* WebProcess/WebPage/WebPage.h:

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (102962 => 102963)


--- trunk/Source/_javascript_Core/ChangeLog	2011-12-15 18:50:59 UTC (rev 102962)
+++ trunk/Source/_javascript_Core/ChangeLog	2011-12-15 18:56:16 UTC (rev 102963)
@@ -1,3 +1,17 @@
+2011-12-15  Anders Carlsson  <[email protected]>
+
+        EventDispatcher should handle wheel events on the connection queue
+        https://bugs.webkit.org/show_bug.cgi?id=74627
+
+        Reviewed by Andreas Kling.
+
+        Add a BoundFunctionImpl specialization that takes three parameters.
+
+        * wtf/Functional.h:
+        (WTF::C::):
+        (WTF::R):
+        (WTF::bind):
+
 2011-12-14  Anders Carlsson  <[email protected]>
 
         Add WTF::Function to wtf/Forward.h

Modified: trunk/Source/_javascript_Core/wtf/Functional.h (102962 => 102963)


--- trunk/Source/_javascript_Core/wtf/Functional.h	2011-12-15 18:50:59 UTC (rev 102962)
+++ trunk/Source/_javascript_Core/wtf/Functional.h	2011-12-15 18:56:16 UTC (rev 102963)
@@ -157,6 +157,25 @@
     R (C::*m_function)(P0);
 };
 
+template<typename R, typename C, typename P0, typename P1> class FunctionWrapper<R (C::*)(P0, P1)> {
+public:
+    typedef R ResultType;
+    static const bool shouldRefFirstParameter = HasRefAndDeref<C>::value;
+
+    explicit FunctionWrapper(R (C::*function)(P0, P1))
+        : m_function(function)
+    {
+    }
+
+    R operator()(C* c, P0 p0, P1 p1)
+    {
+        return (c->*m_function)(p0, p1);
+    }
+
+private:
+    R (C::*m_function)(P0, P1);
+};
+
 template<typename T, bool shouldRefAndDeref> struct RefAndDeref {
     static void ref(T) { }
     static void deref(T) { }
@@ -251,6 +270,34 @@
     P1 m_p1;
 };
 
+template<typename FunctionWrapper, typename R, typename P0, typename P1, typename P2> class BoundFunctionImpl<FunctionWrapper, R (P0, P1, P2)> : public FunctionImpl<typename FunctionWrapper::ResultType ()> {
+public:
+    BoundFunctionImpl(FunctionWrapper functionWrapper, const P0& p0, const P1& p1, const P2& p2)
+        : m_functionWrapper(functionWrapper)
+        , m_p0(p0)
+        , m_p1(p1)
+        , m_p2(p2)
+    {
+        RefAndDeref<P0, FunctionWrapper::shouldRefFirstParameter>::ref(m_p0);
+    }
+    
+    ~BoundFunctionImpl()
+    {
+        RefAndDeref<P0, FunctionWrapper::shouldRefFirstParameter>::deref(m_p0);
+    }
+
+    virtual typename FunctionWrapper::ResultType operator()()
+    {
+        return m_functionWrapper(m_p0, m_p1, m_p2);
+    }
+
+private:
+    FunctionWrapper m_functionWrapper;
+    P0 m_p0;
+    P1 m_p1;
+    P2 m_p2;
+};
+
 class FunctionBase {
 public:
     bool isNull() const
@@ -317,8 +364,14 @@
     return Function<typename FunctionWrapper<FunctionType>::ResultType ()>(adoptRef(new BoundFunctionImpl<FunctionWrapper<FunctionType>, typename FunctionWrapper<FunctionType>::ResultType (A1, A2)>(FunctionWrapper<FunctionType>(function), a1, a2)));
 }
 
+template<typename FunctionType, typename A1, typename A2, typename A3>
+Function<typename FunctionWrapper<FunctionType>::ResultType ()> bind(FunctionType function, const A1& a1, const A2& a2, const A3& a3)
+{
+    return Function<typename FunctionWrapper<FunctionType>::ResultType ()>(adoptRef(new BoundFunctionImpl<FunctionWrapper<FunctionType>, typename FunctionWrapper<FunctionType>::ResultType (A1, A2, A3)>(FunctionWrapper<FunctionType>(function), a1, a2, a3)));
 }
 
+}
+
 using WTF::Function;
 using WTF::bind;
 

Modified: trunk/Source/WebKit2/ChangeLog (102962 => 102963)


--- trunk/Source/WebKit2/ChangeLog	2011-12-15 18:50:59 UTC (rev 102962)
+++ trunk/Source/WebKit2/ChangeLog	2011-12-15 18:56:16 UTC (rev 102963)
@@ -1,3 +1,23 @@
+2011-12-15  Anders Carlsson  <[email protected]>
+
+        EventDispatcher should handle wheel events on the connection queue
+        https://bugs.webkit.org/show_bug.cgi?id=74627
+
+        Reviewed by Andreas Kling.
+
+        Send wheel events to the EventDispatcher, which handles them on the connection work queue, and
+        immediately bounces them to the main thread (for now).
+
+        * UIProcess/WebPageProxy.cpp:
+        (WebKit::WebPageProxy::handleWheelEvent):
+        (WebKit::WebPageProxy::didReceiveEvent):
+        * WebProcess/WebPage/EventDispatcher.cpp:
+        (WebKit::EventDispatcher::wheelEvent):
+        (WebKit::EventDispatcher::dispatchWheelEvent):
+        * WebProcess/WebPage/EventDispatcher.h:
+        * WebProcess/WebPage/EventDispatcher.messages.in:
+        * WebProcess/WebPage/WebPage.h:
+
 2011-12-15  Jon Lee  <[email protected]>
 
         [WK2] Extend WebNotification to include its origin

Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp (102962 => 102963)


--- trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp	2011-12-15 18:50:59 UTC (rev 102962)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp	2011-12-15 18:56:16 UTC (rev 102963)
@@ -31,6 +31,7 @@
 #include "DataReference.h"
 #include "DownloadProxy.h"
 #include "DrawingAreaProxy.h"
+#include "EventDispatcherMessages.h"
 #include "FindIndicator.h"
 #include "Logging.h"
 #include "MessageID.h"
@@ -939,7 +940,7 @@
         process()->sendSync(Messages::WebPage::WheelEventSyncForTesting(event), Messages::WebPage::WheelEventSyncForTesting::Reply(handled), m_pageID);
         didReceiveEvent(event.type(), handled);
     } else
-        process()->send(Messages::WebPage::WheelEvent(event), m_pageID);
+        process()->send(Messages::EventDispatcher::WheelEvent(m_pageID, event), 0);
 }
 
 void WebPageProxy::handleKeyboardEvent(const NativeWebKeyboardEvent& event)
@@ -2929,7 +2930,7 @@
             WebWheelEvent newWheelEvent = coalescedWheelEvent(m_wheelEventQueue, m_currentlyProcessedWheelEvents);
 
             process()->responsivenessTimer()->start();
-            process()->send(Messages::WebPage::WheelEvent(newWheelEvent), m_pageID);
+            process()->send(Messages::EventDispatcher::WheelEvent(m_pageID, newWheelEvent), 0);
         }
 
         break;

Modified: trunk/Source/WebKit2/WebProcess/WebPage/EventDispatcher.cpp (102962 => 102963)


--- trunk/Source/WebKit2/WebProcess/WebPage/EventDispatcher.cpp	2011-12-15 18:50:59 UTC (rev 102962)
+++ trunk/Source/WebKit2/WebProcess/WebPage/EventDispatcher.cpp	2011-12-15 18:56:16 UTC (rev 102963)
@@ -26,6 +26,12 @@
 #include "config.h"
 #include "EventDispatcher.h"
 
+#include "RunLoop.h"
+#include "WebEvent.h"
+#include "WebPage.h"
+#include "WebProcess.h"
+#include <wtf/MainThread.h>
+
 namespace WebKit {
 
 EventDispatcher::EventDispatcher()
@@ -44,8 +50,20 @@
     }
 }
 
-void EventDispatcher::wheelEvent(const WebWheelEvent&)
+void EventDispatcher::wheelEvent(uint64_t pageID, const WebWheelEvent& wheelEvent)
 {
+    RunLoop::main()->dispatch(bind(&EventDispatcher::dispatchWheelEvent, this, pageID, wheelEvent));
 }
 
+void EventDispatcher::dispatchWheelEvent(uint64_t pageID, const WebWheelEvent& wheelEvent)
+{
+    ASSERT(isMainThread());
+
+    WebPage* webPage = WebProcess::shared().webPage(pageID);
+    if (!webPage)
+        return;
+
+    webPage->wheelEvent(wheelEvent);
+}
+
 } // namespace WebKit

Modified: trunk/Source/WebKit2/WebProcess/WebPage/EventDispatcher.h (102962 => 102963)


--- trunk/Source/WebKit2/WebProcess/WebPage/EventDispatcher.h	2011-12-15 18:50:59 UTC (rev 102962)
+++ trunk/Source/WebKit2/WebProcess/WebPage/EventDispatcher.h	2011-12-15 18:56:16 UTC (rev 102963)
@@ -47,7 +47,10 @@
     void didReceiveEventDispatcherMessageOnConnectionWorkQueue(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder* arguments, bool& didHandleMessage);
 
     // Message handlers
-    void wheelEvent(const WebWheelEvent&);
+    void wheelEvent(uint64_t pageID, const WebWheelEvent&);
+
+    // This is called on the main thread.
+    void dispatchWheelEvent(uint64_t pageID, const WebWheelEvent&);
 };
 
 } // namespace WebKit

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


--- trunk/Source/WebKit2/WebProcess/WebPage/EventDispatcher.messages.in	2011-12-15 18:50:59 UTC (rev 102962)
+++ trunk/Source/WebKit2/WebProcess/WebPage/EventDispatcher.messages.in	2011-12-15 18:56:16 UTC (rev 102963)
@@ -21,5 +21,5 @@
 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
 messages -> EventDispatcher {
-    WheelEvent(WebKit::WebWheelEvent event) DispatchOnConnectionQueue
+    WheelEvent(uint64_t pageID, WebKit::WebWheelEvent event) DispatchOnConnectionQueue
 }

Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h (102962 => 102963)


--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h	2011-12-15 18:50:59 UTC (rev 102962)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h	2011-12-15 18:56:16 UTC (rev 102963)
@@ -462,6 +462,8 @@
 
     void contextMenuShowing() { m_isShowingContextMenu = true; }
 
+    void wheelEvent(const WebWheelEvent&);
+
 private:
     WebPage(uint64_t pageID, const WebPageCreationParameters&);
 
@@ -510,7 +512,6 @@
 
     void mouseEvent(const WebMouseEvent&);
     void mouseEventSyncForTesting(const WebMouseEvent&, bool&);
-    void wheelEvent(const WebWheelEvent&);
     void wheelEventSyncForTesting(const WebWheelEvent&, bool&);
     void keyEvent(const WebKeyboardEvent&);
     void keyEventSyncForTesting(const WebKeyboardEvent&, bool&);

Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in (102962 => 102963)


--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in	2011-12-15 18:50:59 UTC (rev 102962)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in	2011-12-15 18:56:16 UTC (rev 102963)
@@ -36,7 +36,6 @@
     KeyEventSyncForTesting(WebKit::WebKeyboardEvent event) -> (bool handled)
     MouseEvent(WebKit::WebMouseEvent event)
     MouseEventSyncForTesting(WebKit::WebMouseEvent event) -> (bool handled)
-    WheelEvent(WebKit::WebWheelEvent event)
     WheelEventSyncForTesting(WebKit::WebWheelEvent event) -> (bool handled)
 #if ENABLE(GESTURE_EVENTS)
     GestureEvent(WebKit::WebGestureEvent event)
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to