Title: [206828] trunk
Revision
206828
Author
cdu...@apple.com
Date
2016-10-05 14:12:51 -0700 (Wed, 05 Oct 2016)

Log Message

KeyboardEvent.getModifierState() should support "CapsLock" modifier
https://bugs.webkit.org/show_bug.cgi?id=162861

Reviewed by Darin Adler.

Source/WebCore:

Add support for "CapsLock" modifier on Mac / iOS for KeyboardEvent's
getModifierState() API, as per:
- https://w3c.github.io/uievents/#dom-keyboardevent-getmodifierstate

No new tests, updated existing test.

* dom/KeyboardEvent.cpp:
(WebCore::KeyboardEvent::KeyboardEvent):
(WebCore::KeyboardEvent::getModifierState):
* dom/KeyboardEvent.h:
* platform/PlatformEvent.h:
* platform/ios/PlatformEventFactoryIOS.mm:
(WebCore::modifiersForEvent):
* platform/mac/PlatformEventFactoryMac.mm:
(WebCore::keyIdentifierForKeyEvent):

Source/WebKit2:

Add support for CapsLock modifier on events.

* Shared/API/c/WKEvent.h:
* Shared/API/c/WKSharedAPICast.h:
(WebKit::toAPI):
* Shared/WebEventConversion.cpp:
(WebKit::WebKit2PlatformMouseEvent::WebKit2PlatformMouseEvent):
(WebKit::WebKit2PlatformWheelEvent::WebKit2PlatformWheelEvent):
(WebKit::WebKit2PlatformKeyboardEvent::WebKit2PlatformKeyboardEvent):
(WebKit::WebKit2PlatformTouchEvent::WebKit2PlatformTouchEvent):
(WebKit::WebKit2PlatformGestureEvent::WebKit2PlatformGestureEvent):
* Shared/efl/WebEventFactory.cpp:
(WebKit::toWebEventModifiers):
* Shared/ios/WebIOSEventFactory.mm:
(modifiersForEvent):
* Shared/mac/WebEventFactory.mm:
(WebKit::modifiersForEvent):
* UIProcess/API/Cocoa/WKNavigationAction.mm:
(toNSEventModifierFlags):
* UIProcess/Cocoa/WebAutomationSessionCocoa.mm:
(WebKit::WebAutomationSession::platformSimulateMouseInteraction):

Tools:

Add support for 'capsLockKey' modifier for EventSender.keyDown() so
that we can test this new modifier support for layout tests.

* TestWebKitAPI/mac/PlatformWebViewMac.mm:
(TestWebKitAPI::modifierFlagsForWKModifiers):
* WebKitTestRunner/InjectedBundle/EventSendingController.cpp:
(WTR::parseModifier):
* WebKitTestRunner/mac/EventSenderProxy.mm:
(WTR::buildModifierFlags):

LayoutTests:

Extend layout test coverage to cover 'Caps Lock' modifier.

* fast/events/special-key-events-in-input-text-expected.txt:
* fast/events/special-key-events-in-input-text.html:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (206827 => 206828)


--- trunk/LayoutTests/ChangeLog	2016-10-05 20:46:15 UTC (rev 206827)
+++ trunk/LayoutTests/ChangeLog	2016-10-05 21:12:51 UTC (rev 206828)
@@ -1,3 +1,15 @@
+2016-10-05  Chris Dumez  <cdu...@apple.com>
+
+        KeyboardEvent.getModifierState() should support "CapsLock" modifier
+        https://bugs.webkit.org/show_bug.cgi?id=162861
+
+        Reviewed by Darin Adler.
+
+        Extend layout test coverage to cover 'Caps Lock' modifier.
+
+        * fast/events/special-key-events-in-input-text-expected.txt:
+        * fast/events/special-key-events-in-input-text.html:
+
 2016-10-05  Zalan Bujtas  <za...@apple.com>
 
         Missing quotation mark when <q> gets reparented.

Modified: trunk/LayoutTests/fast/events/special-key-events-in-input-text-expected.txt (206827 => 206828)


--- trunk/LayoutTests/fast/events/special-key-events-in-input-text-expected.txt	2016-10-05 20:46:15 UTC (rev 206827)
+++ trunk/LayoutTests/fast/events/special-key-events-in-input-text-expected.txt	2016-10-05 21:12:51 UTC (rev 206828)
@@ -1,49 +1,55 @@
 This test verifies that the correct sequence of keyboard events is generated for a keypress for certain special keys. To test manually, press keys and compare results to other browsers.
 
 
