2010-06-16 Martin Robinson <mrobinson@igalia.com>
authormrobinson@webkit.org <mrobinson@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 16 Jun 2010 22:26:35 +0000 (22:26 +0000)
committermrobinson@webkit.org <mrobinson@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 16 Jun 2010 22:26:35 +0000 (22:26 +0000)
        Reviewed by Gustavo Noronha Silva.

        [GTK] Remove the abuse of GDK_CURRENT_TIME in the DRT
        https://bugs.webkit.org/show_bug.cgi?id=40600

        * platform/gtk/Skipped: This change exposed some failures which were previously not reported. Skip them.
2010-06-16  Martin Robinson  <mrobinson@igalia.com>

        Reviewed by Gustavo Noronha Silva.

        [GTK] Remove the abuse of GDK_CURRENT_TIME in the DRT
        https://bugs.webkit.org/show_bug.cgi?id=40600

        * WebCoreSupport/DragClientGtk.cpp:
        (WebKit::DragClient::startDrag): Reset the click count after a drag starts.
        * WebCoreSupport/FrameLoaderClientGtk.cpp:
        (WebKit::postCommitFrameViewSetup): Reset the click count after a load is committed.
        * webkit/webkitprivate.h: Move static click counting variables to be per-view.
        * webkit/webkitwebview.cpp:
        (getEventTime): Added.
        (webkit_web_view_button_press_event): If the event time is zero, use the current time.
        (webkit_web_view_finalize): Clean up click counting member.
        (webkit_web_view_init): Initialize click counting member.
2010-06-16  Martin Robinson  <mrobinson@igalia.com>

        Reviewed by Gustavo Noronha Silva.

        [GTK] Remove the abuse of GDK_CURRENT_TIME in the DRT
        https://bugs.webkit.org/show_bug.cgi?id=40600

        * DumpRenderTree/gtk/EventSender.cpp:
        (prepareMouseButtonEvent): Remove logic adding an offset to GDK_CURRENT_TIME.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@61288 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/platform/gtk/Skipped
WebKit/gtk/ChangeLog
WebKit/gtk/WebCoreSupport/DragClientGtk.cpp
WebKit/gtk/WebCoreSupport/FrameLoaderClientGtk.cpp
WebKit/gtk/webkit/webkitprivate.h
WebKit/gtk/webkit/webkitwebview.cpp
WebKitTools/ChangeLog
WebKitTools/DumpRenderTree/gtk/EventSender.cpp

index c6073e3..b7b8506 100644 (file)
@@ -1,3 +1,12 @@
+2010-06-16  Martin Robinson  <mrobinson@igalia.com>
+
+        Reviewed by Gustavo Noronha Silva.
+
+        [GTK] Remove the abuse of GDK_CURRENT_TIME in the DRT
+        https://bugs.webkit.org/show_bug.cgi?id=40600
+
+        * platform/gtk/Skipped: This change exposed some failures which were previously not reported. Skip them.
+
 2010-06-16  Adam Barth  <abarth@webkit.org>
 
         Reviewed by Eric Seidel.
index ee45148..8f01585 100644 (file)
@@ -5931,3 +5931,10 @@ printing/page-rule-selection.html
 # HTML5 Lexer in r61234.
 # https://bugs.webkit.org/show_bug.cgi?id=40664
 inspector/timeline-script-tag-1.html
+
+# Tests failing because the context menu is grabbing mouse events.
+# https://bugs.webkit.org/show_bug.cgi?id=40601
+fast/events/mouse-click-events.html
+fast/events/right-click-focus.html
+editing/selection/5354455-1.html
+editing/selection/5354455-2.html
index 505f5cc..f9fb250 100644 (file)
@@ -1,3 +1,21 @@
+2010-06-16  Martin Robinson  <mrobinson@igalia.com>
+
+        Reviewed by Gustavo Noronha Silva.
+
+        [GTK] Remove the abuse of GDK_CURRENT_TIME in the DRT
+        https://bugs.webkit.org/show_bug.cgi?id=40600
+
+        * WebCoreSupport/DragClientGtk.cpp: 
+        (WebKit::DragClient::startDrag): Reset the click count after a drag starts.
+        * WebCoreSupport/FrameLoaderClientGtk.cpp:
+        (WebKit::postCommitFrameViewSetup): Reset the click count after a load is committed.
+        * webkit/webkitprivate.h: Move static click counting variables to be per-view.
+        * webkit/webkitwebview.cpp: 
+        (getEventTime): Added.
+        (webkit_web_view_button_press_event): If the event time is zero, use the current time.
+        (webkit_web_view_finalize): Clean up click counting member.
+        (webkit_web_view_init): Initialize click counting member.
+
 2010-06-15  Xan Lopez  <xlopez@igalia.com>
 
         Fix compilation with older GTK+.
index 6c395c7..4bcc4c2 100644 (file)
@@ -79,6 +79,10 @@ void DragClient::startDrag(DragImageRef image, const IntPoint& dragImageOrigin,
     GdkDragContext* context = gtk_drag_begin(GTK_WIDGET(m_webView), targetList.get(), dragOperationToGdkDragActions(clipboard->sourceOperation()), 1, currentEvent.get());
     webView->priv->draggingDataObjects.set(context, dataObject);
 
+    // A drag starting should prevent a double-click from happening. This might
+    // happen if a drag is followed very quickly by another click (like in the DRT).
+    webView->priv->previousClickTime = 0;
+
     if (image)
         gtk_drag_set_icon_pixbuf(context, image, eventPos.x() - dragImageOrigin.x(), eventPos.y() - dragImageOrigin.y());
     else
index 021374c..17a3cd5 100644 (file)
@@ -1145,6 +1145,9 @@ static void postCommitFrameViewSetup(WebKitWebFrame *frame, FrameView *view, boo
         gtk_menu_popdown(menu);
         g_object_unref(menu);
     }
+
+    // Do not allow click counting between main frame loads.
+    priv->previousClickTime = 0;
 }
 
 void FrameLoaderClient::transitionToCommittedFromCachedFrame(CachedFrame* cachedFrame)
index 44ffc1e..556648d 100644 (file)
@@ -56,6 +56,7 @@
 #include "Page.h"
 #include "Frame.h"
 #include "InspectorClientGtk.h"
+#include "IntPoint.h"
 #include "FrameLoaderClient.h"
 #include "ResourceHandle.h"
 #include "ResourceRequest.h"
@@ -152,6 +153,11 @@ extern "C" {
         GHashTable* subResources;
         char* tooltipText;
 
+        int currentClickCount;
+        WebCore::IntPoint* previousClickPoint;
+        guint previousClickButton;
+        guint32 previousClickTime;
+
         HashMap<GdkDragContext*, RefPtr<WebCore::DataObjectGtk> > draggingDataObjects;
     };
 
index f0e484d..f33e5b3 100644 (file)
@@ -587,16 +587,25 @@ static gboolean webkit_web_view_key_release_event(GtkWidget* widget, GdkEventKey
     return GTK_WIDGET_CLASS(webkit_web_view_parent_class)->key_release_event(widget, event);
 }
 
-static gboolean webkit_web_view_button_press_event(GtkWidget* widget, GdkEventButton* event)
+static guint32 getEventTime(GdkEvent* event)
 {
-    // Eventually it may make sense for these to be per-view and per-device,
-    // but at this time the implementation matches the Windows port.
-    static int currentClickCount = 1;
-    static IntPoint previousPoint;
-    static guint previousButton;
-    static guint32 previousTime;
+    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);
+} 
 
+static gboolean webkit_web_view_button_press_event(GtkWidget* widget, GdkEventButton* event)
+{
     WebKitWebView* webView = WEBKIT_WEB_VIEW(widget);
+    WebKitWebViewPrivate* priv = webView->priv;
 
     // FIXME: need to keep track of subframe focus for key events
     gtk_widget_grab_focus(widget);
@@ -620,20 +629,21 @@ static gboolean webkit_web_view_button_press_event(GtkWidget* widget, GdkEventBu
     // 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 = getEventTime(reinterpret_cast<GdkEvent*>(event));
     if ((event->type == GDK_2BUTTON_PRESS || event->type == GDK_3BUTTON_PRESS)
-        || ((abs(event->x - previousPoint.x()) < doubleClickDistance)
-            && (abs(event->y - previousPoint.y()) < doubleClickDistance)
-            && (event->time - previousTime < static_cast<guint>(doubleClickTime))
-            && (event->button == previousButton)))
-        currentClickCount++;
+        || ((abs(event->x - priv->previousClickPoint->x()) < doubleClickDistance)
+            && (abs(event->y - priv->previousClickPoint->y()) < doubleClickDistance)
+            && (eventTime - priv->previousClickTime < static_cast<guint>(doubleClickTime))
+            && (event->button == priv->previousClickButton)))
+        priv->currentClickCount++;
     else
-        currentClickCount = 1;
+        priv->currentClickCount = 1;
 
     PlatformMouseEvent platformEvent(event);
-    platformEvent.setClickCount(currentClickCount);
-    previousPoint = platformEvent.pos();
-    previousButton = event->button;
-    previousTime = event->time;
+    platformEvent.setClickCount(priv->currentClickCount);
+    *priv->previousClickPoint = platformEvent.pos();
+    priv->previousClickButton = event->button;
+    priv->previousClickTime = eventTime;
 
     if (event->button == 3)
         return webkit_web_view_forward_context_menu_event(webView, PlatformMouseEvent(event));
@@ -1196,6 +1206,8 @@ static void webkit_web_view_finalize(GObject* object)
     g_free(priv->customEncoding);
     g_free(priv->iconURI);
 
+    delete priv->previousClickPoint;
+
     G_OBJECT_CLASS(webkit_web_view_parent_class)->finalize(object);
 }
 
@@ -2912,6 +2924,10 @@ static void webkit_web_view_init(WebKitWebView* webView)
     priv->subResources = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_object_unref);
 
     priv->tooltipText = 0;
+    priv->currentClickCount = 0;
+    priv->previousClickPoint = new IntPoint(0, 0);
+    priv->previousClickButton = 0;
+    priv->previousClickTime = 0;
 }
 
 GtkWidget* webkit_web_view_new(void)
index 49f6afe..e60138b 100644 (file)
@@ -1,3 +1,13 @@
+2010-06-16  Martin Robinson  <mrobinson@igalia.com>
+
+        Reviewed by Gustavo Noronha Silva.
+
+        [GTK] Remove the abuse of GDK_CURRENT_TIME in the DRT
+        https://bugs.webkit.org/show_bug.cgi?id=40600
+
+        * DumpRenderTree/gtk/EventSender.cpp:
+        (prepareMouseButtonEvent): Remove logic adding an offset to GDK_CURRENT_TIME.
+
 2010-06-16  Adam Barth  <abarth@webkit.org>
 
         Reviewed by Dimitri Glazkov.
index f3799fb..a7adee0 100644 (file)
@@ -148,12 +148,7 @@ bool prepareMouseButtonEvent(GdkEvent* event, int eventSenderButtonNumber)
     event->button.window = GTK_WIDGET(view)->window;
     event->button.device = gdk_device_get_core_pointer();
     event->button.state = getStateFlags();
-
-    // Mouse up & down events dispatched via g_signal_emit_by_name must offset
-    // their time value, so that WebKit can detect where sequences of mouse
-    // clicks begin and end. This should not interfere with GDK or GTK+ event
-    // processing, because the event is only seen by the widget.
-    event->button.time = GDK_CURRENT_TIME + timeOffset;
+    event->button.time = GDK_CURRENT_TIME;
 
     int xRoot, yRoot;
 #if GTK_CHECK_VERSION(2, 17, 3)