Title: [123799] trunk
Revision
123799
Author
commit-qu...@webkit.org
Date
2012-07-26 15:10:54 -0700 (Thu, 26 Jul 2012)

Log Message

Propagate gesture events to plugins.
https://bugs.webkit.org/show_bug.cgi?id=92281

Patch by Sadrul Habib Chowdhury <sad...@chromium.org> on 2012-07-26
Reviewed by Adam Barth.

Source/WebCore:

Propagate gesture events to plugins. This change does not expose the gesture events
to _javascript_, since there is no spec for that at the moment. Exposing gesture events
to _javascript_ will be done separately, once there is a spec for it.

Test: platform/chromium/plugins/gesture-events.html

* CMakeLists.txt:
* GNUmakefile.list.am:
* Target.pri:
* WebCore.gypi:
* dom/EventNames.h:
(WebCore):
(WebCore::EventNames::isGestureEventType):
(EventNames):
* dom/GestureEvent.cpp: Added.
(WebCore):
(WebCore::GestureEvent::create):
(WebCore::GestureEvent::initGestureEvent):
(WebCore::GestureEvent::interfaceName):
(WebCore::GestureEvent::GestureEvent):
(WebCore::GestureEventDispatchMediator::GestureEventDispatchMediator):
(WebCore::GestureEventDispatchMediator::event):
(WebCore::GestureEventDispatchMediator::dispatchEvent):
* dom/GestureEvent.h: Added.
(WebCore):
(GestureEvent):
(WebCore::GestureEvent::~GestureEvent):
(WebCore::GestureEvent::deltaX):
(WebCore::GestureEvent::deltaY):
(WebCore::GestureEvent::GestureEvent):
(GestureEventDispatchMediator):
(WebCore::GestureEventDispatchMediator::create):
* dom/Node.cpp:
(WebCore):
(WebCore::Node::dispatchGestureEvent):
* dom/Node.h:
(WebCore):
(Node):
* page/EventHandler.cpp:
(WebCore::EventHandler::clear):
(WebCore::EventHandler::handleGestureEvent):
* page/EventHandler.h:

Source/WebKit/chromium:

Propagate gesture events to plugins.

* src/WebInputEventConversion.cpp:
(WebKit):
(WebKit::WebGestureEventBuilder::WebGestureEventBuilder):
* src/WebInputEventConversion.h:
(WebCore):
(WebKit):
(WebGestureEventBuilder):
* src/WebPluginContainerImpl.cpp:
(WebKit::WebPluginContainerImpl::handleEvent):
* src/WebPluginContainerImpl.h:
(WebCore):
(WebPluginContainerImpl):

Tools:

Update TestWebPlugin to receive events, and output logs for the events.

* DumpRenderTree/chromium/TestWebPlugin.cpp:
(TestWebPlugin::handleInputEvent):
* DumpRenderTree/chromium/TestWebPlugin.h:
(TestWebPlugin::acceptsInputEvents):
(TestWebPlugin):

LayoutTests:

Added a layout test to show that the plugins receive the gesture events correctly.

* platform/chromium/plugins/gesture-events-expected.txt: Added.
* platform/chromium/plugins/gesture-events.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (123798 => 123799)


--- trunk/LayoutTests/ChangeLog	2012-07-26 22:07:20 UTC (rev 123798)
+++ trunk/LayoutTests/ChangeLog	2012-07-26 22:10:54 UTC (rev 123799)
@@ -1,3 +1,15 @@
+2012-07-26  Sadrul Habib Chowdhury  <sad...@chromium.org>
+
+        Propagate gesture events to plugins.
+        https://bugs.webkit.org/show_bug.cgi?id=92281
+
+        Reviewed by Adam Barth.
+
+        Added a layout test to show that the plugins receive the gesture events correctly.
+
+        * platform/chromium/plugins/gesture-events-expected.txt: Added.
+        * platform/chromium/plugins/gesture-events.html: Added.
+
 2012-07-26  Gavin Peters  <gav...@chromium.org>
 
         Guard Prerenderer against inserting prerenders into detached documents.

Added: trunk/LayoutTests/platform/chromium/plugins/gesture-events-expected.txt (0 => 123799)


--- trunk/LayoutTests/platform/chromium/plugins/gesture-events-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/platform/chromium/plugins/gesture-events-expected.txt	2012-07-26 22:10:54 UTC (rev 123799)
@@ -0,0 +1,10 @@
+Plugin received event: GestureTap
+Plugin received event: MouseEnter
+Plugin received event: MouseMove
+Plugin received event: MouseDown
+Plugin received event: MouseUp
+Plugin received event: GestureScrollBegin
+Plugin received event: GestureScrollUpdate
+Plugin received event: MouseWheel
+Plugin received event: GestureScrollEnd
+

Added: trunk/LayoutTests/platform/chromium/plugins/gesture-events.html (0 => 123799)