-target - type - ctrlKey,altKey,shiftKey,metaKey - key - code - keyIdentifier - keyCode - charCode
+target - type - ctrlKey,altKey,shiftKey,metaKey,capsLockKey - key - code - keyIdentifier - keyCode - charCode
 
 Ampersand:
-INPUT - keydown - false,false,true,false - 7 - Digit7 - U+0037 - 55 - 0. Value: "".
-INPUT - keypress - false,false,true,false - 7 - Digit7 - - 55 - 55. Value: "".
+INPUT - keydown - false,false,true,false,false - 7 - Digit7 - U+0037 - 55 - 0. Value: "".
+INPUT - keypress - false,false,true,false,false - 7 - Digit7 - - 55 - 55. Value: "".
 INPUT - textInput - 7. Value: "".
-INPUT - keyup - false,false,true,false - 7 - Digit7 - U+0037 - 55 - 0. Value: "7".
+INPUT - keyup - false,false,true,false,false - 7 - Digit7 - U+0037 - 55 - 0. Value: "7".
 
 Backspace:
-INPUT - keydown - false,false,false,false - Backspace - Backspace - U+0008 - 8 - 0. Value: "7".
-INPUT - keyup - false,false,false,false - Backspace - Backspace - U+0008 - 8 - 0. Value: "".
+INPUT - keydown - false,false,false,false,false - Backspace - Backspace - U+0008 - 8 - 0. Value: "7".
+INPUT - keyup - false,false,false,false,false - Backspace - Backspace - U+0008 - 8 - 0. Value: "".
 
 Percent:
-INPUT - keydown - false,false,true,false - 5 - Digit5 - U+0035 - 53 - 0. Value: "".
-INPUT - keypress - false,false,true,false - 5 - Digit5 - - 53 - 53. Value: "".
+INPUT - keydown - false,false,true,false,false - 5 - Digit5 - U+0035 - 53 - 0. Value: "".
+INPUT - keypress - false,false,true,false,false - 5 - Digit5 - - 53 - 53. Value: "".
 INPUT - textInput - 5. Value: "".
-INPUT - keyup - false,false,true,false - 5 - Digit5 - U+0035 - 53 - 0. Value: "5".
+INPUT - keyup - false,false,true,false,false - 5 - Digit5 - U+0035 - 53 - 0. Value: "5".
 
 Backspace:
-INPUT - keydown - false,false,false,false - Backspace - Backspace - U+0008 - 8 - 0. Value: "5".
-INPUT - keyup - false,false,false,false - Backspace - Backspace - U+0008 - 8 - 0. Value: "".
+INPUT - keydown - false,false,false,false,false - Backspace - Backspace - U+0008 - 8 - 0. Value: "5".
+INPUT - keyup - false,false,false,false,false - Backspace - Backspace - U+0008 - 8 - 0. Value: "".
 
 Left parenthesis:
-INPUT - keydown - false,false,true,false - 9 - Digit9 - U+0039 - 57 - 0. Value: "".
-INPUT - keypress - false,false,true,false - 9 - Digit9 - - 57 - 57. Value: "".
+INPUT - keydown - false,false,true,false,false - 9 - Digit9 - U+0039 - 57 - 0. Value: "".
+INPUT - keypress - false,false,true,false,false - 9 - Digit9 - - 57 - 57. Value: "".
 INPUT - textInput - 9. Value: "".
-INPUT - keyup - false,false,true,false - 9 - Digit9 - U+0039 - 57 - 0. Value: "9".
+INPUT - keyup - false,false,true,false,false - 9 - Digit9 - U+0039 - 57 - 0. Value: "9".
 
 Backspace:
-INPUT - keydown - false,false,false,false - Backspace - Backspace - U+0008 - 8 - 0. Value: "9".
-INPUT - keyup - false,false,false,false - Backspace - Backspace - U+0008 - 8 - 0. Value: "".
+INPUT - keydown - false,false,false,false,false - Backspace - Backspace - U+0008 - 8 - 0. Value: "9".
+INPUT - keyup - false,false,false,false,false - Backspace - Backspace - U+0008 - 8 - 0. Value: "".
 
 Right parenthesis:
-INPUT - keydown - false,false,true,false - 0 - Digit0 - U+0030 - 48 - 0. Value: "".
-INPUT - keypress - false,false,true,false - 0 - Digit0 - - 48 - 48. Value: "".
+INPUT - keydown - false,false,true,false,false - 0 - Digit0 - U+0030 - 48 - 0. Value: "".
+INPUT - keypress - false,false,true,false,false - 0 - Digit0 - - 48 - 48. Value: "".
 INPUT - textInput - 0. Value: "".
-INPUT - keyup - false,false,true,false - 0 - Digit0 - U+0030 - 48 - 0. Value: "0".
+INPUT - keyup - false,false,true,false,false - 0 - Digit0 - U+0030 - 48 - 0. Value: "0".
 
 Backspace:
-INPUT - keydown - false,false,false,false - Backspace - Backspace - U+0008 - 8 - 0. Value: "0".
-INPUT - keyup - false,false,false,false - Backspace - Backspace - U+0008 - 8 - 0. Value: "".
+INPUT - keydown - false,false,false,false,false - Backspace - Backspace - U+0008 - 8 - 0. Value: "0".
+INPUT - keyup - false,false,false,false,false - Backspace - Backspace - U+0008 - 8 - 0. Value: "".
 
 Print screen:
-INPUT - keydown - false,false,false,false - PrintScreen - KeyA - PrintScreen - 44 - 0. Value: "".
-INPUT - keyup - false,false,false,false - PrintScreen - KeyA - PrintScreen - 44 - 0. Value: "".
+INPUT - keydown - false,false,false,false,false - PrintScreen - KeyA - PrintScreen - 44 - 0. Value: "".
+INPUT - keyup - false,false,false,false,false - PrintScreen - KeyA - PrintScreen - 44 - 0. Value: "".
 
+'a' key with Caps Lock:
+INPUT - keydown - false,false,false,false,true - a - KeyA - U+0041 - 65 - 0. Value: "".
+INPUT - keypress - false,false,false,false,true - a - KeyA - - 97 - 97. Value: "".
+INPUT - textInput - a. Value: "".
+INPUT - keyup - false,false,false,false,true - a - KeyA - U+0041 - 65 - 0. Value: "a".
+

Modified: trunk/LayoutTests/fast/events/special-key-events-in-input-text.html (206827 => 206828)


--- trunk/LayoutTests/fast/events/special-key-events-in-input-text.html	2016-10-05 20:46:15 UTC (rev 206827)
+++ trunk/LayoutTests/fast/events/special-key-events-in-input-text.html	2016-10-05 21:12:51 UTC (rev 206828)
@@ -17,7 +17,7 @@
    if (type == "textInput") {
      info += e.data;
    } else if (type == "keydown" || type == "keypress" || type == "keyup") {
-     info += [e.ctrlKey, e.altKey, e.shiftKey, e.metaKey] +
+     info += [e.ctrlKey, e.altKey, e.shiftKey, e.metaKey, e.getModifierState('CapsLock')] +
          ' - ' + e.key +
          ' - ' + e.code +
          ' - ' + e.keyIdentifier +
@@ -28,7 +28,7 @@
    log(info);
 }
 
-log("target - type - " + ["ctrlKey", "altKey", "shiftKey", "metaKey"]
+log("target - type - " + ["ctrlKey", "altKey", "shiftKey", "metaKey", "capsLockKey"]
        + ' - ' + "key"
        + ' - ' + "code"
        + ' - ' + "keyIdentifier"
@@ -62,6 +62,8 @@
    eventSender.keyDown("\x08", []);
    log("<br>Print screen:");
    eventSender.keyDown("printScreen", []);
+   log("<br>'a' key with Caps Lock:");
+   eventSender.keyDown("a", ["capsLockKey"]);
   }
 </script>
 </body></html>

Modified: trunk/Source/WebCore/ChangeLog (206827 => 206828)


--- trunk/Source/WebCore/ChangeLog	2016-10-05 20:46:15 UTC (rev 206827)
+++ trunk/Source/WebCore/ChangeLog	2016-10-05 21:12:51 UTC (rev 206828)
@@ -1,3 +1,26 @@
+2016-10-05  Chris Dumez  <cdu...@apple.com>
+
+        KeyboardEvent.getModifierState() should support "CapsLock" modifier
+        https://bugs.webkit.org/show_bug.cgi?id=162861
+
+        Reviewed by Darin Adler.
+
+        Add support for "CapsLock" modifier on Mac / iOS for KeyboardEvent's
+        getModifierState() API, as per:
+        - https://w3c.github.io/uievents/#dom-keyboardevent-getmodifierstate
+
+        No new tests, updated existing test.
+
+        * dom/KeyboardEvent.cpp:
+        (WebCore::KeyboardEvent::KeyboardEvent):
+        (WebCore::KeyboardEvent::getModifierState):
+        * dom/KeyboardEvent.h:
+        * platform/PlatformEvent.h:
+        * platform/ios/PlatformEventFactoryIOS.mm:
+        (WebCore::modifiersForEvent):
+        * platform/mac/PlatformEventFactoryMac.mm:
+        (WebCore::keyIdentifierForKeyEvent):
+
 2016-10-05  Michael Catanzaro  <mcatanz...@igalia.com>
 
         [GTK] Improve OS X UA quirk

Modified: trunk/Source/WebCore/dom/KeyboardEvent.cpp (206827 => 206828)


--- trunk/Source/WebCore/dom/KeyboardEvent.cpp	2016-10-05 20:46:15 UTC (rev 206827)
+++ trunk/Source/WebCore/dom/KeyboardEvent.cpp	2016-10-05 21:12:51 UTC (rev 206828)
@@ -108,6 +108,7 @@
     , m_location(keyLocationCode(key))
     , m_repeat(key.isAutoRepeat())
     , m_altGraphKey(false)
+    , m_capsLockKey(key.modifiers().contains(PlatformEvent::Modifier::CapsLockKey))
     , m_isComposing(view && view->frame() && view->frame()->editor().hasComposition())
 #if PLATFORM(COCOA)
 #if USE(APPKIT)
@@ -137,7 +138,8 @@
     , m_keyIdentifier(initializer.keyIdentifier)
     , m_location(initializer.location)
     , m_repeat(initializer.repeat)
-    , m_altGraphKey(false)
+    , m_altGraphKey(false) // FIXME: should be initialized from initializer.modifierAltGraph.
+    , m_capsLockKey(false) // FIXME: should be initialized from initializer.modifierCapsLock.
     , m_isComposing(initializer.isComposing)
 #if PLATFORM(COCOA)
     , m_handledByInputMethod(false)
@@ -179,7 +181,9 @@
         return metaKey();
     if (keyIdentifier == "AltGraph")
         return altGraphKey();
-    // FIXME: We should support CapsLock, Fn, FnLock, Hyper, NumLock, Super, ScrollLock, Symbol, SymbolLock.
+    if (keyIdentifier == "CapsLock")
+        return m_capsLockKey;
+    // FIXME: The specification also has Fn, FnLock, Hyper, NumLock, Super, ScrollLock, Symbol, SymbolLock.
     return false;
 }
 

