Changeset 238047 in webkit


Ignore:
Timestamp:
Nov 9, 2018 11:10:27 AM (5 years ago)
Author:
dbates@webkit.org
Message:

[iOS] Draw caps lock indicator in password fields
https://bugs.webkit.org/show_bug.cgi?id=190565
<rdar://problem/45262343>

Reviewed by Dean Jackson.

Source/WebCore:

Draw the caps lock indicator in a focused password field on iOS. This makes the behavior of password
fields on iOS more closely match the behavior of password fields on Mac. For now, we only draw the
indicator when caps locks is enabled via the hardware keyboard. We will look to support the software
keyboard in a subsequent commit (see <https://bugs.webkit.org/show_bug.cgi?id=191475>).

The majority of this patch is implementing PlatformKeyboardEvent::currentCapsLockState() for iOS.
In Legacy WebKit, the implementation boils down to calling call -[::WebEvent modifierFlags]. In
Modern WebKit the UIProcess is responsible for -[::WebEvent modifierFlags] and passing it the
WebProcess to store such that invocations of PlatformKeyboardEvent::currentCapsLockState() consult
the store in the WebProcess. A smaller part of this patch is having both the legacy and modern
web views listen for keyboard availability changes so as to update the the caps lock state when
a hardware keyboard is detached or attached.

  • WebCore.xcodeproj/project.pbxproj:
  • page/EventHandler.cpp:

(WebCore::EventHandler::capsLockStateMayHaveChanged const): Extracted from EventHandler::internalKeyEvent()
so that it can shared between WebCore, Modern WebKit, and Legacy WebKit code.
(WebCore::EventHandler::internalKeyEvent): Modified to call capsLockStateMayHaveChanged().

  • page/EventHandler.h:
  • platform/cocoa/KeyEventCocoa.mm:

(WebCore::PlatformKeyboardEvent::currentCapsLockState): Moved from KeyEventMac.mm.
(WebCore::PlatformKeyboardEvent::getCurrentModifierState): Moved from KeyEventMac.mm.

  • platform/ios/KeyEventIOS.mm:

(WebCore::PlatformKeyboardEvent::currentStateOfModifierKeys): Fetch the current modifier state.
(WebCore::PlatformKeyboardEvent::currentCapsLockState): Deleted; we now use the Cocoa implementation.
(WebCore::PlatformKeyboardEvent::getCurrentModifierState): Deleted; we now use the Cocoa implementation.

  • platform/ios/WebEvent.h:
  • platform/ios/WebEvent.mm:

(+[WebEvent modifierFlags]): Added.

  • platform/mac/KeyEventMac.mm:

(WebCore::PlatformKeyboardEvent::currentCapsLockState): Deleted; moved to KeyEventCocoa.mm to be shared
by both Mac and iOS.
(WebCore::PlatformKeyboardEvent::getCurrentModifierState): Deleted; moved to KeyEventCocoa.mm to be shared
by both Mac and iOS.

  • rendering/RenderThemeCocoa.h:
  • rendering/RenderThemeCocoa.mm:

(WebCore::RenderThemeCocoa::shouldHaveCapsLockIndicator const): Moved from RenderThemeMac.mm.

  • rendering/RenderThemeIOS.h:
  • rendering/RenderThemeIOS.mm:

(WebCore::RenderThemeIOS::shouldHaveCapsLockIndicator const): Deleted.

  • rendering/RenderThemeMac.h:
  • rendering/RenderThemeMac.mm:

(WebCore::RenderThemeMac::shouldHaveCapsLockIndicator const): Deleted; moved to RenderThemeCocoa.mm to be
shared by both Mac and iOS.

Source/WebCore/PAL:

Forward declare some more SPI.

  • pal/spi/ios/GraphicsServicesSPI.h:
  • pal/spi/ios/UIKitSPI.h:

Source/WebKit:

Notify the WebContent process with the current modifer state on window activation changes. Notify
the WebContent process when hardware keyboard availability changes (e.g. a keyboard is attached).

  • UIProcess/API/Cocoa/WKWebView.mm:

(-[WKWebView _initializeWithConfiguration:]): Register for hardware keyboard availability changed notifications.
(-[WKWebView dealloc]): Unregister from hardware availability changed notifications.
(hardwareKeyboardAvailabilityChangedCallback): Added.

  • UIProcess/WebPageProxy.cpp:

(WebKit::WebPageProxy::updateCurrentModifierState): Compile this code when building for iOS.

  • UIProcess/WebPageProxy.h:
  • UIProcess/ios/WKContentViewInteraction.mm:

(-[WKContentView _handleKeyUIEvent:]): Update the current modifier state if this event is a hardware
keyboard flags changed event.

  • UIProcess/ios/WebPageProxyIOS.mm:

(WebKit::WebPageProxy::hardwareKeyboardAvailabilityChanged): Added.

  • WebProcess/WebPage/WebPage.h:
  • WebProcess/WebPage/WebPage.messages.in:
  • WebProcess/WebPage/ios/WebPageIOS.mm:

(WebKit::WebPage::hardwareKeyboardAvailabilityChanged):
Added new message HardwareKeyboardAvailabilityChanged. Notify the focused HTML input element (if we have
one) that the caps lock state may have changed when we receive message HardwareKeyboardAvailabilityChanged
so that we toggle visibility of the caps lock indicator.

Source/WebKitLegacy/mac:

Update the caps lock state when a hardware keyboard is attached or detached.

  • WebView/WebHTMLView.mm:

(hardwareKeyboardAvailabilityChangedCallback): Added.
(-[WebHTMLView initWithFrame:]): Register for hardware keyboard availability changed notifications.
(-[WebHTMLView dealloc]): Unregister from hardware keyboard availability changed notifications.

WebKitLibraries:

Expose some more symbols.

  • WebKitPrivateFrameworkStubs/iOS/12/GraphicsServices.framework/GraphicsServices.tbd:
Location:
trunk
Files:
31 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r238046 r238047  
     12018-11-09  Daniel Bates  <dabates@apple.com>
     2
     3        [iOS] Draw caps lock indicator in password fields
     4        https://bugs.webkit.org/show_bug.cgi?id=190565
     5        <rdar://problem/45262343>
     6
     7        Reviewed by Dean Jackson.
     8
     9        Draw the caps lock indicator in a focused password field on iOS. This makes the behavior of password
     10        fields on iOS more closely match the behavior of password fields on Mac. For now, we only draw the
     11        indicator when caps locks is enabled via the hardware keyboard. We will look to support the software
     12        keyboard in a subsequent commit (see <https://bugs.webkit.org/show_bug.cgi?id=191475>).
     13
     14        The majority of this patch is implementing PlatformKeyboardEvent::currentCapsLockState() for iOS.
     15        In Legacy WebKit, the implementation boils down to calling call -[::WebEvent modifierFlags]. In
     16        Modern WebKit the UIProcess is responsible for -[::WebEvent modifierFlags] and passing it the
     17        WebProcess to store such that invocations of PlatformKeyboardEvent::currentCapsLockState() consult
     18        the store in the WebProcess. A smaller part of this patch is having both the legacy and modern
     19        web views listen for keyboard availability changes so as to update the the caps lock state when
     20        a hardware keyboard is detached or attached.
     21
     22        * WebCore.xcodeproj/project.pbxproj:
     23        * page/EventHandler.cpp:
     24        (WebCore::EventHandler::capsLockStateMayHaveChanged const): Extracted from EventHandler::internalKeyEvent()
     25        so that it can shared between WebCore, Modern WebKit, and Legacy WebKit code.
     26        (WebCore::EventHandler::internalKeyEvent): Modified to call capsLockStateMayHaveChanged().
     27        * page/EventHandler.h:
     28        * platform/cocoa/KeyEventCocoa.mm:
     29        (WebCore::PlatformKeyboardEvent::currentCapsLockState): Moved from KeyEventMac.mm.
     30        (WebCore::PlatformKeyboardEvent::getCurrentModifierState): Moved from KeyEventMac.mm.
     31        * platform/ios/KeyEventIOS.mm:
     32        (WebCore::PlatformKeyboardEvent::currentStateOfModifierKeys): Fetch the current modifier state.
     33        (WebCore::PlatformKeyboardEvent::currentCapsLockState): Deleted; we now use the Cocoa implementation.
     34        (WebCore::PlatformKeyboardEvent::getCurrentModifierState): Deleted; we now use the Cocoa implementation.
     35        * platform/ios/WebEvent.h:
     36        * platform/ios/WebEvent.mm:
     37        (+[WebEvent modifierFlags]): Added.
     38        * platform/mac/KeyEventMac.mm:
     39        (WebCore::PlatformKeyboardEvent::currentCapsLockState): Deleted; moved to KeyEventCocoa.mm to be shared
     40        by both Mac and iOS.
     41        (WebCore::PlatformKeyboardEvent::getCurrentModifierState): Deleted; moved to KeyEventCocoa.mm to be shared
     42        by both Mac and iOS.
     43        * rendering/RenderThemeCocoa.h:
     44        * rendering/RenderThemeCocoa.mm:
     45        (WebCore::RenderThemeCocoa::shouldHaveCapsLockIndicator const): Moved from RenderThemeMac.mm.
     46        * rendering/RenderThemeIOS.h:
     47        * rendering/RenderThemeIOS.mm:
     48        (WebCore::RenderThemeIOS::shouldHaveCapsLockIndicator const): Deleted.
     49        * rendering/RenderThemeMac.h:
     50        * rendering/RenderThemeMac.mm:
     51        (WebCore::RenderThemeMac::shouldHaveCapsLockIndicator const): Deleted; moved to RenderThemeCocoa.mm to be
     52        shared by both Mac and iOS.
     53
    1542018-11-09  Chris Dumez  <cdumez@apple.com>
    255
  • trunk/Source/WebCore/PAL/ChangeLog

    r238014 r238047  
     12018-11-09  Daniel Bates  <dabates@apple.com>
     2
     3        [iOS] Draw caps lock indicator in password fields
     4        https://bugs.webkit.org/show_bug.cgi?id=190565
     5        <rdar://problem/45262343>
     6
     7        Reviewed by Dean Jackson.
     8
     9        Forward declare some more SPI.
     10
     11        * pal/spi/ios/GraphicsServicesSPI.h:
     12        * pal/spi/ios/UIKitSPI.h:
     13
    1142018-11-08  Megan Gardner  <megan_gardner@apple.com>
    215
  • trunk/Source/WebCore/PAL/pal/spi/ios/GraphicsServicesSPI.h

    r237266 r238047  
    11/*
    2  * Copyright (C) 2014 Apple Inc. All rights reserved.
     2 * Copyright (C) 2014-2018 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    4444void GSFontPurgeFontCache(void);
    4545
     46typedef struct __GSKeyboard* GSKeyboardRef;
     47uint32_t GSKeyboardGetModifierState(GSKeyboardRef);
     48Boolean GSEventIsHardwareKeyboardAttached();
     49
     50extern const char *kGSEventHardwareKeyboardAvailabilityChangedNotification;
     51
    4652WTF_EXTERN_C_END
    4753
  • trunk/Source/WebCore/PAL/pal/spi/ios/UIKitSPI.h

    r237739 r238047  
    2424 */
    2525
     26WTF_EXTERN_C_BEGIN
     27typedef struct __GSKeyboard* GSKeyboardRef;
     28WTF_EXTERN_C_END
     29
    2630#if USE(APPLE_INTERNAL_SDK)
    2731
     
    4549@interface UIApplication ()
    4650+ (UIApplicationSceneClassicMode)_classicMode;
     51- (GSKeyboardRef)_hardwareKeyboard;
    4752@end
    4853
     
    7681
    7782@interface UIApplication ()
    78 
    7983- (BOOL)_isClassic;
    8084+ (UIApplicationSceneClassicMode)_classicMode;
    81 
     85- (GSKeyboardRef)_hardwareKeyboard;
    8286@end
    8387
  • trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj

    r238014 r238047  
    1368813688                CE5CB1B314EDAB6F00BB2795 /* EventSender.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EventSender.h; sourceTree = "<group>"; };
    1368913689                CE5FA253209E48C50051D700 /* ContentSecurityPolicyClient.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = ContentSecurityPolicyClient.h; path = csp/ContentSecurityPolicyClient.h; sourceTree = "<group>"; };
     13690                CE68C8FF21924EE5001230B3 /* PlatformKeyboardEvent.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = PlatformKeyboardEvent.cpp; sourceTree = "<group>"; };
    1369013691                CE6D89294C7AACE0AD89B3DD /* MathMLMencloseElement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MathMLMencloseElement.h; sourceTree = "<group>"; };
    1369113692                CE6DADF71C591E6A003F6A88 /* ContentSecurityPolicyResponseHeaders.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ContentSecurityPolicyResponseHeaders.cpp; path = csp/ContentSecurityPolicyResponseHeaders.cpp; sourceTree = "<group>"; };
     
    2509025091                                BC5C76291497FE1400BC4775 /* PlatformEvent.h */,
    2509125092                                A723F77A1484CA4C008C6DBE /* PlatformExportMacros.h */,
     25093                                CE68C8FF21924EE5001230B3 /* PlatformKeyboardEvent.cpp */,
    2509225094                                935C476609AC4D4300A6AAB4 /* PlatformKeyboardEvent.h */,
    2509325095                                935C476709AC4D4300A6AAB4 /* PlatformMouseEvent.h */,
  • trunk/Source/WebCore/page/EventHandler.cpp

    r237944 r238047  
    31633163}
    31643164
     3165void EventHandler::capsLockStateMayHaveChanged() const
     3166{
     3167    auto* focusedElement = m_frame.document()->focusedElement();
     3168    if (!is<HTMLInputElement>(focusedElement))
     3169        return;
     3170    downcast<HTMLInputElement>(*focusedElement).capsLockStateMayHaveChanged();
     3171}
     3172
    31653173bool EventHandler::internalKeyEvent(const PlatformKeyboardEvent& initialKeyEvent)
    31663174{
     
    31953203#endif
    31963204
    3197     if (initialKeyEvent.windowsVirtualKeyCode() == VK_CAPITAL) {
    3198         if (auto* element = m_frame.document()->focusedElement()) {
    3199             if (is<HTMLInputElement>(*element))
    3200                 downcast<HTMLInputElement>(*element).capsLockStateMayHaveChanged();
    3201         }
    3202     }
     3205    if (initialKeyEvent.windowsVirtualKeyCode() == VK_CAPITAL)
     3206        capsLockStateMayHaveChanged();
    32033207
    32043208#if ENABLE(PAN_SCROLLING)
  • trunk/Source/WebCore/page/EventHandler.h

    r237266 r238047  
    257257    WEBCORE_EXPORT bool keyEvent(const PlatformKeyboardEvent&);
    258258    void defaultKeyboardEventHandler(KeyboardEvent&);
     259    WEBCORE_EXPORT void capsLockStateMayHaveChanged() const;
    259260
    260261    bool accessibilityPreventsEventPropagation(KeyboardEvent&);
  • trunk/Source/WebCore/platform/cocoa/KeyEventCocoa.mm

    r237266 r238047  
    2828
    2929#import "Logging.h"
     30#import "PlatformKeyboardEvent.h"
    3031#import "WindowsKeyboardCodes.h"
    3132#import <wtf/ASCIICType.h>
     
    3940
    4041namespace WebCore {
     42
     43bool PlatformKeyboardEvent::currentCapsLockState()
     44{
     45    return currentStateOfModifierKeys().contains(PlatformEvent::Modifier::CapsLockKey);
     46}
     47
     48void PlatformKeyboardEvent::getCurrentModifierState(bool& shiftKey, bool& ctrlKey, bool& altKey, bool& metaKey)
     49{
     50    auto currentModifiers = currentStateOfModifierKeys();
     51    shiftKey = currentModifiers.contains(PlatformEvent::Modifier::ShiftKey);
     52    ctrlKey = currentModifiers.contains(PlatformEvent::Modifier::CtrlKey);
     53    altKey = currentModifiers.contains(PlatformEvent::Modifier::AltKey);
     54    metaKey = currentModifiers.contains(PlatformEvent::Modifier::MetaKey);
     55}
    4156
    4257// https://w3c.github.io/uievents-key/
  • trunk/Source/WebCore/platform/ios/KeyEventIOS.mm

    r237266 r238047  
    3232#import "KeyEventCodesIOS.h"
    3333#import "NotImplemented.h"
     34#import "WebEvent.h"
    3435#import "WindowsKeyboardCodes.h"
    3536#import <pal/spi/cocoa/IOKitSPI.h>
     37#import <wtf/MainThread.h>
    3638
    3739using namespace WTF;
     
    313315}
    314316
    315 bool PlatformKeyboardEvent::currentCapsLockState()
    316 {
    317     notImplemented();
    318     return false;
    319 }
    320 
    321 void PlatformKeyboardEvent::getCurrentModifierState(bool& shiftKey, bool& ctrlKey, bool& altKey, bool& metaKey)
    322 {
    323     notImplemented();
    324     shiftKey = false;
    325     ctrlKey = false;
    326     altKey = false;
    327     metaKey = false;
     317OptionSet<PlatformEvent::Modifier> PlatformKeyboardEvent::currentStateOfModifierKeys()
     318{
     319    // s_currentModifiers is only set in the WebContent process, not in the UI process.
     320    if (s_currentModifiers) {
     321        ASSERT(isMainThread());
     322        return *s_currentModifiers;
     323    }
     324
     325    ::WebEventFlags currentModifiers = [::WebEvent modifierFlags];
     326
     327    OptionSet<PlatformEvent::Modifier> modifiers;
     328    if (currentModifiers & ::WebEventFlagMaskShiftKey)
     329        modifiers.add(PlatformEvent::Modifier::ShiftKey);
     330    if (currentModifiers & ::WebEventFlagMaskControlKey)
     331        modifiers.add(PlatformEvent::Modifier::CtrlKey);
     332    if (currentModifiers & ::WebEventFlagMaskOptionKey)
     333        modifiers.add(PlatformEvent::Modifier::AltKey);
     334    if (currentModifiers & ::WebEventFlagMaskCommandKey)
     335        modifiers.add(PlatformEvent::Modifier::MetaKey);
     336    if (currentModifiers & ::WebEventFlagMaskLeftCapsLockKey)
     337        modifiers.add(PlatformEvent::Modifier::CapsLockKey);
     338
     339    return modifiers;
    328340}
    329341
  • trunk/Source/WebCore/platform/ios/WebEvent.h

    r237738 r238047  
    217217@property(nonatomic) BOOL wasHandled;
    218218
     219@property (class, readonly) WebEventFlags modifierFlags;
     220
    219221@end
    220222
  • trunk/Source/WebCore/platform/ios/WebEvent.mm

    r237739 r238047  
    3737#import "WAKAppKitStubs.h"
    3838#import <pal/spi/cocoa/IOKitSPI.h>
     39#import <pal/spi/ios/GraphicsServicesSPI.h>
     40#import <pal/spi/ios/UIKitSPI.h>
     41#import <wtf/SoftLinking.h>
     42
     43SOFT_LINK_FRAMEWORK(UIKit)
     44SOFT_LINK_CLASS(UIKit, UIApplication);
     45
     46#define UIApplication getUIApplicationClass()
    3947
    4048using WebCore::windowsKeyCodeForKeyCode;
     
    492500}
    493501
     502+ (WebEventFlags)modifierFlags
     503{
     504    return GSEventIsHardwareKeyboardAttached() ? GSKeyboardGetModifierState([UIApplication sharedApplication]._hardwareKeyboard) : 0;
     505}
     506
    494507@end
    495508
  • trunk/Source/WebCore/platform/mac/KeyEventMac.mm

    r237886 r238047  
    259259}
    260260
    261 bool PlatformKeyboardEvent::currentCapsLockState()
    262 {
    263     auto currentModifiers = currentStateOfModifierKeys();
    264     return currentModifiers.contains(PlatformEvent::Modifier::CapsLockKey);
    265 }
    266 
    267 void PlatformKeyboardEvent::getCurrentModifierState(bool& shiftKey, bool& ctrlKey, bool& altKey, bool& metaKey)
    268 {
    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 
    276261OptionSet<PlatformEvent::Modifier> PlatformKeyboardEvent::currentStateOfModifierKeys()
    277262{
  • trunk/Source/WebCore/rendering/RenderThemeCocoa.h

    r237765 r238047  
    3737class RenderThemeCocoa : public RenderTheme {
    3838private:
     39    bool shouldHaveCapsLockIndicator(const HTMLInputElement&) const final;
     40
    3941#if ENABLE(APPLE_PAY)
    4042    void adjustApplePayButtonStyle(StyleResolver&, RenderStyle&, const Element*) const override;
  • trunk/Source/WebCore/rendering/RenderThemeCocoa.mm

    r237765 r238047  
    2828
    2929#import "GraphicsContextCG.h"
     30#import "HTMLInputElement.h"
    3031#import "RenderText.h"
    3132
     
    5152
    5253namespace WebCore {
     54
     55bool RenderThemeCocoa::shouldHaveCapsLockIndicator(const HTMLInputElement& element) const
     56{
     57    return element.isPasswordField();
     58}
    5359
    5460#if ENABLE(APPLE_PAY)
  • trunk/Source/WebCore/rendering/RenderThemeIOS.h

    r237842 r238047  
    118118
    119119    bool shouldHaveSpinButton(const HTMLInputElement&) const override;
    120     bool shouldHaveCapsLockIndicator(const HTMLInputElement&) const override;
    121120
    122121#if ENABLE(VIDEO)
  • trunk/Source/WebCore/rendering/RenderThemeIOS.mm

    r237842 r238047  
    11361136}
    11371137
    1138 bool RenderThemeIOS::shouldHaveCapsLockIndicator(const HTMLInputElement&) const
    1139 {
    1140     return false;
    1141 }
    1142 
    11431138FontCascadeDescription& RenderThemeIOS::cachedSystemFontDescription(CSSValueID valueID) const
    11441139{
  • trunk/Source/WebCore/rendering/RenderThemeMac.h

    r238001 r238047  
    165165#endif
    166166
    167     bool shouldHaveCapsLockIndicator(const HTMLInputElement&) const final;
    168 
    169167    bool paintSnapshottedPluginOverlay(const RenderObject&, const PaintInfo&, const IntRect&) final;
    170168
  • trunk/Source/WebCore/rendering/RenderThemeMac.mm

    r238001 r238047  
    23432343}
    23442344
    2345 bool RenderThemeMac::shouldHaveCapsLockIndicator(const HTMLInputElement& element) const
    2346 {
    2347     return element.isPasswordField();
    2348 }
    2349 
    23502345NSPopUpButtonCell* RenderThemeMac::popupButton() const
    23512346{
  • trunk/Source/WebKit/ChangeLog

    r238045 r238047  
     12018-11-09  Daniel Bates  <dabates@apple.com>
     2
     3        [iOS] Draw caps lock indicator in password fields
     4        https://bugs.webkit.org/show_bug.cgi?id=190565
     5        <rdar://problem/45262343>
     6
     7        Reviewed by Dean Jackson.
     8
     9        Notify the WebContent process with the current modifer state on window activation changes. Notify
     10        the WebContent process when hardware keyboard availability changes (e.g. a keyboard is attached).
     11
     12        * UIProcess/API/Cocoa/WKWebView.mm:
     13        (-[WKWebView _initializeWithConfiguration:]): Register for hardware keyboard availability changed notifications.
     14        (-[WKWebView dealloc]): Unregister from hardware availability changed notifications.
     15        (hardwareKeyboardAvailabilityChangedCallback): Added.
     16        * UIProcess/WebPageProxy.cpp:
     17        (WebKit::WebPageProxy::updateCurrentModifierState): Compile this code when building for iOS.
     18        * UIProcess/WebPageProxy.h:
     19        * UIProcess/ios/WKContentViewInteraction.mm:
     20        (-[WKContentView _handleKeyUIEvent:]): Update the current modifier state if this event is a hardware
     21        keyboard flags changed event.
     22        * UIProcess/ios/WebPageProxyIOS.mm:
     23        (WebKit::WebPageProxy::hardwareKeyboardAvailabilityChanged): Added.
     24
     25        * WebProcess/WebPage/WebPage.h:
     26        * WebProcess/WebPage/WebPage.messages.in:
     27        * WebProcess/WebPage/ios/WebPageIOS.mm:
     28        (WebKit::WebPage::hardwareKeyboardAvailabilityChanged):
     29        Added new message HardwareKeyboardAvailabilityChanged. Notify the focused HTML input element (if we have
     30        one) that the caps lock state may have changed when we receive message HardwareKeyboardAvailabilityChanged
     31        so that we toggle visibility of the caps lock indicator.
     32
    1332018-11-09  Tim Horton  <timothy_horton@apple.com>
    234
  • trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm

    r238015 r238047  
    154154#import <pal/spi/cg/CoreGraphicsSPI.h>
    155155#import <pal/spi/cocoa/QuartzCoreSPI.h>
     156#import <pal/spi/ios/GraphicsServicesSPI.h>
    156157#import <wtf/cocoa/Entitlements.h>
    157158
     
    706707    [[_configuration _contentProviderRegistry] addPage:*_page];
    707708    _page->setForceAlwaysUserScalable([_configuration ignoresViewportScaleLimits]);
     709
     710    CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(), (__bridge const void *)(self), hardwareKeyboardAvailabilityChangedCallback, (CFStringRef)[NSString stringWithUTF8String:kGSEventHardwareKeyboardAvailabilityChangedNotification], nullptr, CFNotificationSuspensionBehaviorCoalesce);
    708711#endif
    709712
     
    843846    [[NSNotificationCenter defaultCenter] removeObserver:self];
    844847    [_scrollView setInternalDelegate:nil];
     848
     849    CFNotificationCenterRemoveObserver(CFNotificationCenterGetDarwinNotifyCenter(), (__bridge const void *)(self), (CFStringRef)[NSString stringWithUTF8String:kGSEventHardwareKeyboardAvailabilityChangedNotification], nullptr);
    845850#endif
    846851
     
    31013106
    31023107    [self _keyboardChangedWithInfo:notification.userInfo adjustScrollView:YES];
     3108}
     3109
     3110static void hardwareKeyboardAvailabilityChangedCallback(CFNotificationCenterRef, void* observer, CFStringRef, const void*, CFDictionaryRef)
     3111{
     3112    ASSERT(observer);
     3113    WKWebView *webView = (__bridge WKWebView *)observer;
     3114    webView._page->hardwareKeyboardAvailabilityChanged();
    31033115}
    31043116
  • trunk/Source/WebKit/UIProcess/WebPageProxy.cpp

    r238015 r238047  
    81338133void WebPageProxy::updateCurrentModifierState()
    81348134{
    8135 #if PLATFORM(MAC) && ENABLE(WEBPROCESS_WINDOWSERVER_BLOCKING)
     8135#if PLATFORM(MAC) && ENABLE(WEBPROCESS_WINDOWSERVER_BLOCKING) || PLATFORM(IOS_FAMILY)
    81368136    auto modifiers = PlatformKeyboardEvent::currentStateOfModifierKeys();
    81378137    m_process->send(Messages::WebPage::UpdateCurrentModifierState(modifiers), m_pageID);
  • trunk/Source/WebKit/UIProcess/WebPageProxy.h

    r238015 r238047  
    646646    void startAutoscrollAtPosition(const WebCore::FloatPoint& positionInWindow);
    647647    void cancelAutoscroll();
     648    void hardwareKeyboardAvailabilityChanged();
    648649#if ENABLE(DATA_INTERACTION)
    649650    void didHandleStartDataInteractionRequest(bool started);
     
    13651366    void didCloseSuggestions();
    13661367#endif
     1368
     1369    void updateCurrentModifierState();
    13671370
    13681371private:
     
    18481851#endif
    18491852
    1850     void updateCurrentModifierState();
    1851 
    18521853    void reportPageLoadResult(const WebCore::ResourceError& = { });
    18531854
  • trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm

    r238033 r238047  
    37573757- (void)_handleKeyUIEvent:(::UIEvent *)event
    37583758{
     3759    bool isHardwareKeyboardEvent = !!event._hidEvent;
     3760    if (isHardwareKeyboardEvent && ((UIPhysicalKeyboardEvent *)event)._inputFlags & kUIKeyboardInputModifierFlagsChanged)
     3761        _page->updateCurrentModifierState();
     3762
    37593763    // We only want to handle key event from the hardware keyboard when we are
    37603764    // first responder and we are not interacting with editable content.
    3761     if ([self isFirstResponder] && event._hidEvent && !_page->editorState().isContentEditable) {
     3765    if ([self isFirstResponder] && isHardwareKeyboardEvent && !_page->editorState().isContentEditable) {
    37623766        [self handleKeyEvent:event];
    37633767        return;
  • trunk/Source/WebKit/UIProcess/ios/WebPageProxyIOS.mm

    r237266 r238047  
    10901090}
    10911091
     1092void WebPageProxy::hardwareKeyboardAvailabilityChanged()
     1093{
     1094    updateCurrentModifierState();
     1095    m_process->send(Messages::WebPage::HardwareKeyboardAvailabilityChanged(), m_pageID);
     1096}
     1097
    10921098#if ENABLE(DATA_INTERACTION)
    10931099
  • trunk/Source/WebKit/WebProcess/WebPage/WebPage.h

    r237886 r238047  
    914914    bool platformPrefersTextLegibilityBasedZoomScaling() const;
    915915    const WebCore::ViewportConfiguration& viewportConfiguration() const { return m_viewportConfiguration; }
     916
     917    void hardwareKeyboardAvailabilityChanged();
    916918#endif
    917919
  • trunk/Source/WebKit/WebProcess/WebPage/WebPage.messages.in

    r237886 r238047  
    107107    CancelAutoscroll()
    108108    RequestAssistedNodeInformation(WebKit::CallbackID callbackID)
     109    HardwareKeyboardAvailabilityChanged()
    109110#endif
    110111
  • trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm

    r237935 r238047  
    30883088}
    30893089
     3090void WebPage::hardwareKeyboardAvailabilityChanged()
     3091{
     3092    if (auto* focusedFrame = m_page->focusController().focusedFrame())
     3093        focusedFrame->eventHandler().capsLockStateMayHaveChanged();
     3094}
     3095
    30903096#if USE(QUICK_LOOK)
    30913097void WebPage::didReceivePasswordForQuickLookDocument(const String& password)
  • trunk/Source/WebKitLegacy/mac/ChangeLog

    r238033 r238047  
     12018-11-09  Daniel Bates  <dabates@apple.com>
     2
     3        [iOS] Draw caps lock indicator in password fields
     4        https://bugs.webkit.org/show_bug.cgi?id=190565
     5        <rdar://problem/45262343>
     6
     7        Reviewed by Dean Jackson.
     8
     9        Update the caps lock state when a hardware keyboard is attached or detached.
     10
     11        * WebView/WebHTMLView.mm:
     12        (hardwareKeyboardAvailabilityChangedCallback): Added.
     13        (-[WebHTMLView initWithFrame:]): Register for hardware keyboard availability changed notifications.
     14        (-[WebHTMLView dealloc]): Unregister from hardware keyboard availability changed notifications.
     15
    1162018-11-09  Daniel Bates  <dabates@apple.com>
    217
  • trunk/Source/WebKitLegacy/mac/WebView/WebHTMLView.mm

    r238033 r238047  
    165165#import <WebCore/WAKWindow.h>
    166166#import <WebCore/WKGraphics.h>
     167#import <WebCore/WebCoreThreadRun.h>
    167168#import <WebCore/WebEvent.h>
     169#import <pal/spi/ios/GraphicsServicesSPI.h>
    168170#endif
    169171
     
    815817#if PLATFORM(IOS_FAMILY)
    816818static NSString * const WebMarkedTextUpdatedNotification = @"WebMarkedTextUpdated";
     819
     820static void hardwareKeyboardAvailabilityChangedCallback(CFNotificationCenterRef, void* observer, CFStringRef, const void*, CFDictionaryRef)
     821{
     822    ASSERT(observer);
     823    WebThreadRun(^{
     824        WebHTMLView *webView = (__bridge WebHTMLView *)observer;
     825        if (Frame* coreFrame = core([webView _frame]))
     826            coreFrame->eventHandler().capsLockStateMayHaveChanged();
     827    });
     828}
    817829#endif
    818830
     
    26112623            addObserver:self selector:@selector(markedTextUpdate:)
    26122624                   name:WebMarkedTextUpdatedNotification object:nil];
     2625    CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(), (__bridge const void *)(self), hardwareKeyboardAvailabilityChangedCallback, (CFStringRef)[NSString stringWithUTF8String:kGSEventHardwareKeyboardAvailabilityChangedNotification], nullptr, CFNotificationSuspensionBehaviorCoalesce);
    26132626#endif
    26142627
     
    26272640#if PLATFORM(IOS_FAMILY)
    26282641    [[NSNotificationCenter defaultCenter] removeObserver:self name:WebMarkedTextUpdatedNotification object:nil];
     2642    CFNotificationCenterRemoveObserver(CFNotificationCenterGetDarwinNotifyCenter(), (__bridge const void *)(self), (CFStringRef)[NSString stringWithUTF8String:kGSEventHardwareKeyboardAvailabilityChangedNotification], nullptr);
    26292643#endif
    26302644
  • trunk/WebKitLibraries/ChangeLog

    r233266 r238047  
     12018-11-09  Daniel Bates  <dabates@apple.com>
     2
     3        [iOS] Draw caps lock indicator in password fields
     4        https://bugs.webkit.org/show_bug.cgi?id=190565
     5        <rdar://problem/45262343>
     6
     7        Reviewed by Dean Jackson.
     8
     9        Expose some more symbols.
     10
     11        * WebKitPrivateFrameworkStubs/iOS/12/GraphicsServices.framework/GraphicsServices.tbd:
     12
    1132018-06-27  Jonathan Bedard  <jbedard@apple.com>
    214
  • trunk/WebKitLibraries/WebKitPrivateFrameworkStubs/iOS/12/GraphicsServices.framework/GraphicsServices.tbd

    r233266 r238047  
    1616    symbols:
    1717      - _GSCurrentEventTimestamp
     18      - _GSEventIsHardwareKeyboardAttached
    1819      - _GSFontInitialize
    1920      - _GSFontPurgeFontCache
    2021      - _GSInitialize
     22      - _GSKeyboardGetModifierState
    2123      - _GSSystemRootDirectory
     24      - _kGSEventHardwareKeyboardAvailabilityChangedNotification
    2225install-name: /System/Library/PrivateFrameworks/GraphicsServices.framework/GraphicsServices
    2326objc-constraint: none
Note: See TracChangeset for help on using the changeset viewer.