--- trunk/LayoutTests/platform/chromium/plugins/gesture-events.html	                        (rev 0)
+++ trunk/LayoutTests/platform/chromium/plugins/gesture-events.html	2012-07-26 22:10:54 UTC (rev 123799)
@@ -0,0 +1,31 @@
+<html>
+<head>
+<style>
+  #plugin {
+    width: 150px;
+    height: 150px;
+  }
+</style>
+</head>
+
+<body>
+<embed id="plugin" type="application/x-webkit-test-webplugin" primitive="triangle" background-color="green" primitive-color="blue"></embed>
+<script>
+
+    if (!window.testRunner) {
+        document.write("This test does not work in manual mode.");
+    } else {
+        testRunner.dumpAsText();
+
+        // Send some gesture events to the plugin.
+        var positionX = plugin.offsetLeft + 10;
+        var positionY = plugin.offsetTop + 10;
+        eventSender.gestureTap(positionX, positionY);
+        eventSender.gestureScrollBegin(positionX, positionY);
+        eventSender.gestureScrollUpdate(30, 0);
+        eventSender.gestureScrollEnd(0, 0);
+    }
+
+</script>
+</body>
+</html>

Modified: trunk/Source/WebCore/CMakeLists.txt (123798 => 123799)


--- trunk/Source/WebCore/CMakeLists.txt	2012-07-26 22:07:20 UTC (rev 123798)
+++ trunk/Source/WebCore/CMakeLists.txt	2012-07-26 22:10:54 UTC (rev 123799)
@@ -1099,6 +1099,7 @@
     dom/ExceptionBase.cpp
     dom/ExceptionCodePlaceholder.cpp
     dom/GenericEventQueue.cpp
+    dom/GestureEvent.cpp
     dom/IconURL.cpp
     dom/IdTargetObserver.cpp
     dom/IdTargetObserverRegistry.cpp

Modified: trunk/Source/WebCore/ChangeLog (123798 => 123799)


--- trunk/Source/WebCore/ChangeLog	2012-07-26 22:07:20 UTC (rev 123798)
+++ trunk/Source/WebCore/ChangeLog	2012-07-26 22:10:54 UTC (rev 123799)
@@ -1,3 +1,53 @@
+2012-07-26  Sadrul Habib Chowdhury  <sad...@chromium.org>
+
+        Propagate gesture events to plugins.
+        https://bugs.webkit.org/show_bug.cgi?id=92281
+
+        Reviewed by Adam Barth.
+
+        Propagate gesture events to plugins. This change does not expose the gesture events
+        to _javascript_, since there is no spec for that at the moment. Exposing gesture events
+        to _javascript_ will be done separately, once there is a spec for it.
+
+        Test: platform/chromium/plugins/gesture-events.html
+
+        * CMakeLists.txt:
+        * GNUmakefile.list.am:
+        * Target.pri:
+        * WebCore.gypi:
+        * dom/EventNames.h:
+        (WebCore):
+        (WebCore::EventNames::isGestureEventType):
+        (EventNames):
+        * dom/GestureEvent.cpp: Added.
+        (WebCore):
+        (WebCore::GestureEvent::create):
+        (WebCore::GestureEvent::initGestureEvent):
+        (WebCore::GestureEvent::interfaceName):
+        (WebCore::GestureEvent::GestureEvent):
+        (WebCore::GestureEventDispatchMediator::GestureEventDispatchMediator):
+        (WebCore::GestureEventDispatchMediator::event):
+        (WebCore::GestureEventDispatchMediator::dispatchEvent):
+        * dom/GestureEvent.h: Added.
+        (WebCore):
+        (GestureEvent):
+        (WebCore::GestureEvent::~GestureEvent):
+        (WebCore::GestureEvent::deltaX):
+        (WebCore::GestureEvent::deltaY):
+        (WebCore::GestureEvent::GestureEvent):
+        (GestureEventDispatchMediator):
+        (WebCore::GestureEventDispatchMediator::create):
+        * dom/Node.cpp:
+        (WebCore):
+        (WebCore::Node::dispatchGestureEvent):
+        * dom/Node.h:
+        (WebCore):
+        (Node):
+        * page/EventHandler.cpp:
+        (WebCore::EventHandler::clear):
+        (WebCore::EventHandler::handleGestureEvent):
+        * page/EventHandler.h:
+
 2012-07-26  Gavin Peters  <gav...@chromium.org>
 
         Guard Prerenderer against inserting prerenders into detached documents.

Modified: trunk/Source/WebCore/GNUmakefile.list.am (123798 => 123799)


--- trunk/Source/WebCore/GNUmakefile.list.am	2012-07-26 22:07:20 UTC (rev 123798)
+++ trunk/Source/WebCore/GNUmakefile.list.am	2012-07-26 22:10:54 UTC (rev 123799)
@@ -1952,6 +1952,8 @@
 	Source/WebCore/dom/ExceptionCodePlaceholder.cpp \
 	Source/WebCore/dom/ExceptionCodePlaceholder.h \
 	Source/WebCore/dom/FragmentScriptingPermission.h \
