Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[GTK] Should support key and code properties on keyboard events
https://bugs.webkit.org/show_bug.cgi?id=166759

Reviewed by Carlos Garcia Campos.

Source/WebCore:

This change fixes a bunch of tests which are currently failing, such as:
- fast/events/arrow-keys-on-body.html
- fast/events/constructors/keyboard-event-constructor.html
- fast/events/key-events-in-input-button.html
- fast/events/key-events-in-input-text.html
- fast/events/keyboardevent-code.html
- fast/events/keyboardevent-key.html

* platform/PlatformKeyboardEvent.h:
* platform/gtk/PlatformKeyboardEventGtk.cpp:
(WebCore::PlatformKeyboardEvent::keyValueForGdkKeyCode): match web key value
to GDK key symbol.
(WebCore::PlatformKeyboardEvent::keyCodeForHardwareKeyCode): match web key code
to hardware code as reported by GDK.
(WebCore::PlatformKeyboardEvent::PlatformKeyboardEvent): add web key value and
code to the keyboard event upon creation.

Source/WebKit2:

* Shared/WebEvent.h:
* Shared/WebKeyboardEvent.cpp:
(WebKit::WebKeyboardEvent::WebKeyboardEvent): accept web key value and code on construction.
* Shared/gtk/WebEventFactory.cpp:
(WebKit::WebEventFactory::createWebKeyboardEvent): pass web key value and code on construction.

Source/WTF:

* wtf/FeatureDefines.h: enable key and code properties support for GTK.

Tools:

* WebKitTestRunner/gtk/EventSenderProxyGtk.cpp:
(WTR::getGDKKeySymForKeyRef): add missing modifier keys which were being reported as 'l' and 'r' only
on tests.

LayoutTests:

* platform/gtk/fast/events/keyboardevent-code-expected.txt: Added. Hardware
codes are different for Mac and Linux for a couple of keys, so we need
platform-specific results.

Canonical link: https://commits.webkit.org/183955@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@210504 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
kov committed Jan 9, 2017
1 parent 044c0e4 commit ab004f2
Show file tree
Hide file tree
Showing 13 changed files with 974 additions and 3 deletions.
11 changes: 11 additions & 0 deletions LayoutTests/ChangeLog
@@ -1,3 +1,14 @@
2017-01-06 Gustavo Noronha Silva <gustavo.noronha@collabora.co.uk>

[GTK] Should support key and code properties on keyboard events
https://bugs.webkit.org/show_bug.cgi?id=166759

Reviewed by Carlos Garcia Campos.

* platform/gtk/fast/events/keyboardevent-code-expected.txt: Added. Hardware
codes are different for Mac and Linux for a couple of keys, so we need
platform-specific results.

2017-01-09 Alejandro G. Castro <alex@igalia.com>

[OWR] Unskip fast/mediastream/MediaStream-video-element-track-stop.html
Expand Down
190 changes: 190 additions & 0 deletions LayoutTests/platform/gtk/fast/events/keyboardevent-code-expected.txt
@@ -0,0 +1,190 @@
Test the code attribute on KeyboardEvent.

On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".



* keydown
PASS keyboardEvent.code is "Space"
* keyup
PASS keyboardEvent.code is "Space"

* keydown
PASS keyboardEvent.code is "KeyA"
* keyup
PASS keyboardEvent.code is "KeyA"

* keydown
PASS keyboardEvent.code is "Backspace"
* keyup
PASS keyboardEvent.code is "Backspace"

* keydown
FAIL keyboardEvent.code should be Minus. Was Escape.
* keyup
FAIL keyboardEvent.code should be Minus. Was Escape.

* keydown
PASS keyboardEvent.code is "ArrowLeft"
* keyup
PASS keyboardEvent.code is "ArrowLeft"

* keydown
PASS keyboardEvent.code is "ArrowRight"
* keyup
PASS keyboardEvent.code is "ArrowRight"

* keydown
PASS keyboardEvent.code is "ArrowUp"
* keyup
PASS keyboardEvent.code is "ArrowUp"

* keydown
PASS keyboardEvent.code is "ArrowDown"
* keyup
PASS keyboardEvent.code is "ArrowDown"

* keydown
PASS keyboardEvent.code is "PageUp"
* keyup
PASS keyboardEvent.code is "PageUp"

* keydown
PASS keyboardEvent.code is "PageDown"
* keyup
PASS keyboardEvent.code is "PageDown"

* keydown
PASS keyboardEvent.code is "Home"
* keyup
PASS keyboardEvent.code is "Home"

* keydown
PASS keyboardEvent.code is "End"
* keyup
PASS keyboardEvent.code is "End"

* keydown
PASS keyboardEvent.code is "Delete"
* keyup
PASS keyboardEvent.code is "Delete"

* keydown
PASS keyboardEvent.code is "ControlLeft"
* keyup
PASS keyboardEvent.code is "ControlLeft"

* keydown
PASS keyboardEvent.code is "ShiftLeft"
* keyup
PASS keyboardEvent.code is "ShiftLeft"

* keydown
PASS keyboardEvent.code is "AltLeft"
* keyup
PASS keyboardEvent.code is "AltLeft"

* keydown
PASS keyboardEvent.code is "ControlRight"
* keyup
PASS keyboardEvent.code is "ControlRight"

* keydown
PASS keyboardEvent.code is "ShiftRight"
* keyup
PASS keyboardEvent.code is "ShiftRight"

* keydown
PASS keyboardEvent.code is "AltRight"
* keyup
PASS keyboardEvent.code is "AltRight"

* keydown
PASS keyboardEvent.code is "F1"
* keyup
PASS keyboardEvent.code is "F1"

