Changeset 252873 in webkit


Ignore:
Timestamp:
Nov 25, 2019 9:18:54 PM (4 years ago)
Author:
Fujii Hironori
Message:

[Win] Update KeyboardEvent as per the latest specification
https://bugs.webkit.org/show_bug.cgi?id=202183

Reviewed by Ross Kirsling.

Source/WebCore:

Add 'key' and 'code' properties of KeyboardEvent for Windows. The
implementation is copied from Chromium for Windows.

For implementing 'key' properties, ToUnicodeEx API is used to
convert a virtual key code to a character information.
Unfortunately, ToUnicodeEx alters the stored previous typed dead
key in the driver, it can't be used for each key event. So,
ToUnicodeEx is used to convert all virtual keys with all modifier
combinations beforehand.

This change turns on ENABLE_KEYBOARD_KEY_ATTRIBUTE and
ENABLE_KEYBOARD_CODE_ATTRIBUTE macros for all ports. A follow-up
patch will remove the macros.

Existing tests covers.

  • PlatformWin.cmake:
  • platform/win/KeyEventWin.cpp:

(WebCore::windowsKeyNames):
(WebCore::PlatformKeyboardEvent::PlatformKeyboardEvent):

  • platform/win/WindowsKeyNames.cpp: Added.

(hasControlAndAlt):
(getModifierFlags):
(nonPrintableVirtualKeyToDomKey):
(WindowsKeyNames::WindowsKeyNames):
(WindowsKeyNames::domKeyFromLParam):
(singleCharacterString):
(WindowsKeyNames::domKeyFromChar):
(WindowsKeyNames::domCodeFromLParam):
(WindowsKeyNames::updateLayout):

  • platform/win/WindowsKeyNames.h: Added.

Source/WebKit:

  • Shared/WebEvent.h:
  • Shared/WebKeyboardEvent.cpp:

(WebKit::WebKeyboardEvent::WebKeyboardEvent):

  • Shared/win/WebEventFactory.cpp:

(WebKit::windowsKeyNames):
(WebKit::WebEventFactory::createWebKeyboardEvent):

Source/WTF:

  • wtf/FeatureDefines.h:

LayoutTests:

  • platform/win/TestExpectations:
  • platform/wincairo/TestExpectations:

Unskipped fast/events/arrow-keys-on-body.html, fast/events/keyboardevent-key.html, and fast/events/key-events-in-input-text.html.