+	Source/WebCore/dom/GestureEvent.cpp \
+	Source/WebCore/dom/GestureEvent.h \
 	Source/WebCore/dom/IgnoreDestructiveWriteCountIncrementer.h \
 	Source/WebCore/dom/ExceptionCodePlaceholder.h \
 	Source/WebCore/dom/GenericEventQueue.cpp \

Modified: trunk/Source/WebCore/Target.pri (123798 => 123799)


--- trunk/Source/WebCore/Target.pri	2012-07-26 22:07:20 UTC (rev 123798)
+++ trunk/Source/WebCore/Target.pri	2012-07-26 22:10:54 UTC (rev 123799)
@@ -408,6 +408,7 @@
     dom/ExceptionBase.cpp \
     dom/ExceptionCodePlaceholder.cpp \
     dom/GenericEventQueue.cpp \
+    dom/GestureEvent.cpp \
     dom/IconURL.cpp \
     dom/IdTargetObserver.cpp \
     dom/IdTargetObserverRegistry.cpp \
@@ -1535,6 +1536,7 @@
     dom/ExceptionBase.h \
     dom/ExceptionCode.h \
     dom/FragmentScriptingPermission.h \
+    dom/GestureEvent.h \
     dom/IdTargetObserver.h \
     dom/IdTargetObserverRegistry.h \
     dom/KeyboardEvent.h \

Modified: trunk/Source/WebCore/WebCore.gypi (123798 => 123799)


--- trunk/Source/WebCore/WebCore.gypi	2012-07-26 22:07:20 UTC (rev 123798)
+++ trunk/Source/WebCore/WebCore.gypi	2012-07-26 22:10:54 UTC (rev 123799)
@@ -5187,6 +5187,8 @@
             'dom/ExceptionCodePlaceholder.cpp',
             'dom/GenericEventQueue.cpp',
             'dom/GenericEventQueue.h',
+            'dom/GestureEvent.cpp',
+            'dom/GestureEvent.h',
             'dom/HashChangeEvent.h',
             'dom/IgnoreDestructiveWriteCountIncrementer.h',
             'dom/IconURL.cpp',

Modified: trunk/Source/WebCore/dom/EventNames.h (123798 => 123799)


--- trunk/Source/WebCore/dom/EventNames.h	2012-07-26 22:07:20 UTC (rev 123798)
+++ trunk/Source/WebCore/dom/EventNames.h	2012-07-26 22:10:54 UTC (rev 123799)
@@ -71,6 +71,11 @@
     macro(focus) \
     macro(focusin) \
     macro(focusout) \
+    macro(gesturetap) \
+    macro(gesturetapdown) \
+    macro(gesturescrollstart) \
+    macro(gesturescrollend) \
+    macro(gesturescrollupdate) \
     macro(hashchange) \
     macro(input) \
     macro(invalid) \
@@ -262,6 +267,15 @@
                 || eventType == touchcancelEvent;
         }
 
+        inline bool isGestureEventType(const AtomicString& eventType) const
+        {
+            return eventType == gesturetapEvent
+                || eventType == gesturetapdownEvent
+                || eventType == gesturescrollstartEvent
+                || eventType == gesturescrollendEvent
+                || eventType == gesturescrollupdateEvent;
+        }
+
         Vector<AtomicString> touchEventNames() const
         {
             Vector<AtomicString> names;

Added: trunk/Source/WebCore/dom/GestureEvent.cpp (0 => 123799)


--- trunk/Source/WebCore/dom/GestureEvent.cpp	                        (rev 0)
+++ trunk/Source/WebCore/dom/GestureEvent.cpp	2012-07-26 22:10:54 UTC (rev 123799)
@@ -0,0 +1,128 @@
+/*
+ * Copyright (C) 2012 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *  * Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+
+#if ENABLE(GESTURE_EVENTS)
+
+#include "GestureEvent.h"
+
+namespace WebCore {
+
+PassRefPtr<GestureEvent> GestureEvent::create()
+{
+    return adoptRef(new GestureEvent);
+}
+
+PassRefPtr<GestureEvent> GestureEvent::create(PassRefPtr<AbstractView> view, const PlatformGestureEvent& event)
+{
+    AtomicString eventType;
+    switch (event.type()) {
+    case PlatformEvent::GestureScrollBegin:
+        eventType = eventNames().gesturescrollstartEvent; break;
+    case PlatformEvent::GestureScrollEnd:
+        eventType = eventNames().gesturescrollendEvent; break;
+    case PlatformEvent::GestureScrollUpdate:
+        eventType = eventNames().gesturescrollupdateEvent; break;
+    case PlatformEvent::GestureTap:
+        eventType = eventNames().gesturetapEvent; break;
+    case PlatformEvent::GestureTapDown:
+        eventType = eventNames().gesturetapdownEvent; break;
+    case PlatformEvent::GestureDoubleTap:
+    case PlatformEvent::GestureTwoFingerTap:
+    case PlatformEvent::GestureLongPress:
+    case PlatformEvent::GesturePinchBegin:
+    case PlatformEvent::GesturePinchEnd:
+    case PlatformEvent::GesturePinchUpdate:
+    default:
+        ASSERT_NOT_REACHED();
+    }
+    return adoptRef(new GestureEvent(eventType, view, event.globalPosition().x(), event.globalPosition().y(), event.position().x(), event.position().y(), event.ctrlKey(), event.altKey(), event.shiftKey(), event.metaKey(), event.deltaX(), event.deltaY()));
+}
+
+void GestureEvent::initGestureEvent(const AtomicString& type, PassRefPtr<AbstractView> view, int screenX, int screenY, int clientX, int clientY, bool ctrlKey, bool altKey, bool shiftKey, bool metaKey, float deltaX, float deltaY)
+{
+    if (dispatched())
+        return;
+
+    initUIEvent(type, true, true, view, 0);
+    m_screenLocation = IntPoint(screenX, screenY);
+    m_ctrlKey = ctrlKey;
+    m_altKey = altKey;
+    m_shiftKey = shiftKey;
+    m_metaKey = metaKey;
+
+    m_deltaX = deltaX;
+    m_deltaY = deltaY;
+
+    initCoordinates(IntPoint(clientX, clientY));
+}
+
+const AtomicString& GestureEvent::interfaceName() const
+{
+    static AtomicString interface("TBDInterface");
+    return interface;
+}
+
+GestureEvent::GestureEvent()
+    : m_deltaX(0)
+    , m_deltaY(0)
+{
+}
+
+GestureEvent::GestureEvent(const AtomicString& type, PassRefPtr<AbstractView> view, int screenX, int screenY, int clientX, int clientY, bool ctrlKey, bool altKey, bool shiftKey, bool metaKey, float deltaX, float deltaY)
+    : MouseRelatedEvent(type, true, true, view, 0, IntPoint(screenX, screenY), IntPoint(clientX, clientY),
+#if ENABLE(POINTER_LOCK)
+                        IntPoint(0, 0),
+#endif
+                        ctrlKey, altKey, shiftKey, metaKey)
+    , m_deltaX(deltaX)
+    , m_deltaY(deltaY)
+{
+}
+
+GestureEventDispatchMediator::GestureEventDispatchMediator(PassRefPtr<GestureEvent> gestureEvent)
+    : EventDispatchMediator(gestureEvent)
+{
+}
+
+GestureEvent* GestureEventDispatchMediator::event() const
+{
+    return static_cast<GestureEvent*>(EventDispatchMediator::event());
+}
+
+bool GestureEventDispatchMediator::dispatchEvent(EventDispatcher* dispatcher) const
+{
+    if (dispatcher->node()->disabled())
+        return true;
+
+    dispatcher->dispatchEvent(event());
+    ASSERT(!event()->defaultPrevented());
+    return event()->defaultHandled() || event()->defaultPrevented();
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(GESTURE_EVENTS)

Added: trunk/Source/WebCore/dom/GestureEvent.h (0 => 123799)


--- trunk/Source/WebCore/dom/GestureEvent.h	                        (rev 0)
+++ trunk/Source/WebCore/dom/GestureEvent.h	2012-07-26 22:10:54 UTC (rev 123799)
@@ -0,0 +1,82 @@
+/*
+ * Copyright (C) 2012 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *  * Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef GestureEvent_h
+#define GestureEvent_h
+
+#if ENABLE(GESTURE_EVENTS)
+
+#include "EventDispatcher.h"
+#include "EventNames.h"
+#include "Frame.h"
+#include "FrameView.h"
+#include "MouseRelatedEvent.h"
+#include "PlatformEvent.h"
+#include "PlatformGestureEvent.h"
+
+namespace WebCore {
+
+class GestureEvent : public MouseRelatedEvent {
+public:
+    virtual ~GestureEvent() { }
+
+    static PassRefPtr<GestureEvent> create();
+    static PassRefPtr<GestureEvent> create(PassRefPtr<AbstractView>, const PlatformGestureEvent&);
+
+    void initGestureEvent(const AtomicString& type, PassRefPtr<AbstractView>, int screenX, int screenY, int clientX, int clientY, bool ctrlKey, bool altKey, bool shiftKey, bool metaKey, float deltaX, float deltaY);
+
+    virtual const AtomicString& interfaceName() const;
+
+    float deltaX() const { return m_deltaX; }
+    float deltaY() const { return m_deltaY; }
+
+private:
+    GestureEvent();
+    GestureEvent(const AtomicString& type, PassRefPtr<AbstractView>, int screenX, int screenY, int clientX, int clientY, bool ctrlKey, bool altKey, bool shiftKey, bool metaKey, float deltaX, float deltaY);
+
+    float m_deltaX;
+    float m_deltaY;
+};
+
+class GestureEventDispatchMediator : public EventDispatchMediator {
+public:
+    static PassRefPtr<GestureEventDispatchMediator> create(PassRefPtr<GestureEvent> gestureEvent)
+    {
+        return adoptRef(new GestureEventDispatchMediator(gestureEvent));
+    }
+
+private:
+    explicit GestureEventDispatchMediator(PassRefPtr<GestureEvent>);
+
+    GestureEvent* event() const;
+
+    virtual bool dispatchEvent(EventDispatcher*) const;
+};
+
+} // namespace WebCore
+
+#endif // ENABLE(GESTURE_EVENTS)
+
+#endif // GestureEvent_h

Modified: trunk/Source/WebCore/dom/Node.cpp (123798 => 123799)


--- trunk/Source/WebCore/dom/Node.cpp	2012-07-26 22:07:20 UTC (rev 123798)
+++ trunk/Source/WebCore/dom/Node.cpp	2012-07-26 22:10:54 UTC (rev 123799)
@@ -109,6 +109,10 @@
 #include <wtf/text/CString.h>
 #include <wtf/text/StringBuilder.h>
 
+#if ENABLE(GESTURE_EVENTS)
+#include "GestureEvent.h"
+#endif
+
 #if ENABLE(INSPECTOR)
 #include "InspectorController.h"
 #endif
@@ -2633,6 +2637,13 @@
     return EventDispatcher::dispatchEvent(this, MouseEventDispatchMediator::create(MouseEvent::create(eventType, document()->defaultView(), event, detail, relatedTarget)));
 }
 
+#if ENABLE(GESTURE_EVENTS)
+bool Node::dispatchGestureEvent(const PlatformGestureEvent& event)
+{
+    return EventDispatcher::dispatchEvent(this, GestureEventDispatchMediator::create(GestureEvent::create(document()->defaultView(), event)));
+}
+#endif
+
 void Node::dispatchSimulatedClick(PassRefPtr<Event> event, bool sendMouseEvents, bool showPressedLook)
 {
     EventDispatcher::dispatchSimulatedClick(this, event, sendMouseEvents, showPressedLook);

Modified: trunk/Source/WebCore/dom/Node.h (123798 => 123799)


--- trunk/Source/WebCore/dom/Node.h	2012-07-26 22:07:20 UTC (rev 123798)
+++ trunk/Source/WebCore/dom/Node.h	2012-07-26 22:10:54 UTC (rev 123799)
@@ -88,6 +88,10 @@
 class TagNodeList;
 class TreeScope;
 
+#if ENABLE(GESTURE_EVENTS)
+class PlatformGestureEvent;
+#endif
+
 #if ENABLE(MICRODATA)
 class HTMLPropertiesCollection;
 class PropertyNodeList;
@@ -609,6 +613,9 @@
     bool dispatchKeyEvent(const PlatformKeyboardEvent&);
     bool dispatchWheelEvent(const PlatformWheelEvent&);
     bool dispatchMouseEvent(const PlatformMouseEvent&, const AtomicString& eventType, int clickCount = 0, Node* relatedTarget = 0);
+#if ENABLE(GESTURE_EVENTS)
+    bool dispatchGestureEvent(const PlatformGestureEvent&);
+#endif
     void dispatchSimulatedClick(PassRefPtr<Event> underlyingEvent, bool sendMouseEvents = false, bool showPressedLook = true);
     bool dispatchBeforeLoadEvent(const String& sourceURL);
 

Modified: trunk/Source/WebCore/page/EventHandler.cpp (123798 => 123799)


--- trunk/Source/WebCore/page/EventHandler.cpp	2012-07-26 22:07:20 UTC (rev 123798)
+++ trunk/Source/WebCore/page/EventHandler.cpp	2012-07-26 22:10:54 UTC (rev 123799)
@@ -367,10 +367,11 @@
 #if ENABLE(TOUCH_EVENTS)
     m_originatingTouchPointTargets.clear();
 #endif
+#if ENABLE(GESTURE_EVENTS)
+    m_scrollGestureHandlingNode = 0;
+#endif
     m_maxMouseMovedDuration = 0;
-#if ENABLE(GESTURE_EVENTS)
     m_baseEventType = PlatformEvent::NoType;
-#endif
 }
 
 void EventHandler::nodeWillBeRemoved(Node* nodeToBeRemoved)
@@ -2413,6 +2414,29 @@
 
 bool EventHandler::handleGestureEvent(const PlatformGestureEvent& gestureEvent)
 {
+    Node* eventTarget = 0;
+    if (gestureEvent.type() == PlatformEvent::GestureScrollEnd || gestureEvent.type() == PlatformEvent::GestureScrollUpdate)
+        eventTarget = m_scrollGestureHandlingNode.get();
+
+    if (!eventTarget) {
+        HitTestResult result = hitTestResultAtPoint(gestureEvent.position(), false, false, DontHitTestScrollbars, HitTestRequest::ReadOnly | HitTestRequest::Active);
+        eventTarget = targetNode(result);
+    }
+
+    if (eventTarget) {
+        bool eventSwallowed = eventTarget->dispatchGestureEvent(gestureEvent);
+
+        if (gestureEvent.type() == PlatformEvent::GestureScrollBegin) {
+            if (eventSwallowed)
+                m_scrollGestureHandlingNode = eventTarget;
+            else
+                m_scrollGestureHandlingNode = 0;
+        }
+
+        if (eventSwallowed)
+            return true;
+    }
+
     // FIXME: A more general scroll system (https://bugs.webkit.org/show_bug.cgi?id=80596) will
     // eliminate the need for this.
     TemporaryChange<PlatformEvent::Type> baseEventType(m_baseEventType, gestureEvent.type());

Modified: trunk/Source/WebCore/page/EventHandler.h (123798 => 123799)


--- trunk/Source/WebCore/page/EventHandler.h	2012-07-26 22:07:20 UTC (rev 123798)
+++ trunk/Source/WebCore/page/EventHandler.h	2012-07-26 22:10:54 UTC (rev 123799)
@@ -446,6 +446,11 @@
     TouchTargetMap m_originatingTouchPointTargets;
     bool m_touchPressed;
 #endif
+
+#if ENABLE(GESTURE_EVENTS)
+    RefPtr<Node> m_scrollGestureHandlingNode;
+#endif
+
     double m_maxMouseMovedDuration;
     PlatformEvent::Type m_baseEventType;
 };

Modified: trunk/Source/WebKit/chromium/ChangeLog (123798 => 123799)


--- trunk/Source/WebKit/chromium/ChangeLog	2012-07-26 22:07:20 UTC (rev 123798)
+++ trunk/Source/WebKit/chromium/ChangeLog	2012-07-26 22:10:54 UTC (rev 123799)
@@ -1,3 +1,25 @@
+2012-07-26  Sadrul Habib Chowdhury  <sad...@chromium.org>
+
+        Propagate gesture events to plugins.
+        https://bugs.webkit.org/show_bug.cgi?id=92281
+
+        Reviewed by Adam Barth.
+
+        Propagate gesture events to plugins.
+
+        * src/WebInputEventConversion.cpp:
+        (WebKit):
+        (WebKit::WebGestureEventBuilder::WebGestureEventBuilder):
+        * src/WebInputEventConversion.h:
+        (WebCore):
+        (WebKit):
+        (WebGestureEventBuilder):
+        * src/WebPluginContainerImpl.cpp:
+        (WebKit::WebPluginContainerImpl::handleEvent):
+        * src/WebPluginContainerImpl.h:
+        (WebCore):
+        (WebPluginContainerImpl):
+
 2012-07-26  Adrienne Walker  <e...@google.com>
 
         [chromium] Remove redundant surface origin transforms

Modified: trunk/Source/WebKit/chromium/src/WebInputEventConversion.cpp (123798 => 123799)


--- trunk/Source/WebKit/chromium/src/WebInputEventConversion.cpp	2012-07-26 22:07:20 UTC (rev 123798)
+++ trunk/Source/WebKit/chromium/src/WebInputEventConversion.cpp	2012-07-26 22:10:54 UTC (rev 123799)
@@ -32,6 +32,7 @@
 #include "WebInputEventConversion.h"
 
 #include "EventNames.h"
+#include "GestureEvent.h"
 #include "KeyboardCodes.h"
 #include "KeyboardEvent.h"
 #include "MouseEvent.h"
@@ -512,4 +513,31 @@
 
 #endif // ENABLE(TOUCH_EVENTS)
 
+#if ENABLE(GESTURE_EVENTS)
+WebGestureEventBuilder::WebGestureEventBuilder(const Widget* widget, const GestureEvent& event)
+{
+    if (event.type() == eventNames().gesturetapEvent)
+        type = GestureTap;
+    else if (event.type() == eventNames().gesturetapdownEvent)
+        type = GestureTapDown;
+    else if (event.type() == eventNames().gesturescrollstartEvent)
+        type = GestureScrollBegin;
+    else if (event.type() == eventNames().gesturescrollendEvent)
+        type = GestureScrollEnd;
+    else if (event.type() == eventNames().gesturescrollupdateEvent)
+        type = GestureScrollUpdate;
+
+    timeStampSeconds = event.timeStamp() / millisPerSecond;
+    modifiers = getWebInputModifiers(event);
+
+    globalX = event.screenX();
+    globalY = event.screenY();
+    x = event.absoluteLocation().x() - widget->location().x();
+    y = event.absoluteLocation().y() - widget->location().y();
+
+    deltaX = event.deltaX();
+    deltaY = event.deltaY();
+}
+#endif // ENABLE(GESTURE_EVENTS)
+
 } // namespace WebKit

Modified: trunk/Source/WebKit/chromium/src/WebInputEventConversion.h (123798 => 123799)


--- trunk/Source/WebKit/chromium/src/WebInputEventConversion.h	2012-07-26 22:07:20 UTC (rev 123798)
+++ trunk/Source/WebKit/chromium/src/WebInputEventConversion.h	2012-07-26 22:10:54 UTC (rev 123799)
@@ -39,6 +39,7 @@
 #include "WebInputEvent.h"
 
 namespace WebCore {
+class GestureEvent;
 class KeyboardEvent;
 class MouseEvent;
 class ScrollView;
@@ -131,6 +132,15 @@
 };
 #endif // ENABLE(TOUCH_EVENTS)
 
+#if ENABLE(GESTURE_EVENTS)
+// Converts WebCore::GestureEvent to a corresponding WebGestureEvent.
+// NOTE: If event mapping fails, the type will be set to Undefined.
+class WebGestureEventBuilder : public WebGestureEvent {
+public:
+    WebGestureEventBuilder(const WebCore::Widget*, const WebCore::GestureEvent&);
+};
+#endif // ENABLE(GESTURE_EVENTS)
+
 } // namespace WebKit
 
 #endif

Modified: trunk/Source/WebKit/chromium/src/WebPluginContainerImpl.cpp (123798 => 123799)


--- trunk/Source/WebKit/chromium/src/WebPluginContainerImpl.cpp	2012-07-26 22:07:20 UTC (rev 123798)
+++ trunk/Source/WebKit/chromium/src/WebPluginContainerImpl.cpp	2012-07-26 22:10:54 UTC (rev 123799)
@@ -56,6 +56,7 @@
 #include "Frame.h"
 #include "FrameLoadRequest.h"
 #include "FrameView.h"
+#include "GestureEvent.h"
 #include "GraphicsContext.h"
 #include "HitTestResult.h"
 #include "HostWindow.h"
@@ -188,6 +189,8 @@
         handleKeyboardEvent(static_cast<KeyboardEvent*>(event));
     else if (eventNames().isTouchEventType(event->type()))
         handleTouchEvent(static_cast<TouchEvent*>(event));
+    else if (eventNames().isGestureEventType(event->type()))
+        handleGestureEvent(static_cast<GestureEvent*>(event));
 
     // FIXME: it would be cleaner if Widget::handleEvent returned true/false and
     // HTMLPluginElement called setDefaultHandled or defaultEventHandler.
@@ -736,6 +739,17 @@
     // FIXME: Can a plugin change the cursor from a touch-event callback?
 }
 
+void WebPluginContainerImpl::handleGestureEvent(GestureEvent* event)
+{
+    WebGestureEventBuilder webEvent(this, *event);
+    if (webEvent.type == WebInputEvent::Undefined)
+        return;
+    WebCursorInfo cursorInfo;
+    if (m_webPlugin->handleInputEvent(webEvent, cursorInfo))
+        event->setDefaultHandled();
+    // FIXME: Can a plugin change the cursor from a touch-event callback?
+}
+
 void WebPluginContainerImpl::calculateGeometry(const IntRect& frameRect,
                                                IntRect& windowRect,
                                                IntRect& clipRect,

Modified: trunk/Source/WebKit/chromium/src/WebPluginContainerImpl.h (123798 => 123799)


--- trunk/Source/WebKit/chromium/src/WebPluginContainerImpl.h	2012-07-26 22:07:20 UTC (rev 123798)
+++ trunk/Source/WebKit/chromium/src/WebPluginContainerImpl.h	2012-07-26 22:10:54 UTC (rev 123799)
@@ -45,6 +45,7 @@
 struct NPObject;
 
 namespace WebCore {
+class GestureEvent;
 class HTMLPlugInElement;
 class IntRect;
 class KeyboardEvent;
@@ -167,6 +168,7 @@
     void handleWheelEvent(WebCore::WheelEvent*);
     void handleKeyboardEvent(WebCore::KeyboardEvent*);
     void handleTouchEvent(WebCore::TouchEvent*);
+    void handleGestureEvent(WebCore::GestureEvent*);
 
     void calculateGeometry(const WebCore::IntRect& frameRect,
                            WebCore::IntRect& windowRect,

Modified: trunk/Tools/ChangeLog (123798 => 123799)


--- trunk/Tools/ChangeLog	2012-07-26 22:07:20 UTC (rev 123798)
+++ trunk/Tools/ChangeLog	2012-07-26 22:10:54 UTC (rev 123799)
@@ -1,3 +1,18 @@
+2012-07-26  Sadrul Habib Chowdhury  <sad...@chromium.org>
+
+        Propagate gesture events to plugins.
+        https://bugs.webkit.org/show_bug.cgi?id=92281
+
+        Reviewed by Adam Barth.
+
+        Update TestWebPlugin to receive events, and output logs for the events.
+
+        * DumpRenderTree/chromium/TestWebPlugin.cpp:
+        (TestWebPlugin::handleInputEvent):
+        * DumpRenderTree/chromium/TestWebPlugin.h:
+        (TestWebPlugin::acceptsInputEvents):
+        (TestWebPlugin):
+
 2012-07-26  Balazs Kelemen  <kbal...@webkit.org>
 
         [nrwt] get rid of --skip-pixel-test-if-no-baseline

Modified: trunk/Tools/DumpRenderTree/chromium/TestWebPlugin.cpp (123798 => 123799)


--- trunk/Tools/DumpRenderTree/chromium/TestWebPlugin.cpp	2012-07-26 22:07:20 UTC (rev 123798)
+++ trunk/Tools/DumpRenderTree/chromium/TestWebPlugin.cpp	2012-07-26 22:10:54 UTC (rev 123799)
@@ -27,6 +27,7 @@
 #include "TestWebPlugin.h"
 
 #include "WebFrame.h"
+#include "WebInputEvent.h"
 #include "platform/WebGraphicsContext3D.h"
 #include "WebKit.h"
 #include "platform/WebKitPlatformSupport.h"
@@ -364,3 +365,47 @@
     return program;
 }
 
+bool TestWebPlugin::handleInputEvent(const WebKit::WebInputEvent& event, WebKit::WebCursorInfo& info)
+{
+    const char* eventName = 0;
+    switch (event.type) {
+    case WebKit::WebInputEvent::Undefined:           eventName = "unknown"; break;
+
+    case WebKit::WebInputEvent::MouseDown:           eventName = "MouseDown"; break;
+    case WebKit::WebInputEvent::MouseUp:             eventName = "MouseUp"; break;
+    case WebKit::WebInputEvent::MouseMove:           eventName = "MouseMove"; break;
+    case WebKit::WebInputEvent::MouseEnter:          eventName = "MouseEnter"; break;
+    case WebKit::WebInputEvent::MouseLeave:          eventName = "MouseLeave"; break;
+    case WebKit::WebInputEvent::ContextMenu:         eventName = "ContextMenu"; break;
+
+    case WebKit::WebInputEvent::MouseWheel:          eventName = "MouseWheel"; break;
+
+    case WebKit::WebInputEvent::RawKeyDown:          eventName = "RawKeyDown"; break;
+    case WebKit::WebInputEvent::KeyDown:             eventName = "KeyDown"; break;
+    case WebKit::WebInputEvent::KeyUp:               eventName = "KeyUp"; break;
+    case WebKit::WebInputEvent::Char:                eventName = "Char"; break;
+
+    case WebKit::WebInputEvent::GestureScrollBegin:  eventName = "GestureScrollBegin"; break;
+    case WebKit::WebInputEvent::GestureScrollEnd:    eventName = "GestureScrollEnd"; break;
+    case WebKit::WebInputEvent::GestureScrollUpdate: eventName = "GestureScrollUpdate"; break;
+    case WebKit::WebInputEvent::GestureFlingStart:   eventName = "GestureFlingStart"; break;
+    case WebKit::WebInputEvent::GestureFlingCancel:  eventName = "GestureFlingCancel"; break;
+    case WebKit::WebInputEvent::GestureTap:          eventName = "GestureTap"; break;
+    case WebKit::WebInputEvent::GestureTapDown:      eventName = "GestureTapDown"; break;
+    case WebKit::WebInputEvent::GestureDoubleTap:    eventName = "GestureDoubleTap"; break;
+    case WebKit::WebInputEvent::GestureTwoFingerTap: eventName = "GestureTwoFingerTap"; break;
+    case WebKit::WebInputEvent::GestureLongPress:    eventName = "GestureLongPress"; break;
+    case WebKit::WebInputEvent::GesturePinchBegin:   eventName = "GesturePinchBegin"; break;
+    case WebKit::WebInputEvent::GesturePinchEnd:     eventName = "GesturePinchEnd"; break;
+    case WebKit::WebInputEvent::GesturePinchUpdate:  eventName = "GesturePinchUpdate"; break;
+
+    case WebKit::WebInputEvent::TouchStart:          eventName = "TouchStart"; break;
+    case WebKit::WebInputEvent::TouchMove:           eventName = "TouchMove"; break;
+    case WebKit::WebInputEvent::TouchEnd:            eventName = "TouchEnd"; break;
+    case WebKit::WebInputEvent::TouchCancel:         eventName = "TouchCancel"; break;
+    }
+
+    printf("Plugin received event: %s\n", eventName ? eventName : "unknown");
+    return false;
+}
+

Modified: trunk/Tools/DumpRenderTree/chromium/TestWebPlugin.h (123798 => 123799)


--- trunk/Tools/DumpRenderTree/chromium/TestWebPlugin.h	2012-07-26 22:07:20 UTC (rev 123798)
+++ trunk/Tools/DumpRenderTree/chromium/TestWebPlugin.h	2012-07-26 22:10:54 UTC (rev 123799)
@@ -60,8 +60,8 @@
                                 bool isVisible);
     virtual void updateFocus(bool) { }
     virtual void updateVisibility(bool) { }
-    virtual bool acceptsInputEvents() { return false; }
-    virtual bool handleInputEvent(const WebKit::WebInputEvent&, WebKit::WebCursorInfo&) { return false; }
+    virtual bool acceptsInputEvents() { return true; }
+    virtual bool handleInputEvent(const WebKit::WebInputEvent&, WebKit::WebCursorInfo&);
     virtual void didReceiveResponse(const WebKit::WebURLResponse&) { }
     virtual void didReceiveData(const char* data, int dataLength) { }
     virtual void didFinishLoading() { }
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to