Title: [108628] trunk
Revision
108628
Author
[email protected]
Date
2012-02-23 07:57:52 -0800 (Thu, 23 Feb 2012)

Log Message

[GTK] DRT doesn't support scheduleAsynchronousKeyDown.
https://bugs.webkit.org/show_bug.cgi?id=78481

Patch by ChangSeok Oh <[email protected]> on 2012-02-23
Reviewed by Gustavo Noronha Silva.

Source/WebKit/gtk:

Added a new API to deliver all mutations explicitly.

* WebCoreSupport/DumpRenderTreeSupportGtk.cpp:
(DumpRenderTreeSupportGtk::deliverAllMutationsIfNecessary):
* WebCoreSupport/DumpRenderTreeSupportGtk.h:
(DumpRenderTreeSupportGtk):

Tools:

Extracted shareable code from keyDownCallback and then added createKeyPressEvent
to create gdk press key event.
Added sendKeyDown and sendAsynchronousKeyDown to evaluate keyDown event directly
and asynchronously. Eventually, sendAsynchronousKeyDown calls sendKeyDown.

* DumpRenderTree/gtk/EventSender.cpp:
(scheduleAsynchronousClickCallback):
(createKeyPressEvent):
(sendKeyDown):
(keyDownCallback):
(sendAsynchronousKeyDown):
(scheduleAsynchronousKeyDownCallback):

LayoutTests:

Removed following skipped tests.
fast/mutation/end-of-task-delivery.html
fast/mutation/inline-event-listener.html

* platform/gtk/Skipped:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (108627 => 108628)


--- trunk/LayoutTests/ChangeLog	2012-02-23 15:30:25 UTC (rev 108627)
+++ trunk/LayoutTests/ChangeLog	2012-02-23 15:57:52 UTC (rev 108628)
@@ -1,3 +1,16 @@
+2012-02-23  ChangSeok Oh  <[email protected]>
+
+        [GTK] DRT doesn't support scheduleAsynchronousKeyDown.
+        https://bugs.webkit.org/show_bug.cgi?id=78481
+
+        Reviewed by Gustavo Noronha Silva.
+
+        Removed following skipped tests.
+        fast/mutation/end-of-task-delivery.html
+        fast/mutation/inline-event-listener.html
+
+        * platform/gtk/Skipped:
+
 2012-02-23  Sheriff Bot  <[email protected]>
 
         Unreviewed, rolling out r108577.

Modified: trunk/LayoutTests/platform/gtk/Skipped (108627 => 108628)


--- trunk/LayoutTests/platform/gtk/Skipped	2012-02-23 15:30:25 UTC (rev 108627)
+++ trunk/LayoutTests/platform/gtk/Skipped	2012-02-23 15:57:52 UTC (rev 108628)
@@ -1578,11 +1578,6 @@
 fast/dom/Window/window-custom-prototype.html
 http/tests/security/cross-frame-access-object-getPrototypeOf.html
 
-# GTK port DRT doesn't support some API like scheduleAsynchronousKeyDown.
-# http://webkit.org/b/78481, http://webkit.org/b/78290
-fast/mutation/end-of-task-delivery.html
-fast/mutation/inline-event-listener.html
-
 # Let MemoryCache reuse cached XHRs (REGRESSION caused by r107672)
 # https://bugs.webkit.org/show_bug.cgi?id=76564
 fast/workers/worker-crash-with-invalid-location.html

Modified: trunk/Source/WebKit/gtk/ChangeLog (108627 => 108628)


--- trunk/Source/WebKit/gtk/ChangeLog	2012-02-23 15:30:25 UTC (rev 108627)
+++ trunk/Source/WebKit/gtk/ChangeLog	2012-02-23 15:57:52 UTC (rev 108628)
@@ -1,3 +1,17 @@
+2012-02-23  ChangSeok Oh  <[email protected]>
+
+        [GTK] DRT doesn't support scheduleAsynchronousKeyDown.
+        https://bugs.webkit.org/show_bug.cgi?id=78481
+
+        Reviewed by Gustavo Noronha Silva.
+
+        Added a new API to deliver all mutations explicitly.
+
+        * WebCoreSupport/DumpRenderTreeSupportGtk.cpp:
+        (DumpRenderTreeSupportGtk::deliverAllMutationsIfNecessary):
+        * WebCoreSupport/DumpRenderTreeSupportGtk.h:
+        (DumpRenderTreeSupportGtk):
+
 2012-02-23  Philippe Normand  <[email protected]>
 
         [GTK] FullScreen signals