Location:
trunk
Files:
2 added
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r252856 r252873  
     12019-11-25  Fujii Hironori  <Hironori.Fujii@sony.com>
     2
     3        [Win] Update KeyboardEvent as per the latest specification
     4        https://bugs.webkit.org/show_bug.cgi?id=202183
     5
     6        Reviewed by Ross Kirsling.
     7
     8        * platform/win/TestExpectations:
     9        * platform/wincairo/TestExpectations:
     10        Unskipped fast/events/arrow-keys-on-body.html, fast/events/keyboardevent-key.html, and fast/events/key-events-in-input-text.html.
     11
    1122019-11-25  Zan Dobersek  <zdobersek@igalia.com>  and  Chris Lord <clord@igalia.com>
    213
  • trunk/LayoutTests/platform/win/TestExpectations

    r252830 r252873  
    32353235fast/dom/Window/get-set-properties.html [ Failure ]
    32363236fast/dom/Window/window-lookup-precedence.html [ Failure ]
    3237 fast/events/arrow-keys-on-body.html [ Failure ]
    32383237fast/events/before-input-events-prevent-drag-and-drop.html [ Failure ]
    32393238fast/events/constructors/keyboard-event-constructor.html [ Failure ]
     
    32463245fast/events/input-events-paste-rich-datatransfer.html [ Failure ]
    32473246fast/events/key-events-in-input-button.html [ Failure ]
    3248 fast/events/key-events-in-input-text.html [ Failure ]
    32493247fast/events/keyboardevent-code.html [ Failure ]
    3250 fast/events/keyboardevent-key.html [ Failure ]
    32513248fast/events/updateLayoutForHitTest.html [ Failure ]
    32523249fast/events/wheelevent-basic.html [ Failure ]
  • trunk/LayoutTests/platform/wincairo/TestExpectations

    r252768 r252873  
    16371637fast/dom/adopt-attribute-crash.svg [ Failure ]
    16381638fast/dom/navigator-property-gc-after-frame-detach.html [ Failure ]
    1639 fast/events/arrow-keys-on-body.html [ Failure ]
    16401639fast/events/attempt-scroll-with-no-scrollbars.html [ Failure ]
    16411640fast/events/autoscroll-when-input-is-offscreen.html [ Skip ] # UIScript
     
    16731672fast/events/input-events-paste-rich-datatransfer.html [ Failure ]
    16741673fast/events/key-events-in-input-button.html [ Failure ]
    1675 fast/events/key-events-in-input-text.html [ Failure ]
    16761674fast/events/keyboardevent-code.html [ Failure ]
    1677 fast/events/keyboardevent-key.html [ Failure ]
    16781675fast/events/keydown-numpad-keys.html [ Failure ]
    16791676fast/events/mouse-cursor-image-set.html [ Failure ]
  • trunk/Source/WTF/ChangeLog

    r252870 r252873  
     12019-11-25  Fujii Hironori  <Hironori.Fujii@sony.com>
     2
     3        [Win] Update KeyboardEvent as per the latest specification
     4        https://bugs.webkit.org/show_bug.cgi?id=202183
     5
     6        Reviewed by Ross Kirsling.
     7
     8        * wtf/FeatureDefines.h:
     9
    1102019-11-25  Fujii Hironori  <Hironori.Fujii@sony.com>
    211
  • trunk/Source/WTF/wtf/FeatureDefines.h

    r251963 r252873  
    752752
    753753#if !defined(ENABLE_KEYBOARD_KEY_ATTRIBUTE)
    754 #define ENABLE_KEYBOARD_KEY_ATTRIBUTE 0
     754#define ENABLE_KEYBOARD_KEY_ATTRIBUTE 1
    755755#endif
    756756
    757757#if !defined(ENABLE_KEYBOARD_CODE_ATTRIBUTE)
    758 #define ENABLE_KEYBOARD_CODE_ATTRIBUTE 0
     758#define ENABLE_KEYBOARD_CODE_ATTRIBUTE 1
    759759#endif
    760760
  • trunk/Source/WebCore/ChangeLog

    r252869 r252873  
     12019-11-25  Fujii Hironori  <Hironori.Fujii@sony.com>
     2
     3        [Win] Update KeyboardEvent as per the latest specification
     4        https://bugs.webkit.org/show_bug.cgi?id=202183
     5
     6        Reviewed by Ross Kirsling.
     7
     8        Add 'key' and 'code' properties of KeyboardEvent for Windows. The
     9        implementation is copied from Chromium for Windows.
     10
     11        For implementing 'key' properties, ToUnicodeEx API is used to
     12        convert a virtual key code to a character information.
     13        Unfortunately, ToUnicodeEx alters the stored previous typed dead
     14        key in the driver, it can't be used for each key event. So,
     15        ToUnicodeEx is used to convert all virtual keys with all modifier
     16        combinations beforehand.
     17
     18        This change turns on ENABLE_KEYBOARD_KEY_ATTRIBUTE and
     19        ENABLE_KEYBOARD_CODE_ATTRIBUTE macros for all ports. A follow-up
     20        patch will remove the macros.
     21
     22        Existing tests covers.
     23
     24        * PlatformWin.cmake:
     25        * platform/win/KeyEventWin.cpp:
     26        (WebCore::windowsKeyNames):
     27        (WebCore::PlatformKeyboardEvent::PlatformKeyboardEvent):
     28        * platform/win/WindowsKeyNames.cpp: Added.
     29        (hasControlAndAlt):
     30        (getModifierFlags):
     31        (nonPrintableVirtualKeyToDomKey):
     32        (WindowsKeyNames::WindowsKeyNames):
     33        (WindowsKeyNames::domKeyFromLParam):
     34        (singleCharacterString):
     35        (WindowsKeyNames::domKeyFromChar):
     36        (WindowsKeyNames::domCodeFromLParam):
     37        (WindowsKeyNames::updateLayout):
     38        * platform/win/WindowsKeyNames.h: Added.
     39
    1402019-11-25  Zalan Bujtas  <zalan@apple.com>
    241
  • trunk/Source/WebCore/PlatformWin.cmake

    r252036 r252873  
    108108    platform/win/WidgetWin.cpp
    109109    platform/win/WindowMessageBroadcaster.cpp
     110    platform/win/WindowsKeyNames.cpp
    110111
    111112    rendering/RenderThemeWin.cpp
     
    143144    platform/win/WindowMessageBroadcaster.h
    144145    platform/win/WindowMessageListener.h
     146    platform/win/WindowsKeyNames.h
    145147    platform/win/WindowsTouch.h
    146148)
  • trunk/Source/WebCore/platform/win/KeyEventWin.cpp

    r241751 r252873  
    2727#include "PlatformKeyboardEvent.h"
    2828
     29#include "WindowsKeyNames.h"
    2930#include <windows.h>
    3031#include <wtf/ASCIICType.h>
     
    219220}
    220221
     222static WindowsKeyNames& windowsKeyNames()
     223{
     224    static NeverDestroyed<WindowsKeyNames> keyNames;
     225    return keyNames;
     226}
     227
    221228PlatformKeyboardEvent::PlatformKeyboardEvent(HWND, WPARAM code, LPARAM keyData, Type type, bool systemKey)
    222229    : PlatformEvent(type, GetKeyState(VK_SHIFT) & HIGH_BIT_MASK_SHORT, GetKeyState(VK_CONTROL) & HIGH_BIT_MASK_SHORT, GetKeyState(VK_MENU) & HIGH_BIT_MASK_SHORT, false, WallTime::fromRawSeconds(::GetTickCount() * 0.001))
    223230    , m_text((type == PlatformEvent::Char) ? singleCharacterString(code) : String())
    224231    , m_unmodifiedText((type == PlatformEvent::Char) ? singleCharacterString(code) : String())
     232    , m_key(type == PlatformEvent::Char ? windowsKeyNames().domKeyFromChar(code) : windowsKeyNames().domKeyFromLParam(keyData))
     233    , m_code(windowsKeyNames().domCodeFromLParam(keyData))
    225234    , m_keyIdentifier((type == PlatformEvent::Char) ? String() : keyIdentifierForWindowsKeyCode(code))
    226235    , m_windowsVirtualKeyCode((type == RawKeyDown || type == KeyUp) ? windowsKeycodeWithLocation(code, keyData) : 0)
  • trunk/Source/WebKit/ChangeLog

    r252851 r252873  
     12019-11-25  Fujii Hironori  <Hironori.Fujii@sony.com>
     2
     3        [Win] Update KeyboardEvent as per the latest specification
     4        https://bugs.webkit.org/show_bug.cgi?id=202183
     5
     6        Reviewed by Ross Kirsling.
     7
     8        * Shared/WebEvent.h:
     9        * Shared/WebKeyboardEvent.cpp:
     10        (WebKit::WebKeyboardEvent::WebKeyboardEvent):
     11        * Shared/win/WebEventFactory.cpp:
     12        (WebKit::windowsKeyNames):
     13        (WebKit::WebEventFactory::createWebKeyboardEvent):
     14
    1152019-11-25  ChangSeok Oh  <changseok@webkit.org>
    216
  • trunk/Source/WebKit/Shared/WebEvent.h

    r250596 r252873  
    264264    WebKeyboardEvent(Type, const String& text, const String& key, const String& code, const String& keyIdentifier, int windowsVirtualKeyCode, int nativeVirtualKeyCode, bool isKeypad, OptionSet<Modifier>, WallTime timestamp);
    265265#else
    266     WebKeyboardEvent(Type, const String& text, const String& unmodifiedText, const String& keyIdentifier, int windowsVirtualKeyCode, int nativeVirtualKeyCode, int macCharCode, bool isAutoRepeat, bool isKeypad, bool isSystemKey, OptionSet<Modifier>, WallTime timestamp);
     266    WebKeyboardEvent(Type, const String& text, const String& unmodifiedText, const String& key, const String& code, const String& keyIdentifier, int windowsVirtualKeyCode, int nativeVirtualKeyCode, int macCharCode, bool isAutoRepeat, bool isKeypad, bool isSystemKey, OptionSet<Modifier>, WallTime timestamp);
    267267#endif
    268268
  • trunk/Source/WebKit/Shared/WebKeyboardEvent.cpp

    r244975 r252873  
    133133#else
    134134
    135 WebKeyboardEvent::WebKeyboardEvent(Type type, const String& text, const String& unmodifiedText, const String& keyIdentifier, int windowsVirtualKeyCode, int nativeVirtualKeyCode, int macCharCode, bool isAutoRepeat, bool isKeypad, bool isSystemKey, OptionSet<Modifier> modifiers, WallTime timestamp)
     135WebKeyboardEvent::WebKeyboardEvent(Type type, const String& text, const String& unmodifiedText, const String& key, const String& code, const String& keyIdentifier, int windowsVirtualKeyCode, int nativeVirtualKeyCode, int macCharCode, bool isAutoRepeat, bool isKeypad, bool isSystemKey, OptionSet<Modifier> modifiers, WallTime timestamp)
    136136    : WebEvent(type, modifiers, timestamp)
    137137    , m_text(text)
    138138    , m_unmodifiedText(unmodifiedText)
     139    , m_key(key)
     140    , m_code(code)
    139141    , m_keyIdentifier(keyIdentifier)
    140142    , m_windowsVirtualKeyCode(windowsVirtualKeyCode)
  • trunk/Source/WebKit/Shared/win/WebEventFactory.cpp

    r249560 r252873  
    3232#include <WebCore/PlatformWheelEvent.h>
    3333#include <WebCore/Scrollbar.h>
     34#include <WebCore/WindowsKeyNames.h>
    3435#include <WebCore/WindowsKeyboardCodes.h>
    3536#include <windowsx.h>
     
    447448}
    448449
     450static WindowsKeyNames& windowsKeyNames()
     451{
     452    static NeverDestroyed<WindowsKeyNames> keyNames;
     453    return keyNames;
     454}
     455
    449456WebKeyboardEvent WebEventFactory::createWebKeyboardEvent(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam)
    450457{
     
    452459    String text = textFromEvent(wparam, type);
    453460    String unmodifiedText = unmodifiedTextFromEvent(wparam, type);
     461    String key = message == WM_CHAR ? windowsKeyNames().domKeyFromChar(wparam) : windowsKeyNames().domKeyFromLParam(lparam);
     462    String code = windowsKeyNames().domCodeFromLParam(lparam);
    454463    String keyIdentifier = keyIdentifierFromEvent(wparam, type);
    455464    int windowsVirtualKeyCode = static_cast<int>(wparam);
     
    461470    auto modifiers = modifiersForCurrentKeyState();
    462471
    463     return WebKeyboardEvent(type, text, unmodifiedText, keyIdentifier, windowsVirtualKeyCode, nativeVirtualKeyCode, macCharCode, autoRepeat, isKeypad, isSystemKey, modifiers, WallTime::now());
     472    return WebKeyboardEvent(type, text, unmodifiedText, key, code, keyIdentifier, windowsVirtualKeyCode, nativeVirtualKeyCode, macCharCode, autoRepeat, isKeypad, isSystemKey, modifiers, WallTime::now());
    464473}
    465474
Note: See TracChangeset for help on using the changeset viewer.