Modified: trunk/Source/WebCore/dom/KeyboardEvent.h (206827 => 206828)


--- trunk/Source/WebCore/dom/KeyboardEvent.h	2016-10-05 20:46:15 UTC (rev 206827)
+++ trunk/Source/WebCore/dom/KeyboardEvent.h	2016-10-05 21:12:51 UTC (rev 206828)
@@ -136,6 +136,7 @@
     unsigned m_location { DOM_KEY_LOCATION_STANDARD };
     bool m_repeat { false };
     bool m_altGraphKey { false };
+    bool m_capsLockKey { false };
     bool m_isComposing { false };
 
 #if PLATFORM(COCOA)

Modified: trunk/Source/WebCore/platform/PlatformEvent.h (206827 => 206828)


--- trunk/Source/WebCore/platform/PlatformEvent.h	2016-10-05 20:46:15 UTC (rev 206827)
+++ trunk/Source/WebCore/platform/PlatformEvent.h	2016-10-05 21:12:51 UTC (rev 206828)
@@ -74,6 +74,7 @@
         CtrlKey     = 1 << 1,
         MetaKey     = 1 << 2,
         ShiftKey    = 1 << 3,
+        CapsLockKey = 1 << 4,
     };
 
     Type type() const { return static_cast<Type>(m_type); }

Modified: trunk/Source/WebCore/platform/ios/PlatformEventFactoryIOS.mm (206827 => 206828)


--- trunk/Source/WebCore/platform/ios/PlatformEventFactoryIOS.mm	2016-10-05 20:46:15 UTC (rev 206827)
+++ trunk/Source/WebCore/platform/ios/PlatformEventFactoryIOS.mm	2016-10-05 21:12:51 UTC (rev 206828)
@@ -47,6 +47,8 @@
         modifiers |= PlatformEvent::Modifier::AltKey;
     if (event.modifierFlags & WebEventFlagMaskCommand)
         modifiers |= PlatformEvent::Modifier::MetaKey;
+    if (event.modifierFlags & WebEventFlagMaskAlphaShift)
+        modifiers |= PlatformEvent::Modifier::CapsLockKey;
 
     return modifiers;
 }

Modified: trunk/Source/WebCore/platform/mac/PlatformEventFactoryMac.mm (206827 => 206828)