Modified: trunk/Source/WebKit/gtk/WebCoreSupport/DumpRenderTreeSupportGtk.cpp (108627 => 108628)


--- trunk/Source/WebKit/gtk/WebCoreSupport/DumpRenderTreeSupportGtk.cpp	2012-02-23 15:30:25 UTC (rev 108627)
+++ trunk/Source/WebKit/gtk/WebCoreSupport/DumpRenderTreeSupportGtk.cpp	2012-02-23 15:57:52 UTC (rev 108628)
@@ -61,6 +61,7 @@
 #include "TextIterator.h"
 #include "WebKitAccessibleWrapperAtk.h"
 #include "WebKitDOMRangePrivate.h"
+#include "WebKitMutationObserver.h"
 #include "WorkerThread.h"
 #include "webkitglobalsprivate.h"
 #include "webkitwebframe.h"
@@ -915,3 +916,10 @@
 
     return inputElement->isTextField() && !inputElement->isPasswordField() && inputElement->shouldAutocomplete();
 }
+
+void DumpRenderTreeSupportGtk::deliverAllMutationsIfNecessary()
+{
+#if ENABLE(MUTATION_OBSERVERS)
+    WebKitMutationObserver::deliverAllMutations();
+#endif
+}

Modified: trunk/Source/WebKit/gtk/WebCoreSupport/DumpRenderTreeSupportGtk.h (108627 => 108628)


--- trunk/Source/WebKit/gtk/WebCoreSupport/DumpRenderTreeSupportGtk.h	2012-02-23 15:30:25 UTC (rev 108627)
+++ trunk/Source/WebKit/gtk/WebCoreSupport/DumpRenderTreeSupportGtk.h	2012-02-23 15:57:52 UTC (rev 108628)
@@ -129,6 +129,8 @@
 
     static void setHixie76WebSocketProtocolEnabled(WebKitWebView*, bool enabled);
 
+    static void deliverAllMutationsIfNecessary();
+
 private:
     static bool s_drtRun;
     static bool s_linksIncludedInTabChain;

Modified: trunk/Tools/ChangeLog (108627 => 108628)


--- trunk/Tools/ChangeLog	2012-02-23 15:30:25 UTC (rev 108627)
+++ trunk/Tools/ChangeLog	2012-02-23 15:57:52 UTC (rev 108628)
@@ -1,3 +1,23 @@
+2012-02-23  ChangSeok Oh  <[email protected]>
+
+        [GTK] DRT doesn't support scheduleAsynchronousKeyDown.
+        https://bugs.webkit.org/show_bug.cgi?id=78481
+
+        Reviewed by Gustavo Noronha Silva.
+
+        Extracted shareable code from keyDownCallback and then added createKeyPressEvent
+        to create gdk press key event.
+        Added sendKeyDown and sendAsynchronousKeyDown to evaluate keyDown event directly
+        and asynchronously. Eventually, sendAsynchronousKeyDown calls sendKeyDown.
+
+        * DumpRenderTree/gtk/EventSender.cpp:
+        (scheduleAsynchronousClickCallback):
+        (createKeyPressEvent):
+        (sendKeyDown):
+        (keyDownCallback):
+        (sendAsynchronousKeyDown):
+        (scheduleAsynchronousKeyDownCallback):
+
 2012-02-23  Balazs Kelemen  <[email protected]>
 
         [Qt][WK2] WebKitTestRunner should use 480x360 sized view for W3C SVG tests

Modified: trunk/Tools/DumpRenderTree/gtk/EventSender.cpp (108627 => 108628)


--- trunk/Tools/DumpRenderTree/gtk/EventSender.cpp	2012-02-23 15:30:25 UTC (rev 108627)
+++ trunk/Tools/DumpRenderTree/gtk/EventSender.cpp	2012-02-23 15:57:52 UTC (rev 108628)
@@ -3,6 +3,7 @@
  * Copyright (C) 2009 Zan Dobersek <[email protected]>
  * Copyright (C) 2009 Holger Hans Peter Freyther
  * Copyright (C) 2010 Igalia S.L.
+ * Copyright (C) 2012 ChangSeok Oh <[email protected]>
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -34,6 +35,7 @@
 
 #include "DumpRenderTree.h"
 #include "WebCoreSupport/DumpRenderTreeSupportGtk.h"
+#include "WebKitMutationObserver.h"
 #include <GOwnPtrGtk.h>
 #include <GRefPtrGtk.h>
 #include <GtkVersioning.h>
@@ -248,7 +250,7 @@
 
 static JSValueRef scheduleAsynchronousClickCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
 {
-    g_idle_add(sendClick, 0);
+    g_timeout_add(0, sendClick, 0);
     return JSValueMakeUndefined(context);
 }
 
@@ -611,10 +613,9 @@
     endOfQueue = 0;
 }
 
-static JSValueRef keyDownCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
+static GdkEvent* createKeyPressEvent(JSContextRef context, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
 {
-    if (argumentCount < 1)
-        return JSValueMakeUndefined(context);
+    g_return_val_if_fail(argumentCount >= 1, 0);
     guint modifiers = argumentCount >= 2 ? gdkModifersFromJSValue(context, arguments[1]) : 0;
 
     // handle location argument.
@@ -623,7 +624,8 @@
         location = (int)JSValueToNumber(context, arguments[2], exception);
 
     JSStringRef character = JSValueToStringCopy(context, arguments[0], exception);
-    g_return_val_if_fail((!exception || !*exception), JSValueMakeUndefined(context));
+    g_return_val_if_fail((!exception || !*exception), 0);
+
     int gdkKeySym = GDK_VoidSymbol;
     if (location == DOM_KEY_LOCATION_NUMPAD) {
         if (JSStringIsEqualToUTF8CString(character, "leftArrow"))
@@ -717,10 +719,8 @@
     JSStringRelease(character);
 
     WebKitWebView* view = webkit_web_frame_get_web_view(mainFrame);
-    if (!view)
-        return JSValueMakeUndefined(context);
+    g_return_val_if_fail(view, 0);
 
-    // create and send the event
     GdkEvent* pressEvent = gdk_event_new(GDK_KEY_PRESS);
     pressEvent->key.keyval = gdkKeySym;
     pressEvent->key.state = modifiers;
@@ -732,18 +732,31 @@
 
     // When synthesizing an event, an invalid hardware_keycode value
     // can cause it to be badly processed by Gtk+.
-    GdkKeymapKey* keys;
-    gint n_keys;
-    if (gdk_keymap_get_entries_for_keyval(gdk_keymap_get_default(), gdkKeySym, &keys, &n_keys)) {
-        pressEvent->key.hardware_keycode = keys[0].keycode;
-        g_free(keys);
-    }
+    GOwnPtr<GdkKeymapKey> keys;
+    gint nKeys;
+    if (gdk_keymap_get_entries_for_keyval(gdk_keymap_get_default(), gdkKeySym, &keys.outPtr(), &nKeys))
+        pressEvent->key.hardware_keycode = keys.get()[0].keycode;
 
+    return pressEvent;
+}
+
+static void sendKeyDown(GdkEvent* pressEvent)
+{
+    g_return_if_fail(pressEvent);
     GdkEvent* releaseEvent = gdk_event_copy(pressEvent);
+    releaseEvent->type = GDK_KEY_RELEASE;
+
     dispatchEvent(pressEvent);
-    releaseEvent->key.type = GDK_KEY_RELEASE;
     dispatchEvent(releaseEvent);
 
+    DumpRenderTreeSupportGtk::deliverAllMutationsIfNecessary();
+}
+
+static JSValueRef keyDownCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
+{
+    GdkEvent* pressEvent = createKeyPressEvent(context, argumentCount, arguments, exception);
+    sendKeyDown(pressEvent);
+
     return JSValueMakeUndefined(context);
 }
 
@@ -811,6 +824,21 @@
     return JSValueMakeUndefined(context);
 }
 
+static gboolean sendAsynchronousKeyDown(gpointer userData)
+{
+    sendKeyDown(static_cast<GdkEvent*>(userData));
+    return FALSE;
+}
+
+static JSValueRef scheduleAsynchronousKeyDownCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
+{
+    GdkEvent* pressEvent = createKeyPressEvent(context, argumentCount, arguments, exception);
+    if (pressEvent)
+        g_timeout_add(0, sendAsynchronousKeyDown, static_cast<gpointer>(pressEvent));
+
+    return JSValueMakeUndefined(context);
+}
+
 static JSStaticFunction staticFunctions[] = {
     { "mouseScrollBy", mouseScrollByCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
     { "continuousMouseScrollBy", continuousMouseScrollByCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
@@ -827,6 +855,7 @@
     { "zoomPageOut", zoomPageOutCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
     { "scheduleAsynchronousClick", scheduleAsynchronousClickCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
     { "scalePageBy", scalePageByCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
+    { "scheduleAsynchronousKeyDown", scheduleAsynchronousKeyDownCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
 
     { 0, 0, 0 }
 };
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to