Title: [98200] trunk
Revision
98200
Author
[email protected]
Date
2011-10-23 00:27:47 -0700 (Sun, 23 Oct 2011)

Log Message

[GTK] Implement KeyDown function for WebKit2 EventSender.
https://bugs.webkit.org/show_bug.cgi?id=69410

Tools:

Patch by Kaustubh Atrawalkar <[email protected]> on 2011-10-23
Reviewed by Martin Robinson.

Implement the KeyDown function on Gtk platform.

* WebKitTestRunner/GNUmakefile.am:
* WebKitTestRunner/TestController.cpp:
(WTR::TestController::TestController):
(WTR::TestController::didReceiveSynchronousMessageFromInjectedBundle):
* WebKitTestRunner/gtk/EventSenderProxyGtk.cpp: Added.
(WTR::EventSenderProxy::EventSenderProxy):
(WTR::dispatchEvent):
(WTR::getModifiers):
(WTR::getGDKKeySymForKeyRef):
(WTR::EventSenderProxy::keyDown):

LayoutTests:

Unskip passed tests.

Patch by Kaustubh Atrawalkar <[email protected]> on 2011-10-23
Reviewed by Martin Robinson.

* platform/gtk-wk2/Skipped:

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (98199 => 98200)


--- trunk/LayoutTests/ChangeLog	2011-10-23 07:21:19 UTC (rev 98199)
+++ trunk/LayoutTests/ChangeLog	2011-10-23 07:27:47 UTC (rev 98200)
@@ -1,3 +1,14 @@
+2011-10-23  Kaustubh Atrawalkar  <[email protected]>
+
+        [GTK] Implement KeyDown function for WebKit2 EventSender.
+        https://bugs.webkit.org/show_bug.cgi?id=69410
+
+        Unskip passed tests.
+
+        Reviewed by Martin Robinson.
+
+        * platform/gtk-wk2/Skipped:
+
 2011-10-21  Geoffrey Garen  <[email protected]>
 
         Separated string lifetime bits from character buffer state bits

Modified: trunk/LayoutTests/platform/gtk-wk2/Skipped (98199 => 98200)


--- trunk/LayoutTests/platform/gtk-wk2/Skipped	2011-10-23 07:21:19 UTC (rev 98199)
+++ trunk/LayoutTests/platform/gtk-wk2/Skipped	2011-10-23 07:27:47 UTC (rev 98200)
@@ -87,18 +87,12 @@
 fullscreen/full-screen-zIndex-after.html
 plugins/fullscreen-plugins-dont-reload.html
 plugins/keyboard-events.html
-fast/dom/HTMLSelectElement/click-size-zero-no-crash.html
 fast/dom/access-key-iframe.html
 fast/dom/hidden-iframe-no-focus.html
-fast/dom/horizontal-scrollbar-in-rtl.html
 fast/dom/vertical-scrollbar-in-rtl.html
-fast/events/keypress-removed-node.html
-fast/events/attempt-select-all-with-wrong-modifier.html
-fast/events/keyevent-iframe-removed-crash.html
 fast/events/key-events-in-input-text.html
 fast/events/imagemap-norender-crash.html
 fast/events/special-key-events-in-input-text.html
-fast/events/select-element.html
 fast/events/access-key-self-destruct.html
 fast/events/multiline-link-arrow-navigation.html
 fast/events/check-defocus-event-order-when-triggered-by-tab.html
@@ -107,20 +101,16 @@
 fast/events/scroll-after-click-on-tab-index.html
 fast/events/selectstart-by-arrow-keys.html
 fast/events/tab-is-focusable-assert.html
-fast/events/keydown-keypress-preventDefault.html
-fast/events/keydown-1.html
 fast/events/focusingUnloadedFrame.html
 fast/events/onsearch-enter.html
 fast/events/inputText-never-fired-on-keydown-cancel.html
 fast/events/keydown-numpad-keys.html
-fast/events/select-onchange-crash.html
 fast/events/selectstart-by-arrow-keys-prevent-default.html
 fast/events/onchange-textfield.html
 fast/events/media-element-focus-tab.html
 fast/events/focus-change-crash.html
 fast/events/tabindex-focus-chain.html
 fast/events/node-event-anchor-lock.html
-fast/events/arrow-navigation.html
 fast/events/keydown-keypress-focus-change.html
 fast/events/js-keyboard-event-creation.html
 fast/events/tab-focus-hidden.html