--- trunk/Source/WebCore/platform/mac/PlatformEventFactoryMac.mm	2016-10-05 20:46:15 UTC (rev 206827)
+++ trunk/Source/WebCore/platform/mac/PlatformEventFactoryMac.mm	2016-10-05 21:12:51 UTC (rev 206828)
@@ -690,9 +690,20 @@
 
 static inline OptionSet<PlatformEvent::Modifier> modifiersForEvent(NSEvent *event)
 {
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wdeprecated-declarations"
     OptionSet<PlatformEvent::Modifier> modifiers;
+
+#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101200
+    if (event.modifierFlags & NSEventModifierFlagShift)
+        modifiers |= PlatformEvent::Modifier::ShiftKey;
+    if (event.modifierFlags & NSEventModifierFlagControl)
+        modifiers |= PlatformEvent::Modifier::CtrlKey;
+    if (event.modifierFlags & NSEventModifierFlagOption)
+        modifiers |= PlatformEvent::Modifier::AltKey;
+    if (event.modifierFlags & NSEventModifierFlagCommand)
+        modifiers |= PlatformEvent::Modifier::MetaKey;
+    if (event.modifierFlags & NSEventModifierFlagCapsLock)
+        modifiers |= PlatformEvent::Modifier::CapsLockKey;
+#else
     if (event.modifierFlags & NSShiftKeyMask)
         modifiers |= PlatformEvent::Modifier::ShiftKey;
     if (event.modifierFlags & NSControlKeyMask)
@@ -701,7 +712,10 @@
         modifiers |= PlatformEvent::Modifier::AltKey;
     if (event.modifierFlags & NSCommandKeyMask)
         modifiers |= PlatformEvent::Modifier::MetaKey;
-#pragma clang diagnostic pop
+    if (event.modifierFlags & NSAlphaShiftKeyMask)
+        modifiers |= PlatformEvent::Modifier::CapsLockKey;
+#endif
+
     return modifiers;
 }
 

Modified: trunk/Source/WebKit2/ChangeLog (206827 => 206828)


--- trunk/Source/WebKit2/ChangeLog	2016-10-05 20:46:15 UTC (rev 206827)
+++ trunk/Source/WebKit2/ChangeLog	2016-10-05 21:12:51 UTC (rev 206828)
@@ -1,3 +1,32 @@
+2016-10-05  Chris Dumez  <cdu...@apple.com>
+
+        KeyboardEvent.getModifierState() should support "CapsLock" modifier
+        https://bugs.webkit.org/show_bug.cgi?id=162861
+
+        Reviewed by Darin Adler.
+
+        Add support for CapsLock modifier on events.
+
+        * Shared/API/c/WKEvent.h:
+        * Shared/API/c/WKSharedAPICast.h:
+        (WebKit::toAPI):
+        * Shared/WebEventConversion.cpp:
+        (WebKit::WebKit2PlatformMouseEvent::WebKit2PlatformMouseEvent):
+        (WebKit::WebKit2PlatformWheelEvent::WebKit2PlatformWheelEvent):
+        (WebKit::WebKit2PlatformKeyboardEvent::WebKit2PlatformKeyboardEvent):
+        (WebKit::WebKit2PlatformTouchEvent::WebKit2PlatformTouchEvent):
+        (WebKit::WebKit2PlatformGestureEvent::WebKit2PlatformGestureEvent):
+        * Shared/efl/WebEventFactory.cpp:
+        (WebKit::toWebEventModifiers):
+        * Shared/ios/WebIOSEventFactory.mm:
+        (modifiersForEvent):
+        * Shared/mac/WebEventFactory.mm:
+        (WebKit::modifiersForEvent):
+        * UIProcess/API/Cocoa/WKNavigationAction.mm:
+        (toNSEventModifierFlags):
+        * UIProcess/Cocoa/WebAutomationSessionCocoa.mm:
+        (WebKit::WebAutomationSession::platformSimulateMouseInteraction):
+
 2016-10-05  Zan Dobersek  <zdober...@igalia.com>
 
         Rename ENABLE_ENCRYPTED_MEDIA_V2 to ENABLE_LEGACY_ENCRYPTED_MEDIA

Modified: trunk/Source/WebKit2/Shared/API/c/WKEvent.h (206827 => 206828)


--- trunk/Source/WebKit2/Shared/API/c/WKEvent.h	2016-10-05 20:46:15 UTC (rev 206827)
+++ trunk/Source/WebKit2/Shared/API/c/WKEvent.h	2016-10-05 21:12:51 UTC (rev 206828)
@@ -36,7 +36,8 @@
     kWKEventModifiersShiftKey = 1 << 0,
     kWKEventModifiersControlKey = 1 << 1,
     kWKEventModifiersAltKey = 1 << 2,
-    kWKEventModifiersMetaKey = 1 << 3
+    kWKEventModifiersMetaKey = 1 << 3,
+    kWKEventModifiersCapsLockKey = 1 << 4
 };
 typedef uint32_t WKEventModifiers;
 

Modified: trunk/Source/WebKit2/Shared/API/c/WKSharedAPICast.h (206827 => 206828)


