Title: [177148] trunk/Source
Revision
177148
Author
[email protected]
Date
2014-12-11 09:07:42 -0800 (Thu, 11 Dec 2014)

Log Message

[GTK] Move click counter logic back to WebKitWebViewBase
https://bugs.webkit.org/show_bug.cgi?id=137685

Reviewed by Martin Robinson.

Source/WebCore:

Remove GtkClickCounter.

* PlatformGTK.cmake:
* platform/gtk/GtkClickCounter.cpp: Removed.
* platform/gtk/GtkClickCounter.h: Removed.

Source/WebKit2:

It was moved to a shared class in platform to be used by both
WebKit1 and WebKit2, but it's currently only used by WebKitWebViewBase.

* UIProcess/API/gtk/WebKitWebViewBase.cpp:
(ClickCounter::reset):
(ClickCounter::currentClickCountForGdkButtonEvent):
(webkitWebViewBaseButtonPressEvent):

Modified Paths

Removed Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (177147 => 177148)


--- trunk/Source/WebCore/ChangeLog	2014-12-11 17:02:46 UTC (rev 177147)
+++ trunk/Source/WebCore/ChangeLog	2014-12-11 17:07:42 UTC (rev 177148)
@@ -1,5 +1,18 @@
 2014-12-11  Carlos Garcia Campos  <[email protected]>
 
+        [GTK] Move click counter logic back to WebKitWebViewBase
+        https://bugs.webkit.org/show_bug.cgi?id=137685
+
+        Reviewed by Martin Robinson.
+
+        Remove GtkClickCounter.
+
+        * PlatformGTK.cmake:
+        * platform/gtk/GtkClickCounter.cpp: Removed.
+        * platform/gtk/GtkClickCounter.h: Removed.
+
+2014-12-11  Carlos Garcia Campos  <[email protected]>
+
         [GTK] Implement sizes attribute for link tag
         https://bugs.webkit.org/show_bug.cgi?id=125775
 

Modified: trunk/Source/WebCore/PlatformGTK.cmake (177147 => 177148)


--- trunk/Source/WebCore/PlatformGTK.cmake	2014-12-11 17:02:46 UTC (rev 177147)
+++ trunk/Source/WebCore/PlatformGTK.cmake	2014-12-11 17:07:42 UTC (rev 177148)
@@ -223,7 +223,6 @@
     platform/gtk/DragIcon.cpp
     platform/gtk/DragImageGtk.cpp
     platform/gtk/GRefPtrGtk.cpp
-    platform/gtk/GtkClickCounter.cpp
     platform/gtk/GtkUtilities.cpp
     platform/gtk/GtkVersioning.c
     platform/gtk/KeyBindingTranslator.cpp

Deleted: trunk/Source/WebCore/platform/gtk/GtkClickCounter.cpp (177147 => 177148)


--- trunk/Source/WebCore/platform/gtk/GtkClickCounter.cpp	2014-12-11 17:02:46 UTC (rev 177147)
+++ trunk/Source/WebCore/platform/gtk/GtkClickCounter.cpp	2014-12-11 17:07:42 UTC (rev 177148)
@@ -1,105 +0,0 @@
-/*
- * Copyright (C) 2010, 2011 Igalia S.L.
- *
- *  This library is free software; you can redistribute it and/or
- *  modify it under the terms of the GNU Lesser General Public
- *  License as published by the Free Software Foundation; either
- *  version 2 of the License, or (at your option) any later version.
- *
- *  This library is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- *  Lesser General Public License for more details.
- *
- *  You should have received a copy of the GNU Lesser General Public
- *  License along with this library; if not, write to the Free Software
- *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- */
-
-#include "config.h"
-#include "GtkClickCounter.h"
-
-#include "GUniquePtrGtk.h"
-#include <gtk/gtk.h>
-
-namespace WebCore {
-
-GtkClickCounter::GtkClickCounter()
-    : m_currentClickCount(0)
-    , m_previousClickButton(0)
-    , m_previousClickTime(0)
-{
-}
-
-void GtkClickCounter::reset()
-{
-    m_currentClickCount = 0;
-    m_previousClickPoint = IntPoint();
-    m_previousClickTime = 0;
-    m_previousClickButton = 0;
-}
-
-bool GtkClickCounter::shouldProcessButtonEvent(GdkEventButton*)
-{
-    // For double and triple clicks GDK sends both a normal button press event
-    // and a specific type (like GDK_2BUTTON_PRESS). If we detect a special press
-    // coming up, ignore this event as it certainly generated the double or triple
-    // click. The consequence of not eating this event is two DOM button press events
-    // are generated.
-    GUniquePtr<GdkEvent> nextEvent(gdk_event_peek());
-    if (!nextEvent)
-        return true;
-    if (nextEvent->any.type == GDK_2BUTTON_PRESS || nextEvent->any.type == GDK_3BUTTON_PRESS)
-        return false;
-    return true;
-}
-
-static guint32 getEventTime(GdkEvent* event)
-{
-    guint32 time = gdk_event_get_time(event);
-    if (time)
-        return time;
-
-    // Real events always have a non-zero time, but events synthesized
-    // by the DRT do not and we must calculate a time manually. This time
-    // is not calculated in the DRT, because GTK+ does not work well with
-    // anything other than GDK_CURRENT_TIME on synthesized events.
-    GTimeVal timeValue;
-    g_get_current_time(&timeValue);
-    return (timeValue.tv_sec * 1000) + (timeValue.tv_usec / 1000);
-}
-
-int GtkClickCounter::clickCountForGdkButtonEvent(GtkWidget* widget, GdkEventButton* buttonEvent)
-{
-    gint doubleClickDistance = 250;
-    gint doubleClickTime = 5;
-    GtkSettings* settings = gtk_settings_get_for_screen(gtk_widget_get_screen(widget));
-    g_object_get(settings,
-                 "gtk-double-click-distance", &doubleClickDistance,
-                 "gtk-double-click-time", &doubleClickTime, NULL);
-
-    // GTK+ only counts up to triple clicks, but WebCore wants to know about
-    // quadruple clicks, quintuple clicks, ad infinitum. Here, we replicate the
-    // GDK logic for counting clicks.
-    GdkEvent* event(reinterpret_cast<GdkEvent*>(buttonEvent));
-    guint32 eventTime = getEventTime(event);
-
-    if ((event->type == GDK_2BUTTON_PRESS || event->type == GDK_3BUTTON_PRESS)
-        || ((abs(buttonEvent->x - m_previousClickPoint.x()) < doubleClickDistance)
-            && (abs(buttonEvent->y - m_previousClickPoint.y()) < doubleClickDistance)
-            && (eventTime - m_previousClickTime < static_cast<guint>(doubleClickTime))
-            && (buttonEvent->button == m_previousClickButton)))
-        m_currentClickCount++;
-    else
-        m_currentClickCount = 1;
-
-    gdouble x, y;
-    gdk_event_get_coords(event, &x, &y);
-    m_previousClickPoint = IntPoint(x, y);
-    m_previousClickButton = buttonEvent->button;
-    m_previousClickTime = eventTime;
-
-    return m_currentClickCount;
-}
-
-} // namespace WebCore