@@ -131,16 +121,9 @@
 fast/events/onchange-select-popup.html
 fast/events/onchange-searchfield.html
 fast/events/onchange-text-form-field.html
-fast/events/keydown-remove-frame.html
 fast/events/keypress-focus-change.html
-fast/events/keydown-function-keys.html
-fast/events/space-scroll-event.html
-fast/events/arrow-keys-on-body.html
-fast/events/recorded-keydown-event.html
 fast/events/popup-when-select-change.html
 fast/events/tab-imagemap.html
-fast/events/menu-keydown-on-hidden-element.html
-fast/events/anchor-empty-focus.html
 fast/events/key-events-in-input-button.html
 fast/repaint/fixed-move-after-keyboard-scroll.html
 fast/forms/onchange-enter-submit.html
@@ -200,9 +183,7 @@
 editing/deleting/delete-by-word-001.html
 editing/deleting/delete-ligature-002.html
 editing/deleting/skip-virama-001.html
-editing/deleting/forward-delete-key.html
 editing/deleting/delete-by-word-002.html
-editing/deleting/5729680.html
 editing/inserting/typing-tab-designmode-forms.html
 editing/inserting/typing-tab-designmode.html
 editing/undo/undo-deleteWord.html
@@ -215,7 +196,6 @@
 editing/input/scroll-viewport-page-up-down.html
 editing/input/option-page-up-down.html
 editing/input/style-change-during-input.html
-editing/input/page-up-down-scrolls.html
 
 # [GTK] Implement drag and drop support in WebKit2
 # https://bugs.webkit.org/show_bug.cgi?id=63706
@@ -391,7 +371,6 @@
 fast/events/remove-target-in-mouseup.html
 fast/events/resources/drag-outside-window-frame.html
 fast/events/mouseover-mouseout2.html
-fast/events/node-event-anchor-lock.html
 fast/events/mouseover-button.html
 fast/events/click-focus-anchor.html
 fast/encoding/mailto-always-utf-8.html
@@ -615,10 +594,8 @@
 editing/selection/caret-at-bidi-boundary.html
 editing/selection/fake-drag.html
 editing/selection/paragraph-granularity.html
-editing/selection/5131716-3.html
 editing/selection/after-line-break.html
 editing/selection/anchor-focus3.html
-editing/selection/5057506-2.html
 editing/selection/anchor-focus1.html
 editing/selection/expanding-selections.html
 editing/selection/5232159.html

Modified: trunk/Tools/ChangeLog (98199 => 98200)


--- trunk/Tools/ChangeLog	2011-10-23 07:21:19 UTC (rev 98199)
+++ trunk/Tools/ChangeLog	2011-10-23 07:27:47 UTC (rev 98200)
@@ -1,3 +1,23 @@
+2011-10-23  Kaustubh Atrawalkar  <[email protected]>
+
+        [GTK] Implement KeyDown function for WebKit2 EventSender.
+        https://bugs.webkit.org/show_bug.cgi?id=69410
+
+        Reviewed by Martin Robinson.
+
+        Implement the KeyDown function on Gtk platform.
+
+        * WebKitTestRunner/GNUmakefile.am:
+        * WebKitTestRunner/TestController.cpp:
+        (WTR::TestController::TestController):
+        (WTR::TestController::didReceiveSynchronousMessageFromInjectedBundle):
+        * WebKitTestRunner/gtk/EventSenderProxyGtk.cpp: Added.
+        (WTR::EventSenderProxy::EventSenderProxy):
+        (WTR::dispatchEvent):
+        (WTR::getModifiers):
+        (WTR::getGDKKeySymForKeyRef):
+        (WTR::EventSenderProxy::keyDown):
+
 2011-10-22  Zan Dobersek  <[email protected]>
 
         [WK2][GTK] run-launcher script fails after testing WK2 tests

Modified: trunk/Tools/WebKitTestRunner/GNUmakefile.am (98199 => 98200)


--- trunk/Tools/WebKitTestRunner/GNUmakefile.am	2011-10-23 07:21:19 UTC (rev 98199)
+++ trunk/Tools/WebKitTestRunner/GNUmakefile.am	2011-10-23 07:27:47 UTC (rev 98200)
@@ -10,6 +10,7 @@
 
 Programs_WebKitTestRunner_SOURCES = \
 	Tools/WebKitTestRunner/gtk/main.cpp \