--- trunk/Source/WebKit2/Shared/API/c/WKSharedAPICast.h	2016-10-05 20:46:15 UTC (rev 206827)
+++ trunk/Source/WebKit2/Shared/API/c/WKSharedAPICast.h	2016-10-05 21:12:51 UTC (rev 206828)
@@ -294,6 +294,8 @@
         wkModifiers |= kWKEventModifiersAltKey;
     if (modifiers & WebEvent::MetaKey)
         wkModifiers |= kWKEventModifiersMetaKey;
+    if (modifiers & WebEvent::CapsLockKey)
+        wkModifiers |= kWKEventModifiersCapsLockKey;
     return wkModifiers;
 }
 

Modified: trunk/Source/WebKit2/Shared/WebEventConversion.cpp (206827 => 206828)


--- trunk/Source/WebKit2/Shared/WebEventConversion.cpp	2016-10-05 20:46:15 UTC (rev 206827)
+++ trunk/Source/WebKit2/Shared/WebEventConversion.cpp	2016-10-05 21:12:51 UTC (rev 206828)
@@ -76,6 +76,8 @@
             m_modifiers |= Modifier::AltKey;
         if (webEvent.metaKey())
             m_modifiers |= Modifier::MetaKey;
+        if (webEvent.capsLockKey())
+            m_modifiers |= Modifier::CapsLockKey;
 
         m_timestamp = webEvent.timestamp();
 
@@ -127,6 +129,8 @@
             m_modifiers |= Modifier::AltKey;
         if (webEvent.metaKey())
             m_modifiers |= Modifier::MetaKey;
+        if (webEvent.capsLockKey())
+            m_modifiers |= Modifier::CapsLockKey;
 
         m_timestamp = webEvent.timestamp();
 
@@ -185,6 +189,8 @@
             m_modifiers |= Modifier::AltKey;
         if (webEvent.metaKey())
             m_modifiers |= Modifier::MetaKey;
+        if (webEvent.capsLockKey())
+            m_modifiers |= Modifier::CapsLockKey;
 
         m_timestamp = webEvent.timestamp();
 
@@ -324,6 +330,8 @@
             m_modifiers |= Modifier::AltKey;
         if (webEvent.metaKey())
             m_modifiers |= Modifier::MetaKey;
+        if (webEvent.capsLockKey())
+            m_modifiers |= Modifier::CapsLockKey;
 
         m_timestamp = webEvent.timestamp();
 
@@ -381,6 +389,8 @@
             m_modifiers |= Modifier::AltKey;
         if (webEvent.metaKey())
             m_modifiers |= Modifier::MetaKey;
+        if (webEvent.capsLockKey())
+            m_modifiers |= Modifier::CapsLockKey;
 
         m_timestamp = webEvent.timestamp();
 

Modified: trunk/Source/WebKit2/Shared/efl/WebEventFactory.cpp (206827 => 206828)


--- trunk/Source/WebKit2/Shared/efl/WebEventFactory.cpp	2016-10-05 20:46:15 UTC (rev 206827)
+++ trunk/Source/WebKit2/Shared/efl/WebEventFactory.cpp	2016-10-05 21:12:51 UTC (rev 206828)
@@ -258,6 +258,8 @@
         result |= WebEvent::AltKey;
     if (modifiers & kWKEventModifiersMetaKey)
         result |= WebEvent::MetaKey;
+    if (modifiers & kWKEventModifiersCapsLockKey)
+        result |= WebEvent::CapsLockKey;
 
     return static_cast<WebEvent::Modifiers>(result);
 }

Modified: trunk/Source/WebKit2/Shared/ios/WebIOSEventFactory.mm (206827 => 206828)


--- trunk/Source/WebKit2/Shared/ios/WebIOSEventFactory.mm	2016-10-05 20:46:15 UTC (rev 206827)
+++ trunk/Source/WebKit2/Shared/ios/WebIOSEventFactory.mm	2016-10-05 21:12:51 UTC (rev 206828)
@@ -44,6 +44,8 @@
         modifiers |= WebKit::WebEvent::AltKey;
     if (eventModifierFlags & WebEventFlagMaskCommand)
         modifiers |= WebKit::WebEvent::MetaKey;
+    if (eventModifierFlags & WebEventFlagMaskAlphaShift)
+        modifiers |= WebKit::WebEvent::CapsLockKey;
 
     return static_cast<WebKit::WebEvent::Modifiers>(modifiers);
 }

Modified: trunk/Source/WebKit2/Shared/mac/WebEventFactory.mm (206827 => 206828)


