Title: [237886] trunk
Revision
237886
Author
pvol...@apple.com
Date
2018-11-06 13:58:29 -0800 (Tue, 06 Nov 2018)

Log Message

REGRESSION (r230523): Caps lock indicator not shown in password field
https://bugs.webkit.org/show_bug.cgi?id=190056

Reviewed by Ryosuke Niwa.

Source/WebCore:

When WindowServer access is blocked, GetCurrentModifiers() always returns 0. Instead of calling
GetCurrentModifiers(), store the current modifiers from the key event argument in the method
WebKit::WebPage::keyEvent, and use the stored value to detect if Caps lock is on. Additionally,
the modifiers needs to be updated when the window becomes active.

Test: fast/events/detect-caps-lock.html

* Sources.txt:
* platform/PlatformKeyboardEvent.h:
* platform/graphics/FontTaggedSettings.cpp:
* platform/mac/KeyEventMac.mm:
(WebCore::PlatformKeyboardEvent::currentCapsLockState):
(WebCore::PlatformKeyboardEvent::getCurrentModifierState):
* testing/Internals.cpp:
(WebCore::Internals::capsLockIsOn):
* testing/Internals.h:
* testing/Internals.idl:

Source/WebKit:

Update cached modifier state in the WebProcess when WebKit::WebPage::keyEvent is called, and
when the window becomes active.

* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::dispatchActivityStateChange):
(WebKit::WebPageProxy::updateCurrentModifierState):
* UIProcess/WebPageProxy.h:
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::keyEvent):
(WebKit::WebPage::updateCurrentModifierState):
* WebProcess/WebPage/WebPage.h:
* WebProcess/WebPage/WebPage.messages.in:

Tools:

* WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl:
* WebKitTestRunner/InjectedBundle/TestRunner.cpp:
(WTR::TestRunner::toggleCapsLock):
* WebKitTestRunner/InjectedBundle/TestRunner.h:
* WebKitTestRunner/TestController.h:
* WebKitTestRunner/TestInvocation.cpp:
(WTR::TestInvocation::didReceiveSynchronousMessageFromInjectedBundle):
* WebKitTestRunner/cocoa/TestControllerCocoa.mm:
(WTR::TestController::toggleCapsLock):

LayoutTests:

* TestExpectations:
* fast/events/detect-caps-lock-expected.txt: Added.
* fast/events/detect-caps-lock.html: Added.
* platform/mac/TestExpectations:

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (237885 => 237886)


--- trunk/LayoutTests/ChangeLog	2018-11-06 21:53:21 UTC (rev 237885)
+++ trunk/LayoutTests/ChangeLog	2018-11-06 21:58:29 UTC (rev 237886)
@@ -1,3 +1,15 @@
+2018-11-06  Per Arne Vollan  <pvol...@apple.com>
+
+        REGRESSION (r230523): Caps lock indicator not shown in password field
+        https://bugs.webkit.org/show_bug.cgi?id=190056
+
+        Reviewed by Ryosuke Niwa.
+
+        * TestExpectations:
+        * fast/events/detect-caps-lock-expected.txt: Added.
+        * fast/events/detect-caps-lock.html: Added.
+        * platform/mac/TestExpectations:
+
 2018-11-06  Ali Juma  <aj...@chromium.org>
 
         IntersectionObserver doesn't keep target's JS wrapper alive

Modified: trunk/LayoutTests/TestExpectations (237885 => 237886)


--- trunk/LayoutTests/TestExpectations	2018-11-06 21:53:21 UTC (rev 237885)
+++ trunk/LayoutTests/TestExpectations	2018-11-06 21:58:29 UTC (rev 237886)
@@ -422,6 +422,8 @@
 
 fast/misc/valid-primary-screen-displayID.html [ Skip ]
 
+fast/events/detect-caps-lock.html [ Skip ]
+
 # This test currently only works for mac-wk2
 fast/events/inactive-window-no-mouse-event.html [ Skip ]
 

Added: trunk/LayoutTests/fast/events/detect-caps-lock-expected.txt (0 => 237886)


--- trunk/LayoutTests/fast/events/detect-caps-lock-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/events/detect-caps-lock-expected.txt	2018-11-06 21:58:29 UTC (rev 237886)
@@ -0,0 +1,16 @@
+This test verifies that the function WebCore::currentCapsLockState() returns true when Caps Lock is on.
+
+
+1. Press Caps Lock key when view is active, make view inactive, make view active again, press Caps Lock key.
+CapsLock is on.
+CapsLock is not on.
+2. Press Caps Lock key in inactive view, make view active, press Caps Lock key.
+CapsLock is on.
+CapsLock is not on.
+3. Press Caps Lock key when view is active, press Caps Lock key when view is active.
+CapsLock is on.
+CapsLock is not on.
+4. Press Caps Lock key when view is inactive, press Caps Lock key when view inactive.
+CapsLock is on.
+CapsLock is not on.
+

Added: trunk/LayoutTests/fast/events/detect-caps-lock.html (0 => 237886)


--- trunk/LayoutTests/fast/events/detect-caps-lock.html	                        (rev 0)
+++ trunk/LayoutTests/fast/events/detect-caps-lock.html	2018-11-06 21:58:29 UTC (rev 237886)
@@ -0,0 +1,73 @@
+<!DOCTYPE html>
+<html><head></head>
+    <body>
+        <p>This test verifies that the function WebCore::currentCapsLockState() returns true when Caps Lock is on.</p>
+        <input type="password"></input>
+        <div id="log"></div>
+        
+        <script>
+            function log(msg) {
+                document.getElementById("log").innerHTML+= msg + "<br>";
+            }
+        
+            function keyDown(e) {
+                if (e.key == "q")
+                    return;
+                if (window.internals) {
+                    log(messages[messageCount++]);
+                    if (window.internals.capsLockIsOn())
+                        log("CapsLock is on.");
+                    else
+                        log("CapsLock is not on.");
+                }
+            }
+
+            function keyUp(e) {
+                if (e.key == "q")
+                    testRunner.notifyDone();
+                if (window.internals) {
+                    if (window.internals.capsLockIsOn())
+                        log("CapsLock is on.");
+                    else
+                        log("CapsLock is not on.");
+                }
+            }
+
+            var messages = ["1. Press Caps Lock key when view is active, make view inactive, make view active again, press Caps Lock key.",
+                            "2. Press Caps Lock key in inactive view, make view active, press Caps Lock key.",
+                            "3. Press Caps Lock key when view is active, press Caps Lock key when view is active.",
+                            "4. Press Caps Lock key when view is inactive, press Caps Lock key when view inactive."];
+            var messageCount = 0;
+        
+            var input = document.getElementsByTagName("input")[0];
+            input.addEventListener('keydown', keyDown, false);
+            input.addEventListener('keyup', keyUp, false);
+            input.focus();
+            
+            if (window.testRunner) {
+                testRunner.dumpAsText();
+                testRunner.waitUntilDone();
+                
+                testRunner.toggleCapsLock();
+                testRunner.setWindowIsKey(false);
+                testRunner.setWindowIsKey(true);
+                testRunner.toggleCapsLock();
+                
+                testRunner.setWindowIsKey(false);
+                testRunner.toggleCapsLock();
+                testRunner.setWindowIsKey(true);
+                testRunner.toggleCapsLock();
+
+                testRunner.setWindowIsKey(true);
+                testRunner.toggleCapsLock();
+                testRunner.toggleCapsLock();
+
+                testRunner.setWindowIsKey(false);
+                testRunner.toggleCapsLock();
+                testRunner.toggleCapsLock();
+
+                eventSender.keyDown("q", []);
+            }
+        </script>
+    </body>
+</html>

Modified: trunk/LayoutTests/platform/mac/TestExpectations (237885 => 237886)


--- trunk/LayoutTests/platform/mac/TestExpectations	2018-11-06 21:53:21 UTC (rev 237885)
+++ trunk/LayoutTests/platform/mac/TestExpectations	2018-11-06 21:58:29 UTC (rev 237886)
@@ -40,6 +40,8 @@
 fast/text/mac [ Pass ]
 webkit.org/b/181964 fast/text/mac/select-character-before-zero-width-joiner.html [ ImageOnlyFailure ]
 
+[ Mojave+ ] fast/events/detect-caps-lock.html [ Pass ]
+
 #//////////////////////////////////////////////////////////////////////////////////////////
 # End platform-specific directories.
 #//////////////////////////////////////////////////////////////////////////////////////////

Modified: trunk/Source/WebCore/ChangeLog (237885 => 237886)


--- trunk/Source/WebCore/ChangeLog	2018-11-06 21:53:21 UTC (rev 237885)
+++ trunk/Source/WebCore/ChangeLog	2018-11-06 21:58:29 UTC (rev 237886)
@@ -1,3 +1,28 @@
+2018-11-06  Per Arne Vollan  <pvol...@apple.com>
+
+        REGRESSION (r230523): Caps lock indicator not shown in password field
+        https://bugs.webkit.org/show_bug.cgi?id=190056
+
+        Reviewed by Ryosuke Niwa.
+
+        When WindowServer access is blocked, GetCurrentModifiers() always returns 0. Instead of calling
+        GetCurrentModifiers(), store the current modifiers from the key event argument in the method
+        WebKit::WebPage::keyEvent, and use the stored value to detect if Caps lock is on. Additionally,
+        the modifiers needs to be updated when the window becomes active.
+
+        Test: fast/events/detect-caps-lock.html
+
+        * Sources.txt:
+        * platform/PlatformKeyboardEvent.h:
+        * platform/graphics/FontTaggedSettings.cpp:
+        * platform/mac/KeyEventMac.mm:
+        (WebCore::PlatformKeyboardEvent::currentCapsLockState):
+        (WebCore::PlatformKeyboardEvent::getCurrentModifierState):
+        * testing/Internals.cpp:
+        (WebCore::Internals::capsLockIsOn):
+        * testing/Internals.h:
+        * testing/Internals.idl:
+
 2018-11-06  Javier Fernandez  <jfernan...@igalia.com>
 
         CSS grid elements with justify-content: space-around have extra whitespace, sometimes a lot

Modified: trunk/Source/WebCore/Sources.txt (237885 => 237886)


--- trunk/Source/WebCore/Sources.txt	2018-11-06 21:53:21 UTC (rev 237885)
+++ trunk/Source/WebCore/Sources.txt	2018-11-06 21:58:29 UTC (rev 237886)
@@ -1542,6 +1542,7 @@
 platform/NotImplemented.cpp
 platform/Pasteboard.cpp
 platform/PasteboardWriterData.cpp
+platform/PlatformKeyboardEvent.cpp
 platform/PlatformSpeechSynthesisUtterance.cpp
 platform/PlatformSpeechSynthesisVoice.cpp
 platform/PlatformSpeechSynthesizer.cpp

Added: trunk/Source/WebCore/platform/PlatformKeyboardEvent.cpp (0 => 237886)


--- trunk/Source/WebCore/platform/PlatformKeyboardEvent.cpp	                        (rev 0)
+++ trunk/Source/WebCore/platform/PlatformKeyboardEvent.cpp	2018-11-06 21:58:29 UTC (rev 237886)
@@ -0,0 +1,41 @@
+/*
+ * Copyright (C) 2018 Apple 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``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 INC. OR
+ * 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 "PlatformKeyboardEvent.h"
+
+#include <wtf/MainThread.h>
+
+namespace WebCore {
+
+std::optional<OptionSet<PlatformEvent::Modifier>> PlatformKeyboardEvent::s_currentModifiers;    
+
+void PlatformKeyboardEvent::setCurrentModifierState(OptionSet<Modifier> modifiers)
+{
+    ASSERT(isMainThread());
+    s_currentModifiers = modifiers;
+}
+
+}

Modified: trunk/Source/WebCore/platform/PlatformKeyboardEvent.h (237885 => 237886)


--- trunk/Source/WebCore/platform/PlatformKeyboardEvent.h	2018-11-06 21:53:21 UTC (rev 237885)
+++ trunk/Source/WebCore/platform/PlatformKeyboardEvent.h	2018-11-06 21:58:29 UTC (rev 237886)
@@ -135,8 +135,10 @@
         bool isKeypad() const { return m_isKeypad; }
         bool isSystemKey() const { return m_isSystemKey; }
 
-        static bool currentCapsLockState();
-        static void getCurrentModifierState(bool& shiftKey, bool& ctrlKey, bool& altKey, bool& metaKey);
+        WEBCORE_EXPORT static bool currentCapsLockState();
+        WEBCORE_EXPORT static void getCurrentModifierState(bool& shiftKey, bool& ctrlKey, bool& altKey, bool& metaKey);
+        WEBCORE_EXPORT static void setCurrentModifierState(OptionSet<Modifier>);
+        WEBCORE_EXPORT static OptionSet<Modifier> currentStateOfModifierKeys();
 
 #if PLATFORM(COCOA)
 #if !PLATFORM(IOS_FAMILY)
@@ -206,6 +208,9 @@
         GdkEventKey* m_gdkEventKey;
         CompositionResults m_compositionResults;
 #endif
+        
+        // The modifier state is optional, since it is not needed in the UI process or in legacy WebKit.
+        static std::optional<OptionSet<Modifier>> s_currentModifiers;
     };
     
 } // namespace WebCore

Modified: trunk/Source/WebCore/platform/graphics/cairo/GraphicsContextImplCairo.cpp (237885 => 237886)


--- trunk/Source/WebCore/platform/graphics/cairo/GraphicsContextImplCairo.cpp	2018-11-06 21:53:21 UTC (rev 237885)
+++ trunk/Source/WebCore/platform/graphics/cairo/GraphicsContextImplCairo.cpp	2018-11-06 21:58:29 UTC (rev 237886)
@@ -30,10 +30,14 @@
 #if USE(CAIRO)
 
 #include "CairoOperations.h"
+#include "FloatRoundedRect.h"
 #include "Font.h"
 #include "GlyphBuffer.h"
 #include "GraphicsContextPlatformPrivateCairo.h"
+#include "ImageBuffer.h"
+#include "IntRect.h"
 
+
 namespace WebCore {
 
 GraphicsContext::GraphicsContextImplFactory GraphicsContextImplCairo::createFactory(PlatformContextCairo& platformContext)

Modified: trunk/Source/WebCore/platform/mac/KeyEventMac.mm (237885 => 237886)


--- trunk/Source/WebCore/platform/mac/KeyEventMac.mm	2018-11-06 21:53:21 UTC (rev 237885)
+++ trunk/Source/WebCore/platform/mac/KeyEventMac.mm	2018-11-06 21:58:29 UTC (rev 237886)
@@ -32,6 +32,7 @@
 #import "Logging.h"
 #import "WindowsKeyboardCodes.h"
 #import <Carbon/Carbon.h>
+#import <wtf/MainThread.h>
 
 namespace WebCore {
 using namespace WTF;
@@ -259,16 +260,43 @@
 
 bool PlatformKeyboardEvent::currentCapsLockState()
 {
-    return GetCurrentKeyModifiers() & alphaLock;
+    auto currentModifiers = currentStateOfModifierKeys();
+    return currentModifiers.contains(PlatformEvent::Modifier::CapsLockKey);
 }
 
 void PlatformKeyboardEvent::getCurrentModifierState(bool& shiftKey, bool& ctrlKey, bool& altKey, bool& metaKey)
 {
+    auto currentModifiers = currentStateOfModifierKeys();
+    shiftKey = currentModifiers.contains(PlatformEvent::Modifier::ShiftKey);
+    ctrlKey = currentModifiers.contains(PlatformEvent::Modifier::CtrlKey);
+    altKey = currentModifiers.contains(PlatformEvent::Modifier::AltKey);
+    metaKey = currentModifiers.contains(PlatformEvent::Modifier::MetaKey);
+}
+
+OptionSet<PlatformEvent::Modifier> PlatformKeyboardEvent::currentStateOfModifierKeys()
+{
+#if ENABLE(WEBPROCESS_WINDOWSERVER_BLOCKING)
+    // s_currentModifiers is only set in the WebContent process, not in the UI process.
+    if (s_currentModifiers) {
+        ASSERT(isMainThread());
+        return *s_currentModifiers;
+    }
+#endif
     UInt32 currentModifiers = GetCurrentKeyModifiers();
-    shiftKey = currentModifiers & ::shiftKey;
-    ctrlKey = currentModifiers & ::controlKey;
-    altKey = currentModifiers & ::optionKey;
-    metaKey = currentModifiers & ::cmdKey;
+
+    OptionSet<PlatformEvent::Modifier> modifiers;
+    if (currentModifiers & ::shiftKey)
+        modifiers.add(PlatformEvent::Modifier::ShiftKey);
+    if (currentModifiers & ::controlKey)
+        modifiers.add(PlatformEvent::Modifier::CtrlKey);
+    if (currentModifiers & ::optionKey)
+        modifiers.add(PlatformEvent::Modifier::AltKey);
+    if (currentModifiers & ::cmdKey)
+        modifiers.add(PlatformEvent::Modifier::MetaKey);
+    if (currentModifiers & ::alphaLock)
+        modifiers.add(PlatformEvent::Modifier::CapsLockKey);
+
+    return modifiers;
 }
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/platform/mediarecorder/MediaRecorderPrivate.h (237885 => 237886)


--- trunk/Source/WebCore/platform/mediarecorder/MediaRecorderPrivate.h	2018-11-06 21:53:21 UTC (rev 237885)
+++ trunk/Source/WebCore/platform/mediarecorder/MediaRecorderPrivate.h	2018-11-06 21:58:29 UTC (rev 237886)
@@ -24,6 +24,8 @@
 
 #pragma once
 
+#include <wtf/Forward.h>
+
 #if ENABLE(MEDIA_STREAM)
 
 namespace WTF {

Modified: trunk/Source/WebCore/testing/Internals.cpp (237885 => 237886)


--- trunk/Source/WebCore/testing/Internals.cpp	2018-11-06 21:53:21 UTC (rev 237885)
+++ trunk/Source/WebCore/testing/Internals.cpp	2018-11-06 21:58:29 UTC (rev 237886)
@@ -121,6 +121,7 @@
 #include "PageCache.h"
 #include "PageOverlay.h"
 #include "PathUtilities.h"
+#include "PlatformKeyboardEvent.h"
 #include "PlatformMediaSessionManager.h"
 #include "PlatformScreen.h"
 #include "PlatformStrategies.h"
@@ -4736,6 +4737,11 @@
 #endif
 }
 
+bool Internals::capsLockIsOn()
+{
+    return WebCore::PlatformKeyboardEvent::currentCapsLockState();
+}
+
 bool Internals::supportsVCPEncoder()
 {
 #if defined(ENABLE_VCP_ENCODER)

Modified: trunk/Source/WebCore/testing/Internals.h (237885 => 237886)


--- trunk/Source/WebCore/testing/Internals.h	2018-11-06 21:53:21 UTC (rev 237885)
+++ trunk/Source/WebCore/testing/Internals.h	2018-11-06 21:58:29 UTC (rev 237886)
@@ -738,6 +738,8 @@
 
     unsigned primaryScreenDisplayID();
 
+    bool capsLockIsOn();
+        
     bool supportsVCPEncoder();
         
     using HEVCParameterSet = WebCore::HEVCParameterSet;

Modified: trunk/Source/WebCore/testing/Internals.idl (237885 => 237886)


--- trunk/Source/WebCore/testing/Internals.idl	2018-11-06 21:53:21 UTC (rev 237885)
+++ trunk/Source/WebCore/testing/Internals.idl	2018-11-06 21:58:29 UTC (rev 237886)
@@ -709,6 +709,8 @@
 
     unsigned long primaryScreenDisplayID();
 
+    boolean capsLockIsOn();
+
     boolean supportsVCPEncoder();
 
     HEVCParameterSet? parseHEVCCodecParameters(DOMString codecParameters);

Modified: trunk/Source/WebKit/ChangeLog (237885 => 237886)


--- trunk/Source/WebKit/ChangeLog	2018-11-06 21:53:21 UTC (rev 237885)
+++ trunk/Source/WebKit/ChangeLog	2018-11-06 21:58:29 UTC (rev 237886)
@@ -1,3 +1,23 @@
+2018-11-06  Per Arne Vollan  <pvol...@apple.com>
+
+        REGRESSION (r230523): Caps lock indicator not shown in password field
+        https://bugs.webkit.org/show_bug.cgi?id=190056
+
+        Reviewed by Ryosuke Niwa.
+
+        Update cached modifier state in the WebProcess when WebKit::WebPage::keyEvent is called, and
+        when the window becomes active.
+
+        * UIProcess/WebPageProxy.cpp:
+        (WebKit::WebPageProxy::dispatchActivityStateChange):
+        (WebKit::WebPageProxy::updateCurrentModifierState):
+        * UIProcess/WebPageProxy.h:
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::keyEvent):
+        (WebKit::WebPage::updateCurrentModifierState):
+        * WebProcess/WebPage/WebPage.h:
+        * WebProcess/WebPage/WebPage.messages.in:
+
 2018-11-06  Alex Christensen  <achristen...@webkit.org>
 
         Add ObjC SPI equivalent of WKContextHandlesSafeBrowsing

Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.cpp (237885 => 237886)


--- trunk/Source/WebKit/UIProcess/WebPageProxy.cpp	2018-11-06 21:53:21 UTC (rev 237885)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.cpp	2018-11-06 21:58:29 UTC (rev 237886)
@@ -145,6 +145,7 @@
 #include <WebCore/MIMETypeRegistry.h>
 #include <WebCore/MediaStreamRequest.h>
 #include <WebCore/PerformanceLoggingClient.h>
+#include <WebCore/PlatformEvent.h>
 #include <WebCore/PublicSuffix.h>
 #include <WebCore/RenderEmbeddedObject.h>
 #include <WebCore/ResourceLoadStatistics.h>
@@ -1561,6 +1562,9 @@
     if (changed)
         LOG_WITH_STREAM(ActivityState, stream << "WebPageProxy " << pageID() << " dispatchActivityStateChange: state changed from " << previousActivityState << " to " << m_activityState);
 
+    if ((changed & ActivityState::WindowIsActive) && isViewWindowActive())
+        updateCurrentModifierState();
+
     if ((m_potentiallyChangedActivityStateFlags & ActivityState::IsVisible) && isViewVisible())
         viewIsBecomingVisible();
 
@@ -8125,6 +8129,14 @@
     result = isViewVisible();
 }
 
+void WebPageProxy::updateCurrentModifierState()
+{
+#if PLATFORM(MAC) && ENABLE(WEBPROCESS_WINDOWSERVER_BLOCKING)
+    auto modifiers = PlatformKeyboardEvent::currentStateOfModifierKeys();
+    m_process->send(Messages::WebPage::UpdateCurrentModifierState(modifiers), m_pageID);
+#endif
+}
+
 } // namespace WebKit
 
 #undef MERGE_WHEEL_EVENTS

Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.h (237885 => 237886)


--- trunk/Source/WebKit/UIProcess/WebPageProxy.h	2018-11-06 21:53:21 UTC (rev 237885)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.h	2018-11-06 21:58:29 UTC (rev 237886)
@@ -1851,6 +1851,8 @@
     void stopDisplayLink(unsigned observerID);
 #endif
 
+    void updateCurrentModifierState();
+
     void reportPageLoadResult(const WebCore::ResourceError& = { });
 
     void continueNavigationInNewProcess(API::Navigation&, Ref<WebProcessProxy>&&);

Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp (237885 => 237886)


--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp	2018-11-06 21:53:21 UTC (rev 237885)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp	2018-11-06 21:58:29 UTC (rev 237886)
@@ -2564,6 +2564,8 @@
 
     m_userActivityHysteresis.impulse();
 
+    PlatformKeyboardEvent::setCurrentModifierState(platform(keyboardEvent).modifiers());
+
     CurrentEvent currentEvent(keyboardEvent);
 
     bool handled = handleKeyEvent(keyboardEvent, m_page.get());
@@ -6311,6 +6313,11 @@
 }
 #endif // ENABLE(APPLICATION_MANIFEST)
 
+void WebPage::updateCurrentModifierState(OptionSet<PlatformEvent::Modifier> modifiers)
+{
+    PlatformKeyboardEvent::setCurrentModifierState(modifiers);
+}    
+
 } // namespace WebKit
 
 #undef RELEASE_LOG_IF_ALLOWED

Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.h (237885 => 237886)


--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.h	2018-11-06 21:53:21 UTC (rev 237885)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.h	2018-11-06 21:58:29 UTC (rev 237886)
@@ -1091,6 +1091,8 @@
     void didFinishLoadingApplicationManifest(uint64_t, const std::optional<WebCore::ApplicationManifest>&);
 #endif
 
+    void updateCurrentModifierState(OptionSet<WebCore::PlatformEvent::Modifier> modifiers);
+
     UserContentControllerIdentifier userContentControllerIdentifier() const { return m_userContentController->identifier(); }
 
     WebCore::UserInterfaceLayoutDirection userInterfaceLayoutDirection() const { return m_userInterfaceLayoutDirection; }

Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.messages.in (237885 => 237886)


--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.messages.in	2018-11-06 21:53:21 UTC (rev 237885)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.messages.in	2018-11-06 21:58:29 UTC (rev 237886)
@@ -527,4 +527,6 @@
 #endif
 
     SetDefersLoading(bool defersLoading)
+
+    UpdateCurrentModifierState(OptionSet<WebCore::PlatformEvent::Modifier> modifiers)
 }

Modified: trunk/Tools/ChangeLog (237885 => 237886)


--- trunk/Tools/ChangeLog	2018-11-06 21:53:21 UTC (rev 237885)
+++ trunk/Tools/ChangeLog	2018-11-06 21:58:29 UTC (rev 237886)
@@ -1,3 +1,20 @@
+2018-11-06  Per Arne Vollan  <pvol...@apple.com>
+
+        REGRESSION (r230523): Caps lock indicator not shown in password field
+        https://bugs.webkit.org/show_bug.cgi?id=190056
+
+        Reviewed by Ryosuke Niwa.
+
+        * WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl:
+        * WebKitTestRunner/InjectedBundle/TestRunner.cpp:
+        (WTR::TestRunner::toggleCapsLock):
+        * WebKitTestRunner/InjectedBundle/TestRunner.h:
+        * WebKitTestRunner/TestController.h:
+        * WebKitTestRunner/TestInvocation.cpp:
+        (WTR::TestInvocation::didReceiveSynchronousMessageFromInjectedBundle):
+        * WebKitTestRunner/cocoa/TestControllerCocoa.mm:
+        (WTR::TestController::toggleCapsLock):
+
 2018-11-06  Sihui Liu  <sihui_...@apple.com>
 
         IndexedDB: WAL file keeps growing

Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl (237885 => 237886)


--- trunk/Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl	2018-11-06 21:53:21 UTC (rev 237885)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl	2018-11-06 21:58:29 UTC (rev 237886)
@@ -359,4 +359,6 @@
     void addTestKeyToKeychain(DOMString privateKeyBase64, DOMString attrLabel, DOMString applicationTagBase64);
     void cleanUpKeychain(DOMString attrLabel);
     boolean keyExistsInKeychain(DOMString attrLabel, DOMString applicationTagBase64);
+
+    void toggleCapsLock();
 };

Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp (237885 => 237886)


--- trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp	2018-11-06 21:53:21 UTC (rev 237885)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp	2018-11-06 21:58:29 UTC (rev 237886)
@@ -2513,4 +2513,10 @@
     return WKBooleanGetValue(static_cast<WKBooleanRef>(returnData));
 }
 
+void TestRunner::toggleCapsLock()
+{
+    WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithUTF8CString("ToggleCapsLock"));
+    WKBundlePostSynchronousMessage(InjectedBundle::singleton().bundle(), messageName.get(), nullptr, nullptr);
+}
+
 } // namespace WTR

Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.h (237885 => 237886)


--- trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.h	2018-11-06 21:53:21 UTC (rev 237885)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.h	2018-11-06 21:58:29 UTC (rev 237886)
@@ -477,6 +477,8 @@
     void cleanUpKeychain(JSStringRef attrLabel);
     bool keyExistsInKeychain(JSStringRef attrLabel, JSStringRef applicationTagBase64);
 
+    void toggleCapsLock();
+
 private:
     TestRunner();
 

Modified: trunk/Tools/WebKitTestRunner/TestController.h (237885 => 237886)


--- trunk/Tools/WebKitTestRunner/TestController.h	2018-11-06 21:53:21 UTC (rev 237885)
+++ trunk/Tools/WebKitTestRunner/TestController.h	2018-11-06 21:58:29 UTC (rev 237886)
@@ -260,6 +260,8 @@
     void cleanUpKeychain(const String& attrLabel);
     bool keyExistsInKeychain(const String& attrLabel, const String& applicationTagBase64);
 
+    void toggleCapsLock();
+
 private:
     WKRetainPtr<WKPageConfigurationRef> generatePageConfiguration(WKContextConfigurationRef);
     WKRetainPtr<WKContextConfigurationRef> generateContextConfiguration() const;
@@ -488,6 +490,8 @@
 
     bool m_didReceiveServerRedirectForProvisionalNavigation { false };
 
+    bool m_capsLockOn { false };
+
     WKRetainPtr<WKArrayRef> m_openPanelFileURLs;
 
     std::unique_ptr<EventSenderProxy> m_eventSenderProxy;

Modified: trunk/Tools/WebKitTestRunner/TestInvocation.cpp (237885 => 237886)


--- trunk/Tools/WebKitTestRunner/TestInvocation.cpp	2018-11-06 21:53:21 UTC (rev 237885)
+++ trunk/Tools/WebKitTestRunner/TestInvocation.cpp	2018-11-06 21:58:29 UTC (rev 237886)
@@ -1503,6 +1503,13 @@
         return result;
     }
 
+#if PLATFORM(MAC)
+    if (WKStringIsEqualToUTF8CString(messageName, "ToggleCapsLock")) {
+        TestController::singleton().toggleCapsLock();
+        return nullptr;
+    }
+#endif
+
     ASSERT_NOT_REACHED();
     return nullptr;
 }

Modified: trunk/Tools/WebKitTestRunner/cocoa/TestControllerCocoa.mm (237885 => 237886)


--- trunk/Tools/WebKitTestRunner/cocoa/TestControllerCocoa.mm	2018-11-06 21:53:21 UTC (rev 237885)
+++ trunk/Tools/WebKitTestRunner/cocoa/TestControllerCocoa.mm	2018-11-06 21:58:29 UTC (rev 237886)
@@ -351,4 +351,23 @@
     return false;
 }
 
+#if PLATFORM(MAC)
+void TestController::toggleCapsLock()
+{
+    m_capsLockOn = !m_capsLockOn;
+    NSEvent *fakeEvent = [NSEvent keyEventWithType:NSEventTypeFlagsChanged
+        location:NSZeroPoint
+        modifierFlags:m_capsLockOn ? NSEventModifierFlagCapsLock : 0
+        timestamp:0
+        windowNumber:[mainWebView()->platformWindow() windowNumber]
+        context:nullptr
+        characters:@""
+        charactersIgnoringModifiers:@""
+        isARepeat:NO
+        keyCode:57];
+    
+    [mainWebView()->platformWindow() sendEvent:fakeEvent];
+}
+#endif
+
 } // namespace WTR
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to