+	Tools/WebKitTestRunner/gtk/EventSenderProxyGtk.cpp \
 	Tools/WebKitTestRunner/gtk/PlatformWebViewGtk.cpp \
 	Tools/WebKitTestRunner/gtk/TestControllerGtk.cpp \
 	Tools/WebKitTestRunner/cairo/TestInvocationCairo.cpp \
@@ -22,11 +23,13 @@
 	Tools/WebKitTestRunner/TestController.cpp \
 	Tools/WebKitTestRunner/TestController.h \
 	Tools/WebKitTestRunner/TestInvocation.cpp \
-	Tools/WebKitTestRunner/TestInvocation.h
+	Tools/WebKitTestRunner/TestInvocation.h \
+	Source/WebCore/platform/gtk/GtkVersioning.c
 
 Programs_WebKitTestRunner_CPPFLAGS = \
 	-include Tools/WebKitTestRunner/WebKitTestRunnerPrefix.h \
 	-I$(srcdir)/Tools/WebKitTestRunner \
+	-I$(srcdir)/Source/WebCore/platform/gtk \
 	-I$(top_builddir)/DerivedSources/WebKit2/include \
 	-DWEBKIT_EXEC_PATH=\"${shell pwd}/$(top_builddir)/Programs/\" \
 	$(global_cppflags) \

Modified: trunk/Tools/WebKitTestRunner/TestController.cpp (98199 => 98200)


--- trunk/Tools/WebKitTestRunner/TestController.cpp	2011-10-23 07:21:19 UTC (rev 98199)
+++ trunk/Tools/WebKitTestRunner/TestController.cpp	2011-10-23 07:27:47 UTC (rev 98200)
@@ -38,7 +38,7 @@
 #include <cstdio>
 #include <wtf/PassOwnPtr.h>
 
-#if PLATFORM(MAC) || PLATFORM(QT)
+#if PLATFORM(MAC) || PLATFORM(QT) || PLATFORM(GTK)
 #include "EventSenderProxy.h"
 #endif
 
@@ -74,7 +74,7 @@
     , m_didPrintWebProcessCrashedMessage(false)
     , m_shouldExitWhenWebProcessCrashes(true)
     , m_beforeUnloadReturnValue(true)