--- trunk/Source/WebKit2/Shared/mac/WebEventFactory.mm	2016-10-05 20:46:15 UTC (rev 206827)
+++ trunk/Source/WebKit2/Shared/mac/WebEventFactory.mm	2016-10-05 21:12:51 UTC (rev 206828)
@@ -338,8 +338,19 @@
 static inline WebEvent::Modifiers modifiersForEvent(NSEvent *event)
 {
     unsigned modifiers = 0;
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wdeprecated-declarations"
+
+#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101200
+    if ([event modifierFlags] & NSEventModifierFlagCapsLock)
+        modifiers |= WebEvent::CapsLockKey;
+    if ([event modifierFlags] & NSEventModifierFlagShift)
+        modifiers |= WebEvent::ShiftKey;
+    if ([event modifierFlags] & NSEventModifierFlagControl)
+        modifiers |= WebEvent::ControlKey;
+    if ([event modifierFlags] & NSEventModifierFlagOption)
+        modifiers |= WebEvent::AltKey;
+    if ([event modifierFlags] & NSEventModifierFlagCommand)
+        modifiers |= WebEvent::MetaKey;
+#else
     if ([event modifierFlags] & NSAlphaShiftKeyMask)
         modifiers |= WebEvent::CapsLockKey;
     if ([event modifierFlags] & NSShiftKeyMask)
@@ -350,7 +361,8 @@
         modifiers |= WebEvent::AltKey;
     if ([event modifierFlags] & NSCommandKeyMask)
         modifiers |= WebEvent::MetaKey;
-#pragma clang diagnostic pop
+#endif
+
     return (WebEvent::Modifiers)modifiers;
 }
 

Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKNavigationAction.mm (206827 => 206828)


--- trunk/Source/WebKit2/UIProcess/API/Cocoa/WKNavigationAction.mm	2016-10-05 20:46:15 UTC (rev 206827)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/WKNavigationAction.mm	2016-10-05 21:12:51 UTC (rev 206828)
@@ -79,9 +79,19 @@
 {
     NSEventModifierFlags modifierFlags = 0;
 
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wdeprecated-declarations"
+#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101200
     if (modifiers & WebKit::WebEvent::CapsLockKey)
+        modifierFlags |= NSEventModifierFlagCapsLock;
+    if (modifiers & WebKit::WebEvent::ShiftKey)
+        modifierFlags |= NSEventModifierFlagShift;
+    if (modifiers & WebKit::WebEvent::ControlKey)
+        modifierFlags |= NSEventModifierFlagControl;
+    if (modifiers & WebKit::WebEvent::AltKey)
+        modifierFlags |= NSEventModifierFlagOption;
+    if (modifiers & WebKit::WebEvent::MetaKey)
+        modifierFlags |= NSEventModifierFlagCommand;
+#else
+    if (modifiers & WebKit::WebEvent::CapsLockKey)
         modifierFlags |= NSAlphaShiftKeyMask;
     if (modifiers & WebKit::WebEvent::ShiftKey)
         modifierFlags |= NSShiftKeyMask;
@@ -91,7 +101,8 @@
         modifierFlags |= NSAlternateKeyMask;
     if (modifiers & WebKit::WebEvent::MetaKey)
         modifierFlags |= NSCommandKeyMask;
-#pragma clang diagnostic pop
+#endif
+
     return modifierFlags;
 }
 

Modified: trunk/Source/WebKit2/UIProcess/Cocoa/WebAutomationSessionCocoa.mm (206827 => 206828)


--- trunk/Source/WebKit2/UIProcess/Cocoa/WebAutomationSessionCocoa.mm	2016-10-05 20:46:15 UTC (rev 206827)
+++ trunk/Source/WebKit2/UIProcess/Cocoa/WebAutomationSessionCocoa.mm	2016-10-05 21:12:51 UTC (rev 206828)
@@ -107,6 +107,8 @@
         modifiers |= NSEventModifierFlagControl;
     if (keyModifiers & WebEvent::ShiftKey)
         modifiers |= NSEventModifierFlagShift;
+    if (keyModifiers & WebEvent::CapsLockKey)
+        modifiers |= NSEventModifierFlagCapsLock;
 
     NSTimeInterval timestamp = [NSDate timeIntervalSinceReferenceDate];
     NSWindow *window = page.platformWindow();

Modified: trunk/Tools/ChangeLog (206827 => 206828)