* keydown
PASS keyboardEvent.code is "F2"
* keyup
PASS keyboardEvent.code is "F2"

* keydown
PASS keyboardEvent.code is "F3"
* keyup
PASS keyboardEvent.code is "F3"

* keydown
PASS keyboardEvent.code is "F4"
* keyup
PASS keyboardEvent.code is "F4"

* keydown
PASS keyboardEvent.code is "F5"
* keyup
PASS keyboardEvent.code is "F5"

* keydown
PASS keyboardEvent.code is "F6"
* keyup
PASS keyboardEvent.code is "F6"

* keydown
PASS keyboardEvent.code is "F7"
* keyup
PASS keyboardEvent.code is "F7"

* keydown
PASS keyboardEvent.code is "F8"
* keyup
PASS keyboardEvent.code is "F8"

* keydown
PASS keyboardEvent.code is "F9"
* keyup
PASS keyboardEvent.code is "F9"

* keydown
PASS keyboardEvent.code is "F10"
* keyup
PASS keyboardEvent.code is "F10"

* keydown
PASS keyboardEvent.code is "F11"
* keyup
PASS keyboardEvent.code is "F11"

* keydown
PASS keyboardEvent.code is "F12"
* keyup
PASS keyboardEvent.code is "F12"

* keydown
FAIL keyboardEvent.code should be NumpadEnter. Was Enter.
* keyup
FAIL keyboardEvent.code should be NumpadEnter. Was Enter.

* keydown
PASS keyboardEvent.code is "KeyA"
* keyup
PASS keyboardEvent.code is "KeyA"

* keydown
PASS keyboardEvent.code is "KeyA"
* keyup
PASS keyboardEvent.code is "KeyA"

* keydown
PASS keyboardEvent.code is "KeyA"
* keyup
PASS keyboardEvent.code is "KeyA"

* keydown
PASS keyboardEvent.code is "Digit1"
* keyup
PASS keyboardEvent.code is "Digit1"

PASS successfullyParsed is true

TEST COMPLETE

9 changes: 9 additions & 0 deletions Source/WTF/ChangeLog
@@ -1,3 +1,12 @@
2017-01-06 Gustavo Noronha Silva <gustavo.noronha@collabora.co.uk>

[GTK] Should support key and code properties on keyboard events
https://bugs.webkit.org/show_bug.cgi?id=166759

Reviewed by Carlos Garcia Campos.

* wtf/FeatureDefines.h: enable key and code properties support for GTK.

2017-01-08 Antti Koivisto <antti@apple.com>

Move cache coders to WTF
Expand Down
7 changes: 7 additions & 0 deletions Source/WTF/wtf/FeatureDefines.h
Expand Up @@ -324,6 +324,13 @@ the public iOS SDK. We will also need to update the FeatureDefines.xcconfig file

/* --------- Gtk port (Unix, Windows, Mac) --------- */
#if PLATFORM(GTK)
#if !defined(ENABLE_KEYBOARD_KEY_ATTRIBUTE)
#define ENABLE_KEYBOARD_KEY_ATTRIBUTE 1
#endif

#if !defined(ENABLE_KEYBOARD_CODE_ATTRIBUTE)
#define ENABLE_KEYBOARD_CODE_ATTRIBUTE 1
#endif
#endif /* PLATFORM(GTK) */

/* ENABLE macro defaults for WebCore */
Expand Down
24 changes: 24 additions & 0 deletions Source/WebCore/ChangeLog
@@ -1,3 +1,27 @@
2017-01-06 Gustavo Noronha Silva <gustavo.noronha@collabora.co.uk>

[GTK] Should support key and code properties on keyboard events
https://bugs.webkit.org/show_bug.cgi?id=166759

Reviewed by Carlos Garcia Campos.

This change fixes a bunch of tests which are currently failing, such as:
- fast/events/arrow-keys-on-body.html
- fast/events/constructors/keyboard-event-constructor.html
- fast/events/key-events-in-input-button.html
- fast/events/key-events-in-input-text.html
- fast/events/keyboardevent-code.html
- fast/events/keyboardevent-key.html

* platform/PlatformKeyboardEvent.h:
* platform/gtk/PlatformKeyboardEventGtk.cpp:
(WebCore::PlatformKeyboardEvent::keyValueForGdkKeyCode): match web key value
to GDK key symbol.
(WebCore::PlatformKeyboardEvent::keyCodeForHardwareKeyCode): match web key code
to hardware code as reported by GDK.
(WebCore::PlatformKeyboardEvent::PlatformKeyboardEvent): add web key value and
code to the keyboard event upon creation.

2017-01-09 Carlos Garcia Campos <cgarcia@igalia.com>

[GTK] WebProcess from WebKitGtk+ 2.15.2 SIGSEGVs in std::unique_ptr<SoupBuffer, WTF::GPtrDeleter<SoupBuffer> >::get() const () at /usr/include/c++/6/bits/unique_ptr.h:305
Expand Down
2 changes: 2 additions & 0 deletions Source/WebCore/platform/PlatformKeyboardEvent.h
Expand Up @@ -161,6 +161,8 @@ namespace WebCore {
const CompositionResults& compositionResults() const { return m_compositionResults; }

// Used by WebKit2
static String keyValueForGdkKeyCode(unsigned);
static String keyCodeForHardwareKeyCode(unsigned);
static String keyIdentifierForGdkKeyCode(unsigned);
static int windowsKeyCodeForGdkKeyCode(unsigned);
static String singleCharacterString(unsigned);
Expand Down

0 comments on commit ab004f2

Please sign in to comment.