-#if PLATFORM(MAC) || PLATFORM(QT)
+#if PLATFORM(MAC) || PLATFORM(QT) || PLATFORM(GTK)
     , m_eventSenderProxy(new EventSenderProxy(this))
 #endif
 {
@@ -540,7 +540,7 @@
 
 WKRetainPtr<WKTypeRef> TestController::didReceiveSynchronousMessageFromInjectedBundle(WKStringRef messageName, WKTypeRef messageBody)
 {
-#if PLATFORM(MAC) || PLATFORM(QT)
+#if PLATFORM(MAC) || PLATFORM(QT) || PLATFORM(GTK)
     if (WKStringIsEqualToUTF8CString(messageName, "EventSender")) {
         ASSERT(WKGetTypeID(messageBody) == WKDictionaryGetTypeID());
         WKDictionaryRef messageBodyDictionary = static_cast<WKDictionaryRef>(messageBody);
@@ -565,6 +565,7 @@
             return 0;
         }
 
+#if PLATFORM(MAC) || PLATFORM(QT)
         if (WKStringIsEqualToUTF8CString(subMessageName, "MouseDown") || WKStringIsEqualToUTF8CString(subMessageName, "MouseUp")) {
             WKRetainPtr<WKStringRef> buttonKey = adoptWK(WKStringCreateWithUTF8CString("Button"));
             unsigned button = static_cast<unsigned>(WKUInt64GetValue(static_cast<WKUInt64Ref>(WKDictionaryGetItemForKey(messageBodyDictionary, buttonKey.get()))));
@@ -617,7 +618,7 @@
             m_eventSenderProxy->leapForward(time);
             return 0;
         }
-
+#endif
         ASSERT_NOT_REACHED();
     }
 #endif

Added: trunk/Tools/WebKitTestRunner/gtk/EventSenderProxyGtk.cpp (0 => 98200)


--- trunk/Tools/WebKitTestRunner/gtk/EventSenderProxyGtk.cpp	                        (rev 0)
+++ trunk/Tools/WebKitTestRunner/gtk/EventSenderProxyGtk.cpp	2011-10-23 07:27:47 UTC (rev 98200)
@@ -0,0 +1,199 @@
+/*
+ * Copyright (C) 2007, 2008 Apple Inc. All rights reserved.
+ * Copyright (C) 2009 Zan Dobersek <[email protected]>
+ * Copyright (C) 2009 Holger Hans Peter Freyther
+ * Copyright (C) 2010 Igalia S.L.
+ * Copyright (c) 2010 Motorola Mobility, 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:
+ *
+ * 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.
+ * 3.  Neither the name of Apple Computer, Inc. ("Apple") nor the names of
+ *     its contributors may be used to endorse or promote products derived
+ *     from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE 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 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 "config.h"
+#include "EventSenderProxy.h"
+
+#include "PlatformWebView.h"
+#include "TestController.h"
+#include <GOwnPtrGtk.h>
+#include <GtkVersioning.h>
+#include <gdk/gdk.h>
+#include <gdk/gdkkeysyms.h>
+#include <gtk/gtk.h>
+#include <wtf/text/WTFString.h>
+
+namespace WTR {
+// Key event location code defined in DOM Level 3.
+enum KeyLocationCode {
+    DOMKeyLocationStandard      = 0x00,
+    DOMKeyLocationLeft          = 0x01,
+    DOMKeyLocationRight         = 0x02,
+    DOMKeyLocationNumpad        = 0x03
+};
+
+EventSenderProxy::EventSenderProxy(TestController* testController)
+    : m_testController(testController)
+{
+}
+
+static void dispatchEvent(GdkEvent* event)
+{
+    gtk_main_do_event(event);
+    gdk_event_free(event);
+}
+
+
+static guint getModifiers(WKEventModifiers modifiersRef)
+{
+    guint modifiers = 0;
+
+    if (modifiersRef & kWKEventModifiersControlKey)
+        modifiers |= kWKEventModifiersControlKey;
+    if (modifiersRef & kWKEventModifiersShiftKey)
+        modifiers |= kWKEventModifiersShiftKey;
+    if (modifiersRef & kWKEventModifiersAltKey)
+        modifiers |= kWKEventModifiersAltKey;
+    if (modifiersRef & kWKEventModifiersMetaKey)
+        modifiers |= kWKEventModifiersMetaKey;
+
+    return modifiers;
+}
+
+int getGDKKeySymForKeyRef(WKStringRef keyRef, unsigned location, guint* modifiers)
+{
+    if (location == DOMKeyLocationNumpad) {
+        if (WKStringIsEqualToUTF8CString(keyRef, "leftArrow"))
+            return GDK_KEY_KP_Left;
+        if (WKStringIsEqualToUTF8CString(keyRef, "rightArror"))
+            return GDK_KEY_KP_Right;
+        if (WKStringIsEqualToUTF8CString(keyRef, "upArrow"))
+            return GDK_KEY_KP_Up;
+        if (WKStringIsEqualToUTF8CString(keyRef, "downArrow"))
+            return GDK_KEY_KP_Down;
+        if (WKStringIsEqualToUTF8CString(keyRef, "pageUp"))
+            return GDK_KEY_KP_Page_Up;
+        if (WKStringIsEqualToUTF8CString(keyRef, "pageDown"))
+            return GDK_KEY_KP_Page_Down;
+        if (WKStringIsEqualToUTF8CString(keyRef, "home"))
+            return GDK_KEY_KP_Home;
+        if (WKStringIsEqualToUTF8CString(keyRef, "end"))
+            return GDK_KEY_KP_End;
+        if (WKStringIsEqualToUTF8CString(keyRef, "insert"))
+            return GDK_KEY_KP_Insert;
+        if (WKStringIsEqualToUTF8CString(keyRef, "delete"))
+            return GDK_KEY_KP_Delete;
+
+        return GDK_KEY_VoidSymbol;
+    }
+
+    if (WKStringIsEqualToUTF8CString(keyRef, "leftArrow"))
+        return GDK_KEY_Left;
+    if (WKStringIsEqualToUTF8CString(keyRef, "rightArror"))
+        return GDK_KEY_Right;
+    if (WKStringIsEqualToUTF8CString(keyRef, "upArrow"))
+        return GDK_KEY_Up;
+    if (WKStringIsEqualToUTF8CString(keyRef, "downArrow"))
+        return GDK_KEY_Down;
+    if (WKStringIsEqualToUTF8CString(keyRef, "pageUp"))
+        return GDK_KEY_Page_Up;
+    if (WKStringIsEqualToUTF8CString(keyRef, "pageDown"))
+        return GDK_KEY_Page_Down;
+    if (WKStringIsEqualToUTF8CString(keyRef, "home"))
+        return GDK_KEY_Home;
+    if (WKStringIsEqualToUTF8CString(keyRef, "end"))
+        return GDK_KEY_End;
+    if (WKStringIsEqualToUTF8CString(keyRef, "insert"))
+        return GDK_KEY_Insert;
+    if (WKStringIsEqualToUTF8CString(keyRef, "delete"))
+        return GDK_KEY_Delete;
+    if (WKStringIsEqualToUTF8CString(keyRef, "printScreen"))
+        return GDK_KEY_Print;
+    if (WKStringIsEqualToUTF8CString(keyRef, "menu"))
+        return GDK_KEY_Menu;
+    if (WKStringIsEqualToUTF8CString(keyRef, "F1"))
+        return GDK_KEY_F1;
+    if (WKStringIsEqualToUTF8CString(keyRef, "F2"))
+        return GDK_KEY_F2;
+    if (WKStringIsEqualToUTF8CString(keyRef, "F3"))
+        return GDK_KEY_F3;
+    if (WKStringIsEqualToUTF8CString(keyRef, "F4"))
+        return GDK_KEY_F4;
+    if (WKStringIsEqualToUTF8CString(keyRef, "F5"))
+        return GDK_KEY_F5;
+    if (WKStringIsEqualToUTF8CString(keyRef, "F6"))
+        return GDK_KEY_F6;
+    if (WKStringIsEqualToUTF8CString(keyRef, "F7"))
+        return GDK_KEY_F7;
+    if (WKStringIsEqualToUTF8CString(keyRef, "F8"))
+        return GDK_KEY_F8;
+    if (WKStringIsEqualToUTF8CString(keyRef, "F9"))
+        return GDK_KEY_F9;
+    if (WKStringIsEqualToUTF8CString(keyRef, "F10"))
+        return GDK_KEY_F10;
+    if (WKStringIsEqualToUTF8CString(keyRef, "F11"))
+        return GDK_KEY_F11;
+    if (WKStringIsEqualToUTF8CString(keyRef, "F12"))
+        return GDK_KEY_F12;
+
+    size_t stringSize = WKStringGetLength(keyRef);
+    char* buffer = new char[stringSize];
+    WKStringGetUTF8CString(keyRef, buffer, stringSize);
+    int charCode = buffer[0];
+
+    if (charCode == '\n' || charCode == '\r')
+        return GDK_KEY_Return;
+    if (charCode == '\t')
+        return GDK_KEY_Tab;
+    if (charCode == '\x8')
+        return GDK_KEY_BackSpace;
+
+    if (WTF::isASCIIUpper(charCode))
+        *modifiers |= GDK_SHIFT_MASK;
+
+    return gdk_unicode_to_keyval(charCode);
+}
+
+void EventSenderProxy::keyDown(WKStringRef keyRef, WKEventModifiers modifiersRef, unsigned location)
+{
+    guint modifiers = getModifiers(modifiersRef);
+    int gdkKeySym = getGDKKeySymForKeyRef(keyRef, location, &modifiers);
+
+    GdkEvent* pressEvent = gdk_event_new(GDK_KEY_PRESS);
+    pressEvent->key.keyval = gdkKeySym;
+    pressEvent->key.state = modifiers;
+    pressEvent->key.window = gtk_widget_get_window(GTK_WIDGET(m_testController->mainWebView()->platformView()));
+    g_object_ref(pressEvent->key.window);
+    gdk_event_set_device(pressEvent, getDefaultGDKPointerDevice(pressEvent->key.window));
+
+    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.outPtr()[0].keycode;
+
+    GdkEvent* releaseEvent = gdk_event_copy(pressEvent);
+    dispatchEvent(pressEvent);
+    releaseEvent->key.type = GDK_KEY_RELEASE;
+    dispatchEvent(releaseEvent);
+}
+
+} // namespace WTR
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to