--- trunk/Tools/ChangeLog	2016-10-05 20:46:15 UTC (rev 206827)
+++ trunk/Tools/ChangeLog	2016-10-05 21:12:51 UTC (rev 206828)
@@ -1,3 +1,20 @@
+2016-10-05  Chris Dumez  <cdu...@apple.com>
+
+        KeyboardEvent.getModifierState() should support "CapsLock" modifier
+        https://bugs.webkit.org/show_bug.cgi?id=162861
+
+        Reviewed by Darin Adler.
+
+        Add support for 'capsLockKey' modifier for EventSender.keyDown() so
+        that we can test this new modifier support for layout tests.
+
+        * TestWebKitAPI/mac/PlatformWebViewMac.mm:
+        (TestWebKitAPI::modifierFlagsForWKModifiers):
+        * WebKitTestRunner/InjectedBundle/EventSendingController.cpp:
+        (WTR::parseModifier):
+        * WebKitTestRunner/mac/EventSenderProxy.mm:
+        (WTR::buildModifierFlags):
+
 2016-10-05  Jeremy Jones  <jere...@apple.com>
 
         Add MobileMiniBrowser tests for control center and looping fullscreen.

Modified: trunk/Tools/DumpRenderTree/mac/EventSendingController.mm (206827 => 206828)


--- trunk/Tools/DumpRenderTree/mac/EventSendingController.mm	2016-10-05 20:46:15 UTC (rev 206827)
+++ trunk/Tools/DumpRenderTree/mac/EventSendingController.mm	2016-10-05 21:12:51 UTC (rev 206828)
@@ -437,11 +437,13 @@
     const int shiftKeyMask = NSShiftKeyMask;
     const int alternateKeyMask = NSAlternateKeyMask;
     const int commandKeyMask = NSCommandKeyMask;
+    const int capsLockKeyMask = NSAlphaShiftKeyMask;
 #else
     const int controlKeyMask = WebEventFlagMaskControl;
     const int shiftKeyMask = WebEventFlagMaskShift;
     const int alternateKeyMask = WebEventFlagMaskAlternate;
     const int commandKeyMask = WebEventFlagMaskCommand;
+    const int capsLockKeyMask = WebEventFlagMaskAlphaShift;
 #endif
 
     int flags = 0;
@@ -453,6 +455,8 @@
         flags |= alternateKeyMask;
     else if ([modifierName isEqual:@"metaKey"] || [modifierName isEqual:@"addSelectionKey"])
         flags |= commandKeyMask;
+    else if ([modifierName isEqual:@"capsLockKey"])
+        flags |= capsLockKeyMask;
 
     return flags;
 }

Modified: trunk/Tools/TestWebKitAPI/mac/PlatformWebViewMac.mm (206827 => 206828)


--- trunk/Tools/TestWebKitAPI/mac/PlatformWebViewMac.mm	2016-10-05 20:46:15 UTC (rev 206827)
+++ trunk/Tools/TestWebKitAPI/mac/PlatformWebViewMac.mm	2016-10-05 21:12:51 UTC (rev 206828)
@@ -220,6 +220,8 @@
         returnVal |= NSAlternateKeyMask;
     if (modifiers & kWKEventModifiersMetaKey)
         returnVal |= NSCommandKeyMask;
+    if (modifiers & kWKEventModifiersCapsLockKey)
+        returnVal |= NSAlphaShiftKeyMask;
 
     return returnVal;
 }

Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/EventSendingController.cpp (206827 => 206828)


--- trunk/Tools/WebKitTestRunner/InjectedBundle/EventSendingController.cpp	2016-10-05 20:46:15 UTC (rev 206827)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/EventSendingController.cpp	2016-10-05 21:12:51 UTC (rev 206828)
@@ -116,6 +116,8 @@
         return kWKEventModifiersAltKey;
     if (JSStringIsEqualToUTF8CString(modifier, "metaKey"))
         return kWKEventModifiersMetaKey;
+    if (JSStringIsEqualToUTF8CString(modifier, "capsLockKey"))
+        return kWKEventModifiersCapsLockKey;
     if (JSStringIsEqualToUTF8CString(modifier, "addSelectionKey")) {
 #if OS(MAC_OS_X)
         return kWKEventModifiersMetaKey;

Modified: trunk/Tools/WebKitTestRunner/mac/EventSenderProxy.mm (206827 => 206828)


--- trunk/Tools/WebKitTestRunner/mac/EventSenderProxy.mm	2016-10-05 20:46:15 UTC (rev 206827)
+++ trunk/Tools/WebKitTestRunner/mac/EventSenderProxy.mm	2016-10-05 21:12:51 UTC (rev 206828)
@@ -250,6 +250,8 @@
         flags |= NSAlternateKeyMask;
     if (modifiers & kWKEventModifiersMetaKey)
         flags |= NSCommandKeyMask;
+    if (modifiers & kWKEventModifiersCapsLockKey)
+        flags |= NSAlphaShiftKeyMask;
     return flags;
 }
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to