Deleted: trunk/Source/WebCore/platform/gtk/GtkClickCounter.h (177147 => 177148)


--- trunk/Source/WebCore/platform/gtk/GtkClickCounter.h	2014-12-11 17:02:46 UTC (rev 177147)
+++ trunk/Source/WebCore/platform/gtk/GtkClickCounter.h	2014-12-11 17:07:42 UTC (rev 177148)
@@ -1,45 +0,0 @@
-/*
- * Copyright (C) 2010, 2011 Igalia S.L.
- *
- *  This library is free software; you can redistribute it and/or
- *  modify it under the terms of the GNU Lesser General Public
- *  License as published by the Free Software Foundation; either
- *  version 2 of the License, or (at your option) any later version.
- *
- *  This library is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- *  Lesser General Public License for more details.
- *
- *  You should have received a copy of the GNU Lesser General Public
- *  License along with this library; if not, write to the Free Software
- *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- */
-
-#ifndef GtkClickCounter_h
-#define GtkClickCounter_h
-
-#include "IntPoint.h"
-
-typedef struct _GdkEventButton GdkEventButton;
-
-namespace WebCore {
-
-class GtkClickCounter {
-public:
-    GtkClickCounter();
-    void reset();
-    bool shouldProcessButtonEvent(GdkEventButton*);
-    int clickCountForGdkButtonEvent(GtkWidget*, GdkEventButton*);
-
-private:
-    int m_currentClickCount;
-    IntPoint m_previousClickPoint;
-    unsigned int m_previousClickButton;
-    int m_previousClickTime;
-};
-
-} // namespace WebCore
-
-#endif
-

Modified: trunk/Source/WebKit2/ChangeLog (177147 => 177148)


--- trunk/Source/WebKit2/ChangeLog	2014-12-11 17:02:46 UTC (rev 177147)
+++ trunk/Source/WebKit2/ChangeLog	2014-12-11 17:07:42 UTC (rev 177148)
@@ -1,3 +1,18 @@
+2014-12-11  Carlos Garcia Campos  <[email protected]>
+
+        [GTK] Move click counter logic back to WebKitWebViewBase
+        https://bugs.webkit.org/show_bug.cgi?id=137685
+
+        Reviewed by Martin Robinson.
+
+        It was moved to a shared class in platform to be used by both
+        WebKit1 and WebKit2, but it's currently only used by WebKitWebViewBase.
+
+        * UIProcess/API/gtk/WebKitWebViewBase.cpp:
+        (ClickCounter::reset):
+        (ClickCounter::currentClickCountForGdkButtonEvent):
+        (webkitWebViewBaseButtonPressEvent):
+
 2014-12-11  Carlos Alberto Lopez Perez  <[email protected]>
 
         [SOUP] [GTK] warning: unused parameter at NetworkProcessSoup.cpp after r177056.

Modified: trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBase.cpp (177147 => 177148)


--- trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBase.cpp	2014-12-11 17:02:46 UTC (rev 177147)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBase.cpp	2014-12-11 17:07:42 UTC (rev 177148)
@@ -50,7 +50,6 @@
 #include "WebUserContentControllerProxy.h"
 #include <WebCore/CairoUtilities.h>
 #include <WebCore/GUniquePtrGtk.h>
-#include <WebCore/GtkClickCounter.h>
 #include <WebCore/GtkUtilities.h>
 #include <WebCore/GtkVersioning.h>
 #include <WebCore/NotImplemented.h>
@@ -78,6 +77,63 @@
 using namespace WebKit;
 using namespace WebCore;
 
+struct ClickCounter {
+public:
+    void reset()
+    {
+        currentClickCount = 0;
+        previousClickPoint = IntPoint();
+        previousClickTime = 0;
+        previousClickButton = 0;
+    }
+
+    int currentClickCountForGdkButtonEvent(GdkEventButton* buttonEvent)
+    {
+        GdkEvent* event = reinterpret_cast<GdkEvent*>(buttonEvent);
+        int doubleClickDistance = 250;
+        int doubleClickTime = 5;
+        g_object_get(gtk_settings_get_for_screen(gdk_event_get_screen(event)),
+            "gtk-double-click-distance", &doubleClickDistance, "gtk-double-click-time", &doubleClickTime, nullptr);
+
+        // GTK+ only counts up to triple clicks, but WebCore wants to know about
+        // quadruple clicks, quintuple clicks, ad infinitum. Here, we replicate the
+        // GDK logic for counting clicks.
+        guint32 eventTime = gdk_event_get_time(event);
+        if (!eventTime) {
+            // Real events always have a non-zero time, but events synthesized
+            // by the WTR do not and we must calculate a time manually. This time
+            // is not calculated in the WTR, because GTK+ does not work well with
+            // anything other than GDK_CURRENT_TIME on synthesized events.
+            GTimeVal timeValue;
+            g_get_current_time(&timeValue);
+            eventTime = (timeValue.tv_sec * 1000) + (timeValue.tv_usec / 1000);
+        }
+
+        if ((event->type == GDK_2BUTTON_PRESS || event->type == GDK_3BUTTON_PRESS)
+            || ((abs(buttonEvent->x - previousClickPoint.x()) < doubleClickDistance)
+                && (abs(buttonEvent->y - previousClickPoint.y()) < doubleClickDistance)
+                && (eventTime - previousClickTime < static_cast<unsigned>(doubleClickTime))
+                && (buttonEvent->button == previousClickButton)))
+            currentClickCount++;
+        else
+            currentClickCount = 1;
+
+        double x, y;
+        gdk_event_get_coords(event, &x, &y);
+        previousClickPoint = IntPoint(x, y);
+        previousClickButton = buttonEvent->button;
+        previousClickTime = eventTime;
+
+        return currentClickCount;
+    }
+
+private:
+    int currentClickCount;
+    IntPoint previousClickPoint;
+    unsigned previousClickButton;
+    int previousClickTime;
+};
+
 typedef HashMap<GtkWidget*, IntRect> WebKitWebViewChildrenMap;
 typedef HashMap<uint32_t, GUniquePtr<GdkEvent>> TouchEventsMap;
 
@@ -86,7 +142,7 @@
     std::unique_ptr<PageClientImpl> pageClient;
     RefPtr<WebPageProxy> pageProxy;
     bool shouldForwardNextKeyEvent;
-    GtkClickCounter clickCounter;
+    ClickCounter clickCounter;
     CString tooltipText;
     IntRect tooltipArea;
 #if !GTK_CHECK_VERSION(3, 13, 4)
@@ -702,14 +758,21 @@
 
     priv->inputMethodFilter.notifyMouseButtonPress();
 
-    if (!priv->clickCounter.shouldProcessButtonEvent(buttonEvent))
+    // For double and triple clicks GDK sends both a normal button press event
+    // and a specific type (like GDK_2BUTTON_PRESS). If we detect a special press
+    // coming up, ignore this event as it certainly generated the double or triple
+    // click. The consequence of not eating this event is two DOM button press events
+    // are generated.
+    GUniquePtr<GdkEvent> nextEvent(gdk_event_peek());
+    if (nextEvent && (nextEvent->any.type == GDK_2BUTTON_PRESS || nextEvent->any.type == GDK_3BUTTON_PRESS))
         return TRUE;
 
     // If it's a right click event save it as a possible context menu event.
     if (buttonEvent->button == 3)
         priv->contextMenuEvent.reset(gdk_event_copy(reinterpret_cast<GdkEvent*>(buttonEvent)));
+
     priv->pageProxy->handleMouseEvent(NativeWebMouseEvent(reinterpret_cast<GdkEvent*>(buttonEvent),
-                                                     priv->clickCounter.clickCountForGdkButtonEvent(widget, buttonEvent)));
+        priv->clickCounter.currentClickCountForGdkButtonEvent(buttonEvent)));
     return TRUE;
 }
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to