<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[174880] trunk</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/174880">174880</a></dd>
<dt>Author</dt> <dd>carlosgc@webkit.org</dd>
<dt>Date</dt> <dd>2014-10-20 01:44:19 -0700 (Mon, 20 Oct 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>[GTK] Add initial gestures support
https://bugs.webkit.org/show_bug.cgi?id=137812

Reviewed by Sergio Villar Senin.

.:

Check if the GTK+ version supports gestures or not.

* Source/cmake/FindGTK3.cmake:
* Source/cmake/OptionsGTK.cmake:

Source/WebKit2:

Now that GTK+ has support for gestures, we can use it to handle
touch events and allow to scroll, zoom and tap with the fingers.

* PlatformGTK.cmake: Add new files to compilation.
* UIProcess/API/gtk/PageClientImpl.cpp:
(WebKit::PageClientImpl::doneWithTouchEvent): When the touch event
hasn't been handled by the web process pass it to the
GestureController and only fallback to pointer emulation when the
GestureController doesn't handle the event.
* UIProcess/API/gtk/WebKitWebViewBase.cpp:
(webkitWebViewBaseTouchEvent): If the GestureController is
currently processing gestures is because the START touch event was
not handled by the web process, so pass any successive touch
events to the GestureController directly.
(webkitWebViewBaseGestureController): Create the GestureController
on demand and return a reference.
* UIProcess/API/gtk/WebKitWebViewBasePrivate.h:
* UIProcess/gtk/GestureController.cpp: Added.
(WebKit::GestureController::create): Create a GestureController.
(WebKit::GestureController::GestureController): Initialize the
Gesture memebers.
(WebKit::GestureController::handleEvent): Pass the event to the gestures.
(WebKit::GestureController::isProcessingGestures): Whether
Gestures are active.
(WebKit::GestureController::Gesture::Gesture): Base class for gestures.
(WebKit::GestureController::Gesture::isActive): Whether the
gesture is active.
(WebKit::GestureController::Gesture::handleEvent): Pass the event
to the GtkGesture to process it.
(WebKit::GestureController::DragGesture::handleDrag): Send a wheel
event corresponding to the drag gesture to the web process.
(WebKit::GestureController::DragGesture::handleTap): Send move,
press and release events corresponding to a tap gesture to the web process.
(WebKit::GestureController::DragGesture::begin): Start a drag
gesture and schedule a timer to discard tap gesture in case of
long press.
(WebKit::GestureController::DragGesture::update): If the actual
drag hasn't started yet, check the drag threshold to decide
whether to start the drag or not. Otherwise call handleDrag() to
send the appropriate events to the web process.
(WebKit::GestureController::DragGesture::end): If the drag gesture
finishes and the drag didn't happen (it wasn't a long press and
drag threshold was not reached), call handleTap() to emulate a
click event.
(WebKit::GestureController::DragGesture::DragGesture): Initialize
the GtkGestureDrag.
(WebKit::GestureController::ZoomGesture::begin): Save the current
page scale factor and the center point of the gesture.
(WebKit::GestureController::ZoomGesture::scaleChanged): Schedule a
page scale change in an idle for the given scale value.
(WebKit::GestureController::ZoomGesture::ZoomGesture): Initialize
the GtkGestureZoom.
* UIProcess/gtk/GestureController.h: Added.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkChangeLog">trunk/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2PlatformGTKcmake">trunk/Source/WebKit2/PlatformGTK.cmake</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPIgtkPageClientImplcpp">trunk/Source/WebKit2/UIProcess/API/gtk/PageClientImpl.cpp</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPIgtkWebKitWebViewBasecpp">trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBase.cpp</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPIgtkWebKitWebViewBasePrivateh">trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBasePrivate.h</a></li>
<li><a href="#trunkSourcecmakeFindGTK3cmake">trunk/Source/cmake/FindGTK3.cmake</a></li>
<li><a href="#trunkSourcecmakeOptionsGTKcmake">trunk/Source/cmake/OptionsGTK.cmake</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkSourceWebKit2UIProcessgtkGestureControllercpp">trunk/Source/WebKit2/UIProcess/gtk/GestureController.cpp</a></li>
<li><a href="#trunkSourceWebKit2UIProcessgtkGestureControllerh">trunk/Source/WebKit2/UIProcess/gtk/GestureController.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/ChangeLog (174879 => 174880)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/ChangeLog        2014-10-20 08:23:26 UTC (rev 174879)
+++ trunk/ChangeLog        2014-10-20 08:44:19 UTC (rev 174880)
</span><span class="lines">@@ -1,3 +1,15 @@
</span><ins>+2014-10-20  Carlos Garcia Campos  &lt;cgarcia@igalia.com&gt;
+
+        [GTK] Add initial gestures support
+        https://bugs.webkit.org/show_bug.cgi?id=137812
+
+        Reviewed by Sergio Villar Senin.
+
+        Check if the GTK+ version supports gestures or not.
+
+        * Source/cmake/FindGTK3.cmake:
+        * Source/cmake/OptionsGTK.cmake:
+
</ins><span class="cx"> 2014-10-16  Carlos Garcia Campos  &lt;cgarcia@igalia.com&gt;
</span><span class="cx"> 
</span><span class="cx">         REGRESSION(CMake): [GTK] WebKitSettings:enable-smooth-scrolling does nothing
</span></span></pre></div>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (174879 => 174880)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2014-10-20 08:23:26 UTC (rev 174879)
+++ trunk/Source/WebKit2/ChangeLog        2014-10-20 08:44:19 UTC (rev 174880)
</span><span class="lines">@@ -1,3 +1,64 @@
</span><ins>+2014-10-20  Carlos Garcia Campos  &lt;cgarcia@igalia.com&gt;
+
+        [GTK] Add initial gestures support
+        https://bugs.webkit.org/show_bug.cgi?id=137812
+
+        Reviewed by Sergio Villar Senin.
+
+        Now that GTK+ has support for gestures, we can use it to handle
+        touch events and allow to scroll, zoom and tap with the fingers.
+
+        * PlatformGTK.cmake: Add new files to compilation.
+        * UIProcess/API/gtk/PageClientImpl.cpp:
+        (WebKit::PageClientImpl::doneWithTouchEvent): When the touch event
+        hasn't been handled by the web process pass it to the
+        GestureController and only fallback to pointer emulation when the
+        GestureController doesn't handle the event.
+        * UIProcess/API/gtk/WebKitWebViewBase.cpp:
+        (webkitWebViewBaseTouchEvent): If the GestureController is
+        currently processing gestures is because the START touch event was
+        not handled by the web process, so pass any successive touch
+        events to the GestureController directly.
+        (webkitWebViewBaseGestureController): Create the GestureController
+        on demand and return a reference.
+        * UIProcess/API/gtk/WebKitWebViewBasePrivate.h:
+        * UIProcess/gtk/GestureController.cpp: Added.
+        (WebKit::GestureController::create): Create a GestureController.
+        (WebKit::GestureController::GestureController): Initialize the
+        Gesture memebers.
+        (WebKit::GestureController::handleEvent): Pass the event to the gestures.
+        (WebKit::GestureController::isProcessingGestures): Whether
+        Gestures are active.
+        (WebKit::GestureController::Gesture::Gesture): Base class for gestures.
+        (WebKit::GestureController::Gesture::isActive): Whether the
+        gesture is active.
+        (WebKit::GestureController::Gesture::handleEvent): Pass the event
+        to the GtkGesture to process it.
+        (WebKit::GestureController::DragGesture::handleDrag): Send a wheel
+        event corresponding to the drag gesture to the web process.
+        (WebKit::GestureController::DragGesture::handleTap): Send move,
+        press and release events corresponding to a tap gesture to the web process.
+        (WebKit::GestureController::DragGesture::begin): Start a drag
+        gesture and schedule a timer to discard tap gesture in case of
+        long press.
+        (WebKit::GestureController::DragGesture::update): If the actual
+        drag hasn't started yet, check the drag threshold to decide
+        whether to start the drag or not. Otherwise call handleDrag() to
+        send the appropriate events to the web process.
+        (WebKit::GestureController::DragGesture::end): If the drag gesture
+        finishes and the drag didn't happen (it wasn't a long press and
+        drag threshold was not reached), call handleTap() to emulate a
+        click event.
+        (WebKit::GestureController::DragGesture::DragGesture): Initialize
+        the GtkGestureDrag.
+        (WebKit::GestureController::ZoomGesture::begin): Save the current
+        page scale factor and the center point of the gesture.
+        (WebKit::GestureController::ZoomGesture::scaleChanged): Schedule a
+        page scale change in an idle for the given scale value.
+        (WebKit::GestureController::ZoomGesture::ZoomGesture): Initialize
+        the GtkGestureZoom.
+        * UIProcess/gtk/GestureController.h: Added.
+
</ins><span class="cx"> 2014-10-19  Chris Dumez  &lt;cdumez@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Use is&lt;&gt;() / downcast&lt;&gt;() for all remaining RenderObject subclasses
</span></span></pre></div>
<a id="trunkSourceWebKit2PlatformGTKcmake"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/PlatformGTK.cmake (174879 => 174880)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/PlatformGTK.cmake        2014-10-20 08:23:26 UTC (rev 174879)
+++ trunk/Source/WebKit2/PlatformGTK.cmake        2014-10-20 08:44:19 UTC (rev 174880)
</span><span class="lines">@@ -253,6 +253,7 @@
</span><span class="cx"> 
</span><span class="cx">     UIProcess/gtk/DragAndDropHandler.cpp
</span><span class="cx">     UIProcess/gtk/ExperimentalFeatures.cpp
</span><ins>+    UIProcess/gtk/GestureController.cpp
</ins><span class="cx">     UIProcess/gtk/TextCheckerGtk.cpp
</span><span class="cx">     UIProcess/gtk/WebContextGtk.cpp
</span><span class="cx">     UIProcess/gtk/WebContextMenuProxyGtk.cpp
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPIgtkPageClientImplcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/gtk/PageClientImpl.cpp (174879 => 174880)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/gtk/PageClientImpl.cpp        2014-10-20 08:23:26 UTC (rev 174879)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/PageClientImpl.cpp        2014-10-20 08:44:19 UTC (rev 174880)
</span><span class="lines">@@ -340,6 +340,12 @@
</span><span class="cx">     if (wasEventHandled)
</span><span class="cx">         return;
</span><span class="cx"> 
</span><ins>+#if HAVE(GTK_GESTURES)
+    GestureController&amp; gestureController = webkitWebViewBaseGestureController(WEBKIT_WEB_VIEW_BASE(m_viewWidget));
+    if (gestureController.handleEvent(event.nativeEvent()))
+        return;
+#endif
+
</ins><span class="cx">     // Emulate pointer events if unhandled.
</span><span class="cx">     const GdkEvent* touchEvent = event.nativeEvent();
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPIgtkWebKitWebViewBasecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBase.cpp (174879 => 174880)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBase.cpp        2014-10-20 08:23:26 UTC (rev 174879)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBase.cpp        2014-10-20 08:44:19 UTC (rev 174880)
</span><span class="lines">@@ -138,6 +138,10 @@
</span><span class="cx"> #if ENABLE(DRAG_SUPPORT)
</span><span class="cx">     std::unique_ptr&lt;DragAndDropHandler&gt; dragAndDropHandler;
</span><span class="cx"> #endif
</span><ins>+
+#if HAVE(GTK_GESTURES)
+    std::unique_ptr&lt;GestureController&gt; gestureController;
+#endif
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> WEBKIT_DEFINE_TYPE(WebKitWebViewBase, webkit_web_view_base, GTK_TYPE_CONTAINER)
</span><span class="lines">@@ -777,14 +781,25 @@
</span><span class="cx"> 
</span><span class="cx"> static gboolean webkitWebViewBaseTouchEvent(GtkWidget* widget, GdkEventTouch* event)
</span><span class="cx"> {
</span><del>-    WebKitWebViewBasePrivate* priv = WEBKIT_WEB_VIEW_BASE(widget)-&gt;priv;
</del><ins>+    WebKitWebViewBase* webViewBase = WEBKIT_WEB_VIEW_BASE(widget);
+    WebKitWebViewBasePrivate* priv = webViewBase-&gt;priv;
</ins><span class="cx"> 
</span><span class="cx">     if (priv-&gt;authenticationDialog)
</span><span class="cx">         return TRUE;
</span><span class="cx"> 
</span><span class="cx">     GdkEvent* touchEvent = reinterpret_cast&lt;GdkEvent*&gt;(event);
</span><ins>+
+#if HAVE(GTK_GESTURES)
+    GestureController&amp; gestureController = webkitWebViewBaseGestureController(webViewBase);
+    if (gestureController.isProcessingGestures()) {
+        // If we are already processing gestures is because the WebProcess didn't handle the
+        // BEGIN touch event, so pass subsequent events to the GestureController.
+        gestureController.handleEvent(touchEvent);
+        return TRUE;
+    }
+#endif
+
</ins><span class="cx">     uint32_t sequence = GPOINTER_TO_UINT(gdk_event_get_event_sequence(touchEvent));
</span><del>-
</del><span class="cx">     switch (touchEvent-&gt;type) {
</span><span class="cx">     case GDK_TOUCH_BEGIN: {
</span><span class="cx">         ASSERT(!priv-&gt;touchEvents.contains(sequence));
</span><span class="lines">@@ -807,12 +822,22 @@
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     Vector&lt;WebPlatformTouchPoint&gt; touchPoints;
</span><del>-    webkitWebViewBaseGetTouchPointsForEvent(WEBKIT_WEB_VIEW_BASE(widget), touchEvent, touchPoints);
</del><ins>+    webkitWebViewBaseGetTouchPointsForEvent(webViewBase, touchEvent, touchPoints);
</ins><span class="cx">     priv-&gt;pageProxy-&gt;handleTouchEvent(NativeWebTouchEvent(reinterpret_cast&lt;GdkEvent*&gt;(event), touchPoints));
</span><span class="cx"> 
</span><span class="cx">     return TRUE;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+#if HAVE(GTK_GESTURES)
+GestureController&amp; webkitWebViewBaseGestureController(WebKitWebViewBase* webViewBase)
+{
+    WebKitWebViewBasePrivate* priv = webViewBase-&gt;priv;
+    if (!priv-&gt;gestureController)
+        priv-&gt;gestureController = std::make_unique&lt;GestureController&gt;(*priv-&gt;pageProxy);
+    return *priv-&gt;gestureController;
+}
+#endif
+
</ins><span class="cx"> static gboolean webkitWebViewBaseQueryTooltip(GtkWidget* widget, gint /* x */, gint /* y */, gboolean keyboardMode, GtkTooltip* tooltip)
</span><span class="cx"> {
</span><span class="cx">     WebKitWebViewBasePrivate* priv = WEBKIT_WEB_VIEW_BASE(widget)-&gt;priv;
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPIgtkWebKitWebViewBasePrivateh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBasePrivate.h (174879 => 174880)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBasePrivate.h        2014-10-20 08:23:26 UTC (rev 174879)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBasePrivate.h        2014-10-20 08:44:19 UTC (rev 174880)
</span><span class="lines">@@ -29,6 +29,7 @@
</span><span class="cx"> #define WebKitWebViewBasePrivate_h
</span><span class="cx"> 
</span><span class="cx"> #include &quot;DragAndDropHandler.h&quot;
</span><ins>+#include &quot;GestureController.h&quot;
</ins><span class="cx"> #include &quot;WebContextMenuProxyGtk.h&quot;
</span><span class="cx"> #include &quot;WebInspectorProxy.h&quot;
</span><span class="cx"> #include &quot;WebKitPrivate.h&quot;
</span><span class="lines">@@ -78,4 +79,8 @@
</span><span class="cx"> WebKit::DragAndDropHandler&amp; webkitWebViewBaseDragAndDropHandler(WebKitWebViewBase*);
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><ins>+#if HAVE(GTK_GESTURES)
+WebKit::GestureController&amp; webkitWebViewBaseGestureController(WebKitWebViewBase*);
+#endif
+
</ins><span class="cx"> #endif // WebKitWebViewBasePrivate_h
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessgtkGestureControllercpp"></a>
<div class="addfile"><h4>Added: trunk/Source/WebKit2/UIProcess/gtk/GestureController.cpp (0 => 174880)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/gtk/GestureController.cpp                                (rev 0)
+++ trunk/Source/WebKit2/UIProcess/gtk/GestureController.cpp        2014-10-20 08:44:19 UTC (rev 174880)
</span><span class="lines">@@ -0,0 +1,204 @@
</span><ins>+/*
+ * Copyright (C) 2014 Igalia S.L.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. 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 APPLE INC. AND ITS CONTRIBUTORS ``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 INC. OR ITS 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 &quot;config.h&quot;
+#include &quot;GestureController.h&quot;
+
+#if HAVE(GTK_GESTURES)
+
+#include &quot;NativeWebMouseEvent.h&quot;
+#include &quot;NativeWebWheelEvent.h&quot;
+#include &quot;WebPageProxy.h&quot;
+#include &lt;WebCore/FloatPoint.h&gt;
+#include &lt;WebCore/Scrollbar.h&gt;
+#include &lt;gtk/gtk.h&gt;
+
+using namespace WebCore;
+
+namespace WebKit {
+
+GestureController::GestureController(WebPageProxy&amp; page)
+    : m_dragGesture(page)
+    , m_zoomGesture(page)
+{
+}
+
+bool GestureController::handleEvent(const GdkEvent* event)
+{
+    bool wasProcessingGestures = isProcessingGestures();
+    m_dragGesture.handleEvent(event);
+    m_zoomGesture.handleEvent(event);
+    return event-&gt;type == GDK_TOUCH_END ? wasProcessingGestures : isProcessingGestures();
+}
+
+bool GestureController::isProcessingGestures() const
+{
+    return m_dragGesture.isActive() || m_zoomGesture.isActive();
+}
+
+GestureController::Gesture::Gesture(GtkGesture* gesture, WebPageProxy&amp; page)
+    : m_gesture(adoptGRef(gesture))
+    , m_page(page)
+{
+    gtk_event_controller_set_propagation_phase(GTK_EVENT_CONTROLLER(m_gesture.get()), GTK_PHASE_NONE);
+}
+
+bool GestureController::Gesture::isActive() const
+{
+    return gtk_gesture_is_active(m_gesture.get());
+}
+
+void GestureController::Gesture::handleEvent(const GdkEvent* event)
+{
+    gtk_event_controller_handle_event(GTK_EVENT_CONTROLLER(m_gesture.get()), event);
+}
+
+void GestureController::DragGesture::handleDrag(const GdkEvent* event, double x, double y)
+{
+    ASSERT(m_inDrag);
+    GUniquePtr&lt;GdkEvent&gt; scrollEvent(gdk_event_new(GDK_SCROLL));
+    scrollEvent-&gt;scroll.time = event-&gt;touch.time;
+    scrollEvent-&gt;scroll.x = m_start.x();
+    scrollEvent-&gt;scroll.y = m_start.y();
+    scrollEvent-&gt;scroll.x_root = event-&gt;touch.x_root;
+    scrollEvent-&gt;scroll.y_root = event-&gt;touch.y_root;
+    scrollEvent-&gt;scroll.direction = GDK_SCROLL_SMOOTH;
+    scrollEvent-&gt;scroll.delta_x = (m_offset.x() - x) / Scrollbar::pixelsPerLineStep();
+    scrollEvent-&gt;scroll.delta_y = (m_offset.y() - y) / Scrollbar::pixelsPerLineStep();
+    scrollEvent-&gt;scroll.state = event-&gt;touch.state;
+    m_page.handleWheelEvent(NativeWebWheelEvent(scrollEvent.get()));
+}
+
+void GestureController::DragGesture::handleTap(const GdkEvent* event)
+{
+    ASSERT(!m_inDrag);
+    GUniquePtr&lt;GdkEvent&gt; pointerEvent(gdk_event_new(GDK_MOTION_NOTIFY));
+    pointerEvent-&gt;motion.time = event-&gt;touch.time;
+    pointerEvent-&gt;motion.x = event-&gt;touch.x;
+    pointerEvent-&gt;motion.y = event-&gt;touch.y;
+    pointerEvent-&gt;motion.x_root = event-&gt;touch.x_root;
+    pointerEvent-&gt;motion.y_root = event-&gt;touch.y_root;
+    pointerEvent-&gt;motion.state = event-&gt;touch.state;
+    m_page.handleMouseEvent(NativeWebMouseEvent(pointerEvent.get(), 0));
+
+    pointerEvent.reset(gdk_event_new(GDK_BUTTON_PRESS));
+    pointerEvent-&gt;button.button = 1;
+    pointerEvent-&gt;button.time = event-&gt;touch.time;
+    pointerEvent-&gt;button.x = event-&gt;touch.x;
+    pointerEvent-&gt;button.y = event-&gt;touch.y;
+    pointerEvent-&gt;button.x_root = event-&gt;touch.x_root;
+    pointerEvent-&gt;button.y_root = event-&gt;touch.y_root;
+    m_page.handleMouseEvent(NativeWebMouseEvent(pointerEvent.get(), 1));
+
+    pointerEvent-&gt;type = GDK_BUTTON_RELEASE;
+    m_page.handleMouseEvent(NativeWebMouseEvent(pointerEvent.get(), 0));
+}
+
+void GestureController::DragGesture::begin(DragGesture* dragGesture, double x, double y, GtkGesture* gesture)
+{
+    GdkEventSequence* sequence = gtk_gesture_single_get_current_sequence(GTK_GESTURE_SINGLE(gesture));
+    gtk_gesture_set_sequence_state(gesture, sequence, GTK_EVENT_SEQUENCE_CLAIMED);
+    dragGesture-&gt;m_inDrag = false;
+    dragGesture-&gt;m_start.set(x, y);
+    dragGesture-&gt;m_offset.set(0, 0);
+
+    GtkWidget* widget = gtk_event_controller_get_widget(GTK_EVENT_CONTROLLER(gesture));
+    unsigned delay;
+    g_object_get(gtk_widget_get_settings(widget), &quot;gtk-long-press-time&quot;, &amp;delay, nullptr);
+    dragGesture-&gt;m_longPressTimeout.scheduleAfterDelay(&quot;[WebKit] DragGesture long press timeout&quot;, [dragGesture]() {
+        dragGesture-&gt;m_inDrag = true;
+    }, std::chrono::milliseconds(delay));
+}
+
+void GestureController::DragGesture::update(DragGesture* dragGesture, double x, double y, GtkGesture* gesture)
+{
+    GdkEventSequence* sequence = gtk_gesture_single_get_current_sequence(GTK_GESTURE_SINGLE(gesture));
+    gtk_gesture_set_sequence_state(gesture, sequence, GTK_EVENT_SEQUENCE_CLAIMED);
+
+    GtkWidget* widget = gtk_event_controller_get_widget(GTK_EVENT_CONTROLLER(gesture));
+    if (!dragGesture-&gt;m_inDrag &amp;&amp; gtk_drag_check_threshold(widget, dragGesture-&gt;m_start.x(), dragGesture-&gt;m_start.y(), dragGesture-&gt;m_start.x() + x, dragGesture-&gt;m_start.y() + y)) {
+        dragGesture-&gt;m_inDrag = true;
+        dragGesture-&gt;m_longPressTimeout.cancel();
+    }
+
+    if (dragGesture-&gt;m_inDrag)
+        dragGesture-&gt;handleDrag(gtk_gesture_get_last_event(gesture, sequence), x, y);
+    dragGesture-&gt;m_offset.set(x, y);
+}
+
+void GestureController::DragGesture::end(DragGesture* dragGesture, GdkEventSequence* sequence, GtkGesture* gesture)
+{
+    dragGesture-&gt;m_longPressTimeout.cancel();
+    if (!dragGesture-&gt;m_inDrag) {
+        dragGesture-&gt;handleTap(gtk_gesture_get_last_event(gesture, sequence));
+        gtk_gesture_set_state(gesture, GTK_EVENT_SEQUENCE_DENIED);
+    } else if (!gtk_gesture_handles_sequence(gesture, sequence))
+        gtk_gesture_set_state(gesture, GTK_EVENT_SEQUENCE_DENIED);
+}
+
+GestureController::DragGesture::DragGesture(WebPageProxy&amp; page)
+    : Gesture(gtk_gesture_drag_new(page.viewWidget()), page)
+    , m_inDrag(false)
+{
+    gtk_gesture_single_set_touch_only(GTK_GESTURE_SINGLE(m_gesture.get()), TRUE);
+    g_signal_connect_swapped(m_gesture.get(), &quot;drag-begin&quot;, G_CALLBACK(begin), this);
+    g_signal_connect_swapped(m_gesture.get(), &quot;drag-update&quot;, G_CALLBACK(update), this);
+    g_signal_connect_swapped(m_gesture.get(), &quot;end&quot;, G_CALLBACK(end), this);
+}
+
+void GestureController::ZoomGesture::begin(ZoomGesture* zoomGesture, GdkEventSequence*, GtkGesture* gesture)
+{
+    gtk_gesture_set_state(gesture, GTK_EVENT_SEQUENCE_CLAIMED);
+
+    zoomGesture-&gt;m_initialScale = zoomGesture-&gt;m_page.pageScaleFactor();
+    double x, y;
+    gtk_gesture_get_bounding_box_center(gesture, &amp;x, &amp;y);
+    zoomGesture-&gt;m_point = IntPoint(x, y);
+}
+
+void GestureController::ZoomGesture::scaleChanged(ZoomGesture* zoomGesture, double scale, GtkGesture*)
+{
+    zoomGesture-&gt;m_scale = zoomGesture-&gt;m_initialScale * scale;
+    if (zoomGesture-&gt;m_idle.isScheduled())
+        return;
+
+    zoomGesture-&gt;m_idle.schedule(&quot;[WebKit] Zoom Gesture Idle&quot;, [zoomGesture]() {
+        // FIXME: Zoomed area is not correctly centered.
+        zoomGesture-&gt;m_page.scalePage(zoomGesture-&gt;m_scale, zoomGesture-&gt;m_point);
+    });
+}
+
+GestureController::ZoomGesture::ZoomGesture(WebPageProxy&amp; page)
+    : Gesture(gtk_gesture_zoom_new(page.viewWidget()), page)
+    , m_initialScale(0)
+    , m_scale(0)
+{
+    g_signal_connect_swapped(m_gesture.get(), &quot;begin&quot;, G_CALLBACK(begin), this);
+    g_signal_connect_swapped(m_gesture.get(), &quot;scale-changed&quot;, G_CALLBACK(scaleChanged), this);
+}
+
+} // namespace WebKit
+
+#endif // HAVE(GTK_GESTURES)
</ins></span></pre></div>
<a id="trunkSourceWebKit2UIProcessgtkGestureControllerh"></a>
<div class="addfile"><h4>Added: trunk/Source/WebKit2/UIProcess/gtk/GestureController.h (0 => 174880)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/gtk/GestureController.h                                (rev 0)
+++ trunk/Source/WebKit2/UIProcess/gtk/GestureController.h        2014-10-20 08:44:19 UTC (rev 174880)
</span><span class="lines">@@ -0,0 +1,106 @@
</span><ins>+/*
+ * Copyright (C) 2014 Igalia S.L.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. 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 APPLE INC. AND ITS CONTRIBUTORS ``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 INC. OR ITS 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 GestureController_h
+#define GestureController_h
+
+#if HAVE(GTK_GESTURES)
+
+#include &lt;WebCore/FloatPoint.h&gt;
+#include &lt;wtf/Noncopyable.h&gt;
+#include &lt;wtf/gobject/GMainLoopSource.h&gt;
+#include &lt;wtf/gobject/GRefPtr.h&gt;
+
+typedef union _GdkEvent GdkEvent;
+typedef struct _GdkEventSequence GdkEventSequence;
+typedef struct _GtkGesture GtkGesture;
+
+namespace WebKit {
+class WebPageProxy;
+
+class GestureController {
+    WTF_MAKE_NONCOPYABLE(GestureController);
+
+public:
+    GestureController(WebPageProxy&amp;);
+
+    bool isProcessingGestures() const;
+    bool handleEvent(const GdkEvent*);
+
+private:
+    class Gesture {
+    public:
+        bool isActive() const;
+        void handleEvent(const GdkEvent*);
+
+    protected:
+        Gesture(GtkGesture*, WebPageProxy&amp;);
+
+        GRefPtr&lt;GtkGesture&gt; m_gesture;
+        WebPageProxy&amp; m_page;
+    };
+
+    class DragGesture final : public Gesture {
+    public:
+        DragGesture(WebPageProxy&amp;);
+
+    private:
+        void handleDrag(const GdkEvent*, double x, double y);
+        void handleTap(const GdkEvent*);
+
+        static void begin(DragGesture*, double x, double y, GtkGesture*);
+        static void update(DragGesture*, double x, double y, GtkGesture*);
+        static void end(DragGesture*, GdkEventSequence*, GtkGesture*);
+
+        WebCore::FloatPoint m_start;
+        WebCore::FloatPoint m_offset;
+        GMainLoopSource m_longPressTimeout;
+        GRefPtr&lt;GtkGesture&gt; m_longPress;
+        bool m_inDrag;
+    };
+
+    class ZoomGesture final : public Gesture {
+    public:
+        ZoomGesture(WebPageProxy&amp;);
+
+    private:
+        static void begin(ZoomGesture*, GdkEventSequence*, GtkGesture*);
+        static void scaleChanged(ZoomGesture*, double scale, GtkGesture*);
+
+        gdouble m_initialScale;
+        gdouble m_scale;
+        WebCore::IntPoint m_point;
+        GMainLoopSource m_idle;
+    };
+
+    DragGesture m_dragGesture;
+    ZoomGesture m_zoomGesture;
+};
+
+} // namespace WebKit
+
+#endif // HAVE(GTK_GESTURES)
+
+#endif // GestureController_h
</ins></span></pre></div>
<a id="trunkSourcecmakeFindGTK3cmake"></a>
<div class="modfile"><h4>Modified: trunk/Source/cmake/FindGTK3.cmake (174879 => 174880)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/cmake/FindGTK3.cmake        2014-10-20 08:23:26 UTC (rev 174879)
+++ trunk/Source/cmake/FindGTK3.cmake        2014-10-20 08:44:19 UTC (rev 174880)
</span><span class="lines">@@ -64,5 +64,11 @@
</span><span class="cx">         &quot;be enabled and also supported by the GTK+ dependency: X11, Wayland&quot;)
</span><span class="cx"> endif ()
</span><span class="cx"> 
</span><ins>+if (GTK3_VERSION AND VERSION_OK AND NOT(&quot;${GTK3_VERSION}&quot; VERSION_LESS &quot;3.14.0&quot;))
+    set(GTK_SUPPORTS_GESTURES ON)
+else ()
+    set(GTK_SUPPORTS_GESTURES OFF)
+endif ()
+
</ins><span class="cx"> include(FindPackageHandleStandardArgs)
</span><span class="cx"> FIND_PACKAGE_HANDLE_STANDARD_ARGS(GTK3 DEFAULT_MSG GTK3_INCLUDE_DIRS GTK3_LIBRARIES VERSION_OK)
</span></span></pre></div>
<a id="trunkSourcecmakeOptionsGTKcmake"></a>
<div class="modfile"><h4>Modified: trunk/Source/cmake/OptionsGTK.cmake (174879 => 174880)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/cmake/OptionsGTK.cmake        2014-10-20 08:23:26 UTC (rev 174879)
+++ trunk/Source/cmake/OptionsGTK.cmake        2014-10-20 08:44:19 UTC (rev 174880)
</span><span class="lines">@@ -261,6 +261,10 @@
</span><span class="cx">     set(ENABLE_CREDENTIAL_STORAGE 1)
</span><span class="cx"> endif ()
</span><span class="cx"> 
</span><ins>+if (GTK_SUPPORTS_GESTURES)
+    add_definitions(-DHAVE_GTK_GESTURES=1)
+endif ()
+
</ins><span class="cx"> # This part can be simplified once CMake 2.8.6 is required and
</span><span class="cx"> # CMakePushCheckState can be used. We need to have OPENGL_INCLUDE_DIR as part
</span><span class="cx"> # of the directories check_include_files() looks for in case OpenGL is
</span></span></pre>
</div>
</div>

</body>
</html>