Changeset 237886 in webkit


Ignore:
Timestamp:
Nov 6, 2018 1:58:29 PM (5 years ago)
Author:
pvollan@apple.com
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:
Location:
trunk
Files:
3 added
25 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r237880 r237886  
     12018-11-06  Per Arne Vollan  <pvollan@apple.com>
     2
     3        REGRESSION (r230523): Caps lock indicator not shown in password field
     4        https://bugs.webkit.org/show_bug.cgi?id=190056
     5
     6        Reviewed by Ryosuke Niwa.
     7
     8        * TestExpectations:
     9        * fast/events/detect-caps-lock-expected.txt: Added.
     10        * fast/events/detect-caps-lock.html: Added.
     11        * platform/mac/TestExpectations:
     12
    1132018-11-06  Ali Juma  <ajuma@chromium.org>
    214
  • trunk/LayoutTests/TestExpectations

    r237864 r237886  
    422422
    423423fast/misc/valid-primary-screen-displayID.html [ Skip ]
     424
     425fast/events/detect-caps-lock.html [ Skip ]
    424426
    425427# This test currently only works for mac-wk2
  • trunk/LayoutTests/platform/mac/TestExpectations

    r237569 r237886  
    4040fast/text/mac [ Pass ]
    4141webkit.org/b/181964 fast/text/mac/select-character-before-zero-width-joiner.html [ ImageOnlyFailure ]
     42
     43[ Mojave+ ] fast/events/detect-caps-lock.html [ Pass ]
    4244
    4345#//////////////////////////////////////////////////////////////////////////////////////////
  • trunk/Source/WebCore/ChangeLog

    r237884 r237886  
     12018-11-06  Per Arne Vollan  <pvollan@apple.com>
     2
     3        REGRESSION (r230523): Caps lock indicator not shown in password field
     4        https://bugs.webkit.org/show_bug.cgi?id=190056
     5
     6        Reviewed by Ryosuke Niwa.
     7
     8        When WindowServer access is blocked, GetCurrentModifiers() always returns 0. Instead of calling
     9        GetCurrentModifiers(), store the current modifiers from the key event argument in the method
     10        WebKit::WebPage::keyEvent, and use the stored value to detect if Caps lock is on. Additionally,
     11        the modifiers needs to be updated when the window becomes active.
     12
     13        Test: fast/events/detect-caps-lock.html
     14
     15        * Sources.txt:
     16        * platform/PlatformKeyboardEvent.h:
     17        * platform/graphics/FontTaggedSettings.cpp:
     18        * platform/mac/KeyEventMac.mm:
     19        (WebCore::PlatformKeyboardEvent::currentCapsLockState):
     20        (WebCore::PlatformKeyboardEvent::getCurrentModifierState):
     21        * testing/Internals.cpp:
     22        (WebCore::Internals::capsLockIsOn):
     23        * testing/Internals.h:
     24        * testing/Internals.idl:
     25
    1262018-11-06  Javier Fernandez  <jfernandez@igalia.com>
    227
  • trunk/Source/WebCore/Sources.txt

    r237880 r237886  
    15431543platform/Pasteboard.cpp
    15441544platform/PasteboardWriterData.cpp
     1545platform/PlatformKeyboardEvent.cpp
    15451546platform/PlatformSpeechSynthesisUtterance.cpp
    15461547platform/PlatformSpeechSynthesisVoice.cpp
  • trunk/Source/WebCore/platform/PlatformKeyboardEvent.h

    r237266 r237886  
    136136        bool isSystemKey() const { return m_isSystemKey; }
    137137
    138         static bool currentCapsLockState();
    139         static void getCurrentModifierState(bool& shiftKey, bool& ctrlKey, bool& altKey, bool& metaKey);
     138        WEBCORE_EXPORT static bool currentCapsLockState();
     139        WEBCORE_EXPORT static void getCurrentModifierState(bool& shiftKey, bool& ctrlKey, bool& altKey, bool& metaKey);
     140        WEBCORE_EXPORT static void setCurrentModifierState(OptionSet<Modifier>);
     141        WEBCORE_EXPORT static OptionSet<Modifier> currentStateOfModifierKeys();
    140142
    141143#if PLATFORM(COCOA)
     
    207209        CompositionResults m_compositionResults;
    208210#endif
     211       
     212        // The modifier state is optional, since it is not needed in the UI process or in legacy WebKit.
     213        static std::optional<OptionSet<Modifier>> s_currentModifiers;
    209214    };
    210215   
  • trunk/Source/WebCore/platform/graphics/cairo/GraphicsContextImplCairo.cpp

    r237844 r237886  
    3131
    3232#include "CairoOperations.h"
     33#include "FloatRoundedRect.h"
    3334#include "Font.h"
    3435#include "GlyphBuffer.h"
    3536#include "GraphicsContextPlatformPrivateCairo.h"
     37#include "ImageBuffer.h"
     38#include "IntRect.h"
     39
    3640
    3741namespace WebCore {
  • trunk/Source/WebCore/platform/mac/KeyEventMac.mm

    r236427 r237886  
    3333#import "WindowsKeyboardCodes.h"
    3434#import <Carbon/Carbon.h>
     35#import <wtf/MainThread.h>
    3536
    3637namespace WebCore {
     
    260261bool PlatformKeyboardEvent::currentCapsLockState()
    261262{
    262     return GetCurrentKeyModifiers() & alphaLock;
     263    auto currentModifiers = currentStateOfModifierKeys();
     264    return currentModifiers.contains(PlatformEvent::Modifier::CapsLockKey);
    263265}
    264266
    265267void PlatformKeyboardEvent::getCurrentModifierState(bool& shiftKey, bool& ctrlKey, bool& altKey, bool& metaKey)
    266268{
     269    auto currentModifiers = currentStateOfModifierKeys();
     270    shiftKey = currentModifiers.contains(PlatformEvent::Modifier::ShiftKey);
     271    ctrlKey = currentModifiers.contains(PlatformEvent::Modifier::CtrlKey);
     272    altKey = currentModifiers.contains(PlatformEvent::Modifier::AltKey);
     273    metaKey = currentModifiers.contains(PlatformEvent::Modifier::MetaKey);
     274}
     275
     276OptionSet<PlatformEvent::Modifier> PlatformKeyboardEvent::currentStateOfModifierKeys()
     277{
     278#if ENABLE(WEBPROCESS_WINDOWSERVER_BLOCKING)
     279    // s_currentModifiers is only set in the WebContent process, not in the UI process.
     280    if (s_currentModifiers) {
     281        ASSERT(isMainThread());
     282        return *s_currentModifiers;
     283    }
     284#endif
    267285    UInt32 currentModifiers = GetCurrentKeyModifiers();
    268     shiftKey = currentModifiers & ::shiftKey;
    269     ctrlKey = currentModifiers & ::controlKey;
    270     altKey = currentModifiers & ::optionKey;
    271     metaKey = currentModifiers & ::cmdKey;
     286
     287    OptionSet<PlatformEvent::Modifier> modifiers;
     288    if (currentModifiers & ::shiftKey)
     289        modifiers.add(PlatformEvent::Modifier::ShiftKey);
     290    if (currentModifiers & ::controlKey)
     291        modifiers.add(PlatformEvent::Modifier::CtrlKey);
     292    if (currentModifiers & ::optionKey)
     293        modifiers.add(PlatformEvent::Modifier::AltKey);
     294    if (currentModifiers & ::cmdKey)
     295        modifiers.add(PlatformEvent::Modifier::MetaKey);
     296    if (currentModifiers & ::alphaLock)
     297        modifiers.add(PlatformEvent::Modifier::CapsLockKey);
     298
     299    return modifiers;
    272300}
    273301
  • trunk/Source/WebCore/platform/mediarecorder/MediaRecorderPrivate.h

    r237642 r237886  
    2424
    2525#pragma once
     26
     27#include <wtf/Forward.h>
    2628
    2729#if ENABLE(MEDIA_STREAM)
  • trunk/Source/WebCore/testing/Internals.cpp

    r237837 r237886  
    122122#include "PageOverlay.h"
    123123#include "PathUtilities.h"
     124#include "PlatformKeyboardEvent.h"
    124125#include "PlatformMediaSessionManager.h"
    125126#include "PlatformScreen.h"
     
    47374738}
    47384739
     4740bool Internals::capsLockIsOn()
     4741{
     4742    return WebCore::PlatformKeyboardEvent::currentCapsLockState();
     4743}
     4744
    47394745bool Internals::supportsVCPEncoder()
    47404746{
  • trunk/Source/WebCore/testing/Internals.h

    r237837 r237886  
    739739    unsigned primaryScreenDisplayID();
    740740
     741    bool capsLockIsOn();
     742       
    741743    bool supportsVCPEncoder();
    742744       
  • trunk/Source/WebCore/testing/Internals.idl

    r237837 r237886  
    710710    unsigned long primaryScreenDisplayID();
    711711
     712    boolean capsLockIsOn();
     713
    712714    boolean supportsVCPEncoder();
    713715
  • trunk/Source/WebKit/ChangeLog

    r237885 r237886  
     12018-11-06  Per Arne Vollan  <pvollan@apple.com>
     2
     3        REGRESSION (r230523): Caps lock indicator not shown in password field
     4        https://bugs.webkit.org/show_bug.cgi?id=190056
     5
     6        Reviewed by Ryosuke Niwa.
     7
     8        Update cached modifier state in the WebProcess when WebKit::WebPage::keyEvent is called, and
     9        when the window becomes active.
     10
     11        * UIProcess/WebPageProxy.cpp:
     12        (WebKit::WebPageProxy::dispatchActivityStateChange):
     13        (WebKit::WebPageProxy::updateCurrentModifierState):
     14        * UIProcess/WebPageProxy.h:
     15        * WebProcess/WebPage/WebPage.cpp:
     16        (WebKit::WebPage::keyEvent):
     17        (WebKit::WebPage::updateCurrentModifierState):
     18        * WebProcess/WebPage/WebPage.h:
     19        * WebProcess/WebPage/WebPage.messages.in:
     20
    1212018-11-06  Alex Christensen  <achristensen@webkit.org>
    222
  • trunk/Source/WebKit/UIProcess/WebPageProxy.cpp

    r237863 r237886  
    146146#include <WebCore/MediaStreamRequest.h>
    147147#include <WebCore/PerformanceLoggingClient.h>
     148#include <WebCore/PlatformEvent.h>
    148149#include <WebCore/PublicSuffix.h>
    149150#include <WebCore/RenderEmbeddedObject.h>
     
    15611562    if (changed)
    15621563        LOG_WITH_STREAM(ActivityState, stream << "WebPageProxy " << pageID() << " dispatchActivityStateChange: state changed from " << previousActivityState << " to " << m_activityState);
     1564
     1565    if ((changed & ActivityState::WindowIsActive) && isViewWindowActive())
     1566        updateCurrentModifierState();
    15631567
    15641568    if ((m_potentiallyChangedActivityStateFlags & ActivityState::IsVisible) && isViewVisible())
     
    81268130}
    81278131
     8132void WebPageProxy::updateCurrentModifierState()
     8133{
     8134#if PLATFORM(MAC) && ENABLE(WEBPROCESS_WINDOWSERVER_BLOCKING)
     8135    auto modifiers = PlatformKeyboardEvent::currentStateOfModifierKeys();
     8136    m_process->send(Messages::WebPage::UpdateCurrentModifierState(modifiers), m_pageID);
     8137#endif
     8138}
     8139
    81288140} // namespace WebKit
    81298141
  • trunk/Source/WebKit/UIProcess/WebPageProxy.h

    r237639 r237886  
    18521852#endif
    18531853
     1854    void updateCurrentModifierState();
     1855
    18541856    void reportPageLoadResult(const WebCore::ResourceError& = { });
    18551857
  • trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp

    r237614 r237886  
    25652565    m_userActivityHysteresis.impulse();
    25662566
     2567    PlatformKeyboardEvent::setCurrentModifierState(platform(keyboardEvent).modifiers());
     2568
    25672569    CurrentEvent currentEvent(keyboardEvent);
    25682570
     
    63126314#endif // ENABLE(APPLICATION_MANIFEST)
    63136315
     6316void WebPage::updateCurrentModifierState(OptionSet<PlatformEvent::Modifier> modifiers)
     6317{
     6318    PlatformKeyboardEvent::setCurrentModifierState(modifiers);
     6319}   
     6320
    63146321} // namespace WebKit
    63156322
  • trunk/Source/WebKit/WebProcess/WebPage/WebPage.h

    r237480 r237886  
    10921092#endif
    10931093
     1094    void updateCurrentModifierState(OptionSet<WebCore::PlatformEvent::Modifier> modifiers);
     1095
    10941096    UserContentControllerIdentifier userContentControllerIdentifier() const { return m_userContentController->identifier(); }
    10951097
  • trunk/Source/WebKit/WebProcess/WebPage/WebPage.messages.in

    r237467 r237886  
    528528
    529529    SetDefersLoading(bool defersLoading)
     530
     531    UpdateCurrentModifierState(OptionSet<WebCore::PlatformEvent::Modifier> modifiers)
    530532}
  • trunk/Tools/ChangeLog

    r237882 r237886  
     12018-11-06  Per Arne Vollan  <pvollan@apple.com>
     2
     3        REGRESSION (r230523): Caps lock indicator not shown in password field
     4        https://bugs.webkit.org/show_bug.cgi?id=190056
     5
     6        Reviewed by Ryosuke Niwa.
     7
     8        * WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl:
     9        * WebKitTestRunner/InjectedBundle/TestRunner.cpp:
     10        (WTR::TestRunner::toggleCapsLock):
     11        * WebKitTestRunner/InjectedBundle/TestRunner.h:
     12        * WebKitTestRunner/TestController.h:
     13        * WebKitTestRunner/TestInvocation.cpp:
     14        (WTR::TestInvocation::didReceiveSynchronousMessageFromInjectedBundle):
     15        * WebKitTestRunner/cocoa/TestControllerCocoa.mm:
     16        (WTR::TestController::toggleCapsLock):
     17
    1182018-11-06  Sihui Liu  <sihui_liu@apple.com>
    219
  • trunk/Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl

    r237700 r237886  
    360360    void cleanUpKeychain(DOMString attrLabel);
    361361    boolean keyExistsInKeychain(DOMString attrLabel, DOMString applicationTagBase64);
     362
     363    void toggleCapsLock();
    362364};
  • trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp

    r237700 r237886  
    25142514}
    25152515
     2516void TestRunner::toggleCapsLock()
     2517{
     2518    WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithUTF8CString("ToggleCapsLock"));
     2519    WKBundlePostSynchronousMessage(InjectedBundle::singleton().bundle(), messageName.get(), nullptr, nullptr);
     2520}
     2521
    25162522} // namespace WTR
  • trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.h

    r237700 r237886  
    478478    bool keyExistsInKeychain(JSStringRef attrLabel, JSStringRef applicationTagBase64);
    479479
     480    void toggleCapsLock();
     481
    480482private:
    481483    TestRunner();
  • trunk/Tools/WebKitTestRunner/TestController.h

    r237870 r237886  
    261261    bool keyExistsInKeychain(const String& attrLabel, const String& applicationTagBase64);
    262262
     263    void toggleCapsLock();
     264
    263265private:
    264266    WKRetainPtr<WKPageConfigurationRef> generatePageConfiguration(WKContextConfigurationRef);
     
    489491    bool m_didReceiveServerRedirectForProvisionalNavigation { false };
    490492
     493    bool m_capsLockOn { false };
     494
    491495    WKRetainPtr<WKArrayRef> m_openPanelFileURLs;
    492496
  • trunk/Tools/WebKitTestRunner/TestInvocation.cpp

    r237700 r237886  
    15041504    }
    15051505
     1506#if PLATFORM(MAC)
     1507    if (WKStringIsEqualToUTF8CString(messageName, "ToggleCapsLock")) {
     1508        TestController::singleton().toggleCapsLock();
     1509        return nullptr;
     1510    }
     1511#endif
     1512
    15061513    ASSERT_NOT_REACHED();
    15071514    return nullptr;
  • trunk/Tools/WebKitTestRunner/cocoa/TestControllerCocoa.mm

    r237870 r237886  
    352352}
    353353
     354#if PLATFORM(MAC)
     355void TestController::toggleCapsLock()
     356{
     357    m_capsLockOn = !m_capsLockOn;
     358    NSEvent *fakeEvent = [NSEvent keyEventWithType:NSEventTypeFlagsChanged
     359        location:NSZeroPoint
     360        modifierFlags:m_capsLockOn ? NSEventModifierFlagCapsLock : 0
     361        timestamp:0
     362        windowNumber:[mainWebView()->platformWindow() windowNumber]
     363        context:nullptr
     364        characters:@""
     365        charactersIgnoringModifiers:@""
     366        isARepeat:NO
     367        keyCode:57];
     368   
     369    [mainWebView()->platformWindow() sendEvent:fakeEvent];
     370}
     371#endif
     372
    354373} // namespace WTR
Note: See TracChangeset for help on using the changeset viewer.