[iOS] Draw caps lock indicator in password fields
authordbates@webkit.org <dbates@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 11 Nov 2018 21:32:53 +0000 (21:32 +0000)
committerdbates@webkit.org <dbates@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 11 Nov 2018 21:32:53 +0000 (21:32 +0000)
https://bugs.webkit.org/show_bug.cgi?id=190565
<rdar://problem/45262343>

Source/WebCore:

Reviewed by Dean Jackson.

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.

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:

Reviewed by Dean Jackson.

Forward declare some more SPI.

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

Source/WebKit:

Reviewed by Dean Jackson.

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:

Reviewed by Dean Jackson.

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:

Reviewed by Dean Jackson.

Expose some more symbols.

* WebKitPrivateFrameworkStubs/iOS/12/GraphicsServices.framework/GraphicsServices.tbd:

LayoutTests:

Unreviewed.

Update expected results now that iOS supports showing the caps lock indictor.

* platform/ios/fast/css/text-overflow-input-expected.txt:
* platform/ios/fast/forms/basic-inputs-expected.txt:
* platform/ios/fast/forms/input-appearance-height-expected.txt:
* platform/ios/fast/forms/input-value-expected.txt:
* platform/ios/fast/forms/placeholder-pseudo-style-expected.txt:
* platform/ios/tables/mozilla_expected_failures/bugs/bug92647-1-expected.txt:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@238078 268f45cc-cd09-0410-ab3c-d52691b4dbfc

38 files changed:
LayoutTests/ChangeLog
LayoutTests/platform/ios/fast/css/text-overflow-input-expected.txt
LayoutTests/platform/ios/fast/forms/basic-inputs-expected.txt
LayoutTests/platform/ios/fast/forms/input-appearance-height-expected.txt
LayoutTests/platform/ios/fast/forms/input-value-expected.txt
LayoutTests/platform/ios/fast/forms/placeholder-pseudo-style-expected.txt
LayoutTests/platform/ios/tables/mozilla_expected_failures/bugs/bug92647-1-expected.txt
Source/WebCore/ChangeLog
Source/WebCore/PAL/ChangeLog
Source/WebCore/PAL/pal/spi/ios/GraphicsServicesSPI.h
Source/WebCore/PAL/pal/spi/ios/UIKitSPI.h
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/page/EventHandler.cpp
Source/WebCore/page/EventHandler.h
Source/WebCore/platform/cocoa/KeyEventCocoa.mm
Source/WebCore/platform/ios/KeyEventIOS.mm
Source/WebCore/platform/ios/WebEvent.h
Source/WebCore/platform/ios/WebEvent.mm
Source/WebCore/platform/mac/KeyEventMac.mm
Source/WebCore/rendering/RenderThemeCocoa.h
Source/WebCore/rendering/RenderThemeCocoa.mm
Source/WebCore/rendering/RenderThemeIOS.h
Source/WebCore/rendering/RenderThemeIOS.mm
Source/WebCore/rendering/RenderThemeMac.h
Source/WebCore/rendering/RenderThemeMac.mm
Source/WebKit/ChangeLog
Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm
Source/WebKit/UIProcess/WebPageProxy.cpp
Source/WebKit/UIProcess/WebPageProxy.h
Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm
Source/WebKit/UIProcess/ios/WebPageProxyIOS.mm
Source/WebKit/WebProcess/WebPage/WebPage.h
Source/WebKit/WebProcess/WebPage/WebPage.messages.in
Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm
Source/WebKitLegacy/mac/ChangeLog
Source/WebKitLegacy/mac/WebView/WebHTMLView.mm
WebKitLibraries/ChangeLog
WebKitLibraries/WebKitPrivateFrameworkStubs/iOS/12/GraphicsServices.framework/GraphicsServices.tbd

index 21fbd2d..1838bb3 100644 (file)
@@ -1,3 +1,20 @@
+2018-11-11  Daniel Bates  <dabates@apple.com>
+
+        [iOS] Draw caps lock indicator in password fields
+        https://bugs.webkit.org/show_bug.cgi?id=190565
+        <rdar://problem/45262343>
+
+        Unreviewed.
+
+        Update expected results now that iOS supports showing the caps lock indictor.
+
+        * platform/ios/fast/css/text-overflow-input-expected.txt:
+        * platform/ios/fast/forms/basic-inputs-expected.txt:
+        * platform/ios/fast/forms/input-appearance-height-expected.txt:
+        * platform/ios/fast/forms/input-value-expected.txt:
+        * platform/ios/fast/forms/placeholder-pseudo-style-expected.txt:
+        * platform/ios/tables/mozilla_expected_failures/bugs/bug92647-1-expected.txt:
+
 2018-11-11  Myles C. Maxfield  <mmaxfield@apple.com>
 
         Address post-review comments after r237955
index 2e370a6..dc49a92 100644 (file)
@@ -31,6 +31,8 @@ layer at (0,0) size 800x310
         RenderText {#text} at (569,21) size 5x19
           text run at (569,21) width 5: " "
         RenderTextControl {INPUT} at (575,22) size 136x22 [bgcolor=#FFFFFF] [border: (1px solid #4C4C4C)]
+          RenderFlexibleBox {DIV} at (6,3) size 123x15
+            RenderBlock {DIV} at (0,0) size 123x14
         RenderBR {BR} at (712,21) size 1x19
         RenderTextControl {INPUT} at (2,47) size 136x22 [bgcolor=#FFFFFF] [border: (1px solid #4C4C4C)]
         RenderText {#text} at (139,46) size 5x19
@@ -53,6 +55,8 @@ layer at (0,0) size 800x310
         RenderText {#text} at (569,46) size 5x19
           text run at (569,46) width 5: " "
         RenderTextControl {INPUT} at (575,47) size 136x22 [bgcolor=#FFFFFF] [border: (1px solid #4C4C4C)]
+          RenderFlexibleBox {DIV} at (6,3) size 123x15
+            RenderBlock {DIV} at (0,0) size 123x14
         RenderText {#text} at (0,0) size 0x0
       RenderBlock {P} at (0,122) size 784x70
         RenderText {#text} at (0,0) size 547x19
@@ -79,6 +83,8 @@ layer at (0,0) size 800x310
         RenderText {#text} at (569,21) size 5x19
           text run at (569,21) width 5: " "
         RenderTextControl {INPUT} at (575,22) size 136x22 [bgcolor=#FFFFFF] [border: (1px solid #4C4C4C)]
+          RenderFlexibleBox {DIV} at (6,3) size 123x15
+            RenderBlock {DIV} at (0,0) size 123x14
         RenderBR {BR} at (712,21) size 1x19
         RenderTextControl {INPUT} at (2,47) size 136x22 [bgcolor=#FFFFFF] [border: (1px solid #4C4C4C)]
         RenderText {#text} at (139,46) size 5x19
@@ -101,6 +107,8 @@ layer at (0,0) size 800x310
         RenderText {#text} at (569,46) size 5x19
           text run at (569,46) width 5: " "
         RenderTextControl {INPUT} at (575,47) size 136x22 [bgcolor=#FFFFFF] [border: (1px solid #4C4C4C)]
+          RenderFlexibleBox {DIV} at (6,3) size 123x15
+            RenderBlock {DIV} at (0,0) size 123x14
         RenderText {#text} at (0,0) size 0x0
       RenderBlock {P} at (0,208) size 784x70
         RenderText {#text} at (0,0) size 238x19
@@ -145,7 +153,7 @@ layer at (447,77) size 122x14 scrollWidth 266
     RenderText {#text} at (0,0) size 265x14
       text run at (0,0) width 265: "Lorem ipsum dolor sit amet, consectetur adipiscing elit"
 layer at (590,77) size 122x14 scrollWidth 366
-  RenderBlock {DIV} at (6,3) size 123x15
+  RenderBlock {DIV} at (0,0) size 123x14
     RenderText {#text} at (0,0) size 366x14
       text run at (0,0) width 366: "\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}"
 layer at (17,102) size 122x14 scrollX 142 scrollWidth 265
@@ -169,7 +177,7 @@ layer at (447,102) size 122x14 scrollX 142 scrollWidth 265
     RenderText {#text} at (-142,0) size 266x14
       text run at (-142,0) width 265: "Lorem ipsum dolor sit amet, consectetur adipiscing elit"
 layer at (590,102) size 122x14 scrollWidth 366
-  RenderBlock {DIV} at (6,3) size 123x15
+  RenderBlock {DIV} at (0,0) size 123x14
     RenderText {#text} at (0,0) size 366x14
       text run at (0,0) width 366: "\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}"
 layer at (17,163) size 122x14 scrollWidth 265
@@ -193,7 +201,7 @@ layer at (447,163) size 122x14 scrollWidth 266
     RenderText {#text} at (0,0) size 265x14
       text run at (0,0) width 265: "Lorem ipsum dolor sit amet, consectetur adipiscing elit"
 layer at (590,163) size 122x14 scrollWidth 366
-  RenderBlock {DIV} at (6,3) size 123x15
+  RenderBlock {DIV} at (0,0) size 123x14
     RenderText {#text} at (0,0) size 366x14
       text run at (0,0) width 366: "\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}"
 layer at (17,188) size 122x14 scrollX 142 scrollWidth 265
@@ -217,7 +225,7 @@ layer at (447,188) size 122x14 scrollX 142 scrollWidth 265
     RenderText {#text} at (-142,0) size 266x14
       text run at (-142,0) width 265: "Lorem ipsum dolor sit amet, consectetur adipiscing elit"
 layer at (590,188) size 122x14 scrollWidth 371
-  RenderBlock {DIV} at (6,3) size 123x15
+  RenderBlock {DIV} at (0,0) size 123x14
     RenderText {#text} at (5,0) size 366x14
       text run at (5,0) width 366: "\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}"
 layer at (263,249) size 122x14 scrollWidth 265
index 2d92327..60d5225 100644 (file)
@@ -42,6 +42,8 @@ layer at (0,0) size 800x600
           text run at (314,2) width 13: "b "
           text run at (326,2) width 8: "a"
         RenderTextControl {INPUT} at (3,28) size 136x22 [bgcolor=#FFFFFF] [border: (1px solid #4C4C4C)]
+          RenderFlexibleBox {DIV} at (6,3) size 123x15
+            RenderBlock {DIV} at (0,0) size 123x14
         RenderText {#text} at (140,27) size 65x19
           text run at (140,27) width 65: "password "
         RenderText {#text} at (344,27) size 9x19
@@ -67,7 +69,7 @@ layer at (35,364) size 122x14 scrollWidth 148
     RenderText {#text} at (0,0) size 147x14
       text run at (0,0) width 147: "foobarbazfoobarbazfoobarbaz"
 layer at (28,389) size 122x14
-  RenderBlock {DIV} at (6,3) size 123x15
+  RenderBlock {DIV} at (0,0) size 123x14
     RenderText {#text} at (0,0) size 20x14
       text run at (0,0) width 20: "\x{25CF}\x{25CF}\x{25CF}"
 layer at (195,361) size 136x21
@@ -78,8 +80,10 @@ layer at (202,364) size 122x14
       text run at (0,0) width 16: "foo"
 layer at (225,386) size 135x21
   RenderTextControl {INPUT} at (206,28) size 137x22 [bgcolor=#FFFFFF] [border: (1px solid #4C4C4C)]
+    RenderFlexibleBox {DIV} at (6,3) size 123x15
+      RenderBlock {DIV} at (0,0) size 123x14
 layer at (231,389) size 122x14
-  RenderBlock {DIV} at (6,3) size 123x15 [color=#545454]
+  RenderBlock {DIV} at (0,0) size 123x14 [color=#545454]
     RenderText {#text} at (0,0) size 20x14
       text run at (0,0) width 20: "\x{25CF}\x{25CF}\x{25CF}"
 layer at (113,424) size 16x16
index 327b323..79ab57f 100644 (file)
@@ -83,6 +83,8 @@ layer at (0,0) size 800x600
         RenderText {#text} at (0,235) size 65x19
           text run at (0,235) width 65: "password "
         RenderTextControl {INPUT} at (66,236) size 136x22 [bgcolor=#FFFFFF] [border: (1px solid #4C4C4C)]
+          RenderFlexibleBox {DIV} at (6,3) size 123x15
+            RenderBlock {DIV} at (0,0) size 123x14
         RenderText {#text} at (203,235) size 5x19
           text run at (203,235) width 5: " "
         RenderBR {BR} at (207,250) size 1x0
@@ -101,6 +103,6 @@ layer at (44,58) size 122x14
 layer at (67,242) size 122x14
   RenderBlock {DIV} at (6,3) size 123x15
 layer at (81,267) size 122x14
-  RenderBlock {DIV} at (6,3) size 123x15
+  RenderBlock {DIV} at (0,0) size 123x14
 layer at (61,292) size 122x14
   RenderBlock {DIV} at (0,0) size 123x14
index 4437eb4..2978462 100644 (file)
@@ -46,6 +46,8 @@ layer at (0,0) size 800x600
                   text run at (1,2) width 248: "password with value property changed"
               RenderTableCell {TD} at (395,29) size 240x27 [r=1 c=1 rs=1 cs=1]
                 RenderTextControl {INPUT} at (3,3) size 136x22 [bgcolor=#FFFFFF] [border: (1px solid #4C4C4C)]
+                  RenderFlexibleBox {DIV} at (6,3) size 123x15
+                    RenderBlock {DIV} at (0,0) size 123x14
               RenderTableCell {TD} at (636,31) size 63x23 [r=1 c=2 rs=1 cs=1]
                 RenderText {#text} at (1,1) size 30x20
                   text run at (1,2) width 30: "after"
@@ -205,7 +207,7 @@ layer at (413,142) size 122x14
     RenderText {#text} at (0,0) size 32x14
       text run at (0,0) width 32: "before"
 layer at (413,171) size 122x14
-  RenderBlock {DIV} at (6,3) size 123x15
+  RenderBlock {DIV} at (0,0) size 123x14
     RenderText {#text} at (0,0) size 40x14
       text run at (0,0) width 40: "\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}\x{25CF}"
 layer at (413,328) size 122x14
index 79cd1eb..f0dcbe6 100644 (file)
@@ -17,6 +17,8 @@ layer at (0,0) size 800x600
       RenderText {#text} at (282,21) size 5x19
         text run at (282,21) width 5: " "
       RenderTextControl {INPUT} at (288,22) size 137x22 [bgcolor=#FFFFFF] [border: (1px solid #4C4C4C)]
+        RenderFlexibleBox {DIV} at (6,3) size 123x15
+          RenderBlock {DIV} at (0,0) size 123x14
       RenderText {#text} at (426,21) size 5x19
         text run at (426,21) width 5: " "
       RenderText {#text} at (569,21) size 5x19
@@ -43,7 +45,7 @@ layer at (303,33) size 122x14
     RenderText {#text} at (0,0) size 48x14
       text run at (0,0) width 48: "password"
 layer at (303,33) size 122x14
-  RenderBlock {DIV} at (6,3) size 123x15
+  RenderBlock {DIV} at (0,0) size 123x14
 layer at (590,33) size 122x14
   RenderBlock {DIV} at (6,3) size 123x15 [color=#A9A9A9]
     RenderText {#text} at (0,0) size 34x14
index b496b84..a4471c1 100644 (file)
@@ -24,9 +24,11 @@ layer at (0,0) size 800x600
                           text run at (2,3) width 31: "PIN:"
                       RenderTableCell {TD} at (82,48) size 185x29 [border: (1px inset #808080)] [r=1 c=1 rs=1 cs=1]
                         RenderTextControl {INPUT} at (4,4) size 136x22 [bgcolor=#FFFFFF] [border: (1px solid #4C4C4C)]
+                          RenderFlexibleBox {DIV} at (6,3) size 123x15
+                            RenderBlock {DIV} at (0,0) size 123x14
                         RenderText {#text} at (0,0) size 0x0
                       RenderTableCell {TD} at (268,60) size 5x5 [border: (1px inset #808080)] [r=1 c=2 rs=1 cs=1]
 layer at (108,32) size 122x14
   RenderBlock {DIV} at (6,3) size 123x15
 layer at (108,70) size 122x14
-  RenderBlock {DIV} at (6,3) size 123x15
+  RenderBlock {DIV} at (0,0) size 123x14
index 9956481..4a9db55 100644 (file)
@@ -1,3 +1,54 @@
+2018-11-11  Daniel Bates  <dabates@apple.com>
+
+        [iOS] Draw caps lock indicator in password fields
+        https://bugs.webkit.org/show_bug.cgi?id=190565
+        <rdar://problem/45262343>
+
+        Reviewed by Dean Jackson.
+
+        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.
+
+        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.
+
 2018-11-11  Zalan Bujtas  <zalan@apple.com>
 
         [LFC][BFC] In-flow positioned logic is really formatting context dependent.
index 3dd51b4..a794f21 100644 (file)
@@ -1,3 +1,16 @@
+2018-11-11  Daniel Bates  <dabates@apple.com>
+
+        [iOS] Draw caps lock indicator in password fields
+        https://bugs.webkit.org/show_bug.cgi?id=190565
+        <rdar://problem/45262343>
+
+        Reviewed by Dean Jackson.
+
+        Forward declare some more SPI.
+
+        * pal/spi/ios/GraphicsServicesSPI.h:
+        * pal/spi/ios/UIKitSPI.h:
+
 2018-11-09  Ryan Haddad  <ryanhaddad@apple.com>
 
         Unreviewed, rolling out r238047.
index 1cc8b31..1b5bd97 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2014 Apple Inc. All rights reserved.
+ * Copyright (C) 2014-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
@@ -43,6 +43,12 @@ CFStringRef GSSystemRootDirectory(void);
 void GSFontInitialize(void);
 void GSFontPurgeFontCache(void);
 
+typedef struct __GSKeyboard* GSKeyboardRef;
+uint32_t GSKeyboardGetModifierState(GSKeyboardRef);
+Boolean GSEventIsHardwareKeyboardAttached();
+
+extern const char *kGSEventHardwareKeyboardAvailabilityChangedNotification;
+
 WTF_EXTERN_C_END
 
 #endif
index 7c94714..1a87af5 100644 (file)
  * THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+WTF_EXTERN_C_BEGIN
+typedef struct __GSKeyboard* GSKeyboardRef;
+WTF_EXTERN_C_END
+
 #if USE(APPLE_INTERNAL_SDK)
 
 #import <UIKit/NSParagraphStyle_Private.h>
@@ -44,6 +48,7 @@
 
 @interface UIApplication ()
 + (UIApplicationSceneClassicMode)_classicMode;
+- (GSKeyboardRef)_hardwareKeyboard;
 @end
 
 #else
@@ -75,10 +80,9 @@ typedef NS_ENUM(NSInteger, UIApplicationSceneClassicMode) {
 @end
 
 @interface UIApplication ()
-
 - (BOOL)_isClassic;
 + (UIApplicationSceneClassicMode)_classicMode;
-
+- (GSKeyboardRef)_hardwareKeyboard;
 @end
 
 @interface UIColor ()
index cb0917a..91b9ec2 100644 (file)
                CE2849881CA3614600B4A57F /* ContentSecurityPolicyDirectiveNames.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ContentSecurityPolicyDirectiveNames.cpp; path = csp/ContentSecurityPolicyDirectiveNames.cpp; sourceTree = "<group>"; };
                CE5CB1B314EDAB6F00BB2795 /* EventSender.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EventSender.h; sourceTree = "<group>"; };
                CE5FA253209E48C50051D700 /* ContentSecurityPolicyClient.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = ContentSecurityPolicyClient.h; path = csp/ContentSecurityPolicyClient.h; sourceTree = "<group>"; };
+               CE68C8FF21924EE5001230B3 /* PlatformKeyboardEvent.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = PlatformKeyboardEvent.cpp; sourceTree = "<group>"; };
                CE6D89294C7AACE0AD89B3DD /* MathMLMencloseElement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MathMLMencloseElement.h; sourceTree = "<group>"; };
                CE6DADF71C591E6A003F6A88 /* ContentSecurityPolicyResponseHeaders.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ContentSecurityPolicyResponseHeaders.cpp; path = csp/ContentSecurityPolicyResponseHeaders.cpp; sourceTree = "<group>"; };
                CE6DADF81C591E6A003F6A88 /* ContentSecurityPolicyResponseHeaders.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ContentSecurityPolicyResponseHeaders.h; path = csp/ContentSecurityPolicyResponseHeaders.h; sourceTree = "<group>"; };
                                A14978701ABAF3A500CEF7E4 /* PlatformContentFilter.h */,
                                BC5C76291497FE1400BC4775 /* PlatformEvent.h */,
                                A723F77A1484CA4C008C6DBE /* PlatformExportMacros.h */,
+                               CE68C8FF21924EE5001230B3 /* PlatformKeyboardEvent.cpp */,
                                935C476609AC4D4300A6AAB4 /* PlatformKeyboardEvent.h */,
                                935C476709AC4D4300A6AAB4 /* PlatformMouseEvent.h */,
                                C5BAC16F14E30E4700008837 /* PlatformPasteboard.h */,
index b80b768..ffd4607 100644 (file)
@@ -3162,6 +3162,14 @@ bool EventHandler::keyEvent(const PlatformKeyboardEvent& keyEvent)
     return wasHandled;
 }
 
+void EventHandler::capsLockStateMayHaveChanged() const
+{
+    auto* focusedElement = m_frame.document()->focusedElement();
+    if (!is<HTMLInputElement>(focusedElement))
+        return;
+    downcast<HTMLInputElement>(*focusedElement).capsLockStateMayHaveChanged();
+}
+
 bool EventHandler::internalKeyEvent(const PlatformKeyboardEvent& initialKeyEvent)
 {
     Ref<Frame> protectedFrame(m_frame);
@@ -3194,12 +3202,8 @@ bool EventHandler::internalKeyEvent(const PlatformKeyboardEvent& initialKeyEvent
     }
 #endif
 
-    if (initialKeyEvent.windowsVirtualKeyCode() == VK_CAPITAL) {
-        if (auto* element = m_frame.document()->focusedElement()) {
-            if (is<HTMLInputElement>(*element))
-                downcast<HTMLInputElement>(*element).capsLockStateMayHaveChanged();
-        }
-    }
+    if (initialKeyEvent.windowsVirtualKeyCode() == VK_CAPITAL)
+        capsLockStateMayHaveChanged();
 
 #if ENABLE(PAN_SCROLLING)
     if (m_frame.mainFrame().eventHandler().panScrollInProgress()) {
index f5fe08f..92fbc5a 100644 (file)
@@ -256,6 +256,7 @@ public:
     WEBCORE_EXPORT bool handleAccessKey(const PlatformKeyboardEvent&);
     WEBCORE_EXPORT bool keyEvent(const PlatformKeyboardEvent&);
     void defaultKeyboardEventHandler(KeyboardEvent&);
+    WEBCORE_EXPORT void capsLockStateMayHaveChanged() const;
 
     bool accessibilityPreventsEventPropagation(KeyboardEvent&);
     WEBCORE_EXPORT void handleKeyboardSelectionMovementForAccessibility(KeyboardEvent&);
index 631dd14..05c0a8c 100644 (file)
 #import "KeyEventCocoa.h"
 
 #import "Logging.h"
+#import "PlatformKeyboardEvent.h"
 #import "WindowsKeyboardCodes.h"
 #import <wtf/ASCIICType.h>
+#import <wtf/MainThread.h>
 #import <wtf/text/WTFString.h>
 
 #if PLATFORM(IOS_FAMILY)
@@ -39,6 +41,20 @@ using namespace WTF;
 
 namespace WebCore {
 
+bool PlatformKeyboardEvent::currentCapsLockState()
+{
+    return currentStateOfModifierKeys().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);
+}
+
 // https://w3c.github.io/uievents-key/
 String keyForCharCode(unichar charCode)
 {
index 19ca9bf..9bd57e7 100644 (file)
 #import "KeyEventCocoa.h"
 #import "KeyEventCodesIOS.h"
 #import "NotImplemented.h"
+#import "WebEvent.h"
 #import "WindowsKeyboardCodes.h"
 #import <pal/spi/cocoa/IOKitSPI.h>
+#import <wtf/MainThread.h>
 
 using namespace WTF;
 
@@ -312,19 +314,29 @@ void PlatformKeyboardEvent::disambiguateKeyDownEvent(Type type, bool backwardCom
     }
 }
 
-bool PlatformKeyboardEvent::currentCapsLockState()
+OptionSet<PlatformEvent::Modifier> PlatformKeyboardEvent::currentStateOfModifierKeys()
 {
-    notImplemented();
-    return false;
-}
+    // s_currentModifiers is only set in the WebContent process, not in the UI process.
+    if (s_currentModifiers) {
+        ASSERT(isMainThread());
+        return *s_currentModifiers;
+    }
 
-void PlatformKeyboardEvent::getCurrentModifierState(bool& shiftKey, bool& ctrlKey, bool& altKey, bool& metaKey)
-{
-    notImplemented();
-    shiftKey = false;
-    ctrlKey = false;
-    altKey = false;
-    metaKey = false;
+    ::WebEventFlags currentModifiers = [::WebEvent modifierFlags];
+
+    OptionSet<PlatformEvent::Modifier> modifiers;
+    if (currentModifiers & ::WebEventFlagMaskShiftKey)
+        modifiers.add(PlatformEvent::Modifier::ShiftKey);
+    if (currentModifiers & ::WebEventFlagMaskControlKey)
+        modifiers.add(PlatformEvent::Modifier::CtrlKey);
+    if (currentModifiers & ::WebEventFlagMaskOptionKey)
+        modifiers.add(PlatformEvent::Modifier::AltKey);
+    if (currentModifiers & ::WebEventFlagMaskCommandKey)
+        modifiers.add(PlatformEvent::Modifier::MetaKey);
+    if (currentModifiers & ::WebEventFlagMaskLeftCapsLockKey)
+        modifiers.add(PlatformEvent::Modifier::CapsLockKey);
+
+    return modifiers;
 }
 
 }
index 3bd36bf..224a07e 100644 (file)
@@ -216,6 +216,8 @@ WEBCORE_EXPORT @interface WebEvent : NSObject {
 
 @property(nonatomic) BOOL wasHandled;
 
+@property (class, readonly) WebEventFlags modifierFlags;
+
 @end
 
 #endif // TARGET_OS_IPHONE
index e678e9e..a6bd733 100644 (file)
 #import "KeyEventCodesIOS.h"
 #import "WAKAppKitStubs.h"
 #import <pal/spi/cocoa/IOKitSPI.h>
+#import <pal/spi/ios/GraphicsServicesSPI.h>
+#import <pal/spi/ios/UIKitSPI.h>
+#import <wtf/SoftLinking.h>
+
+SOFT_LINK_FRAMEWORK(UIKit)
+SOFT_LINK_CLASS(UIKit, UIApplication);
+
+#define UIApplication getUIApplicationClass()
 
 using WebCore::windowsKeyCodeForKeyCode;
 using WebCore::windowsKeyCodeForCharCode;
@@ -491,6 +499,11 @@ static NSString *normalizedStringWithAppKitCompatibilityMapping(NSString *charac
     return _gestureRotation;
 }
 
++ (WebEventFlags)modifierFlags
+{
+    return GSEventIsHardwareKeyboardAttached() ? GSKeyboardGetModifierState([UIApplication sharedApplication]._hardwareKeyboard) : 0;
+}
+
 @end
 
 #endif // PLATFORM(IOS_FAMILY)
index b08a53e..2bcb510 100644 (file)
@@ -258,21 +258,6 @@ void PlatformKeyboardEvent::disambiguateKeyDownEvent(Type type, bool backwardCom
     }
 }
 
-bool PlatformKeyboardEvent::currentCapsLockState()
-{
-    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)
index a464c10..f188742 100644 (file)
@@ -36,6 +36,8 @@ namespace WebCore {
 
 class RenderThemeCocoa : public RenderTheme {
 private:
+    bool shouldHaveCapsLockIndicator(const HTMLInputElement&) const final;
+
 #if ENABLE(APPLE_PAY)
     void adjustApplePayButtonStyle(StyleResolver&, RenderStyle&, const Element*) const override;
     bool paintApplePayButton(const RenderObject&, const PaintInfo&, const IntRect&) override;
index feacfc5..b4aaf64 100644 (file)
@@ -27,6 +27,7 @@
 #import "RenderThemeCocoa.h"
 
 #import "GraphicsContextCG.h"
+#import "HTMLInputElement.h"
 #import "RenderText.h"
 
 #if ENABLE(APPLE_PAY)
@@ -51,6 +52,11 @@ SOFT_LINK_MAY_FAIL(PassKit, PKDrawApplePayButton, void, (CGContextRef context, C
 
 namespace WebCore {
 
+bool RenderThemeCocoa::shouldHaveCapsLockIndicator(const HTMLInputElement& element) const
+{
+    return element.isPasswordField();
+}
+
 #if ENABLE(APPLE_PAY)
 
 static const auto applePayButtonMinimumWidth = 140;
index ca8c0ba..a5a30ac 100644 (file)
@@ -117,7 +117,6 @@ protected:
 #endif
 
     bool shouldHaveSpinButton(const HTMLInputElement&) const override;
-    bool shouldHaveCapsLockIndicator(const HTMLInputElement&) const override;
 
 #if ENABLE(VIDEO)
     String mediaControlsStyleSheet() override;
index 1d17aea..52b4d74 100644 (file)
@@ -1135,11 +1135,6 @@ bool RenderThemeIOS::shouldHaveSpinButton(const HTMLInputElement&) const
     return false;
 }
 
-bool RenderThemeIOS::shouldHaveCapsLockIndicator(const HTMLInputElement&) const
-{
-    return false;
-}
-
 FontCascadeDescription& RenderThemeIOS::cachedSystemFontDescription(CSSValueID valueID) const
 {
     static NeverDestroyed<FontCascadeDescription> systemFont;
index 1dd2b1f..b74344c 100644 (file)
@@ -164,8 +164,6 @@ private:
     bool supportsClosedCaptioning() const final { return true; }
 #endif
 
-    bool shouldHaveCapsLockIndicator(const HTMLInputElement&) const final;
-
     bool paintSnapshottedPluginOverlay(const RenderObject&, const PaintInfo&, const IntRect&) final;
 
 #if ENABLE(ATTACHMENT_ELEMENT)
index 6464ab4..423e293 100644 (file)
@@ -2342,11 +2342,6 @@ void RenderThemeMac::adjustSliderThumbSize(RenderStyle& style, const Element*) c
     }
 }
 
-bool RenderThemeMac::shouldHaveCapsLockIndicator(const HTMLInputElement& element) const
-{
-    return element.isPasswordField();
-}
-
 NSPopUpButtonCell* RenderThemeMac::popupButton() const
 {
     if (!m_popupButton) {
index 07ce39b..d5aeb77 100644 (file)
@@ -1,3 +1,35 @@
+2018-11-11  Daniel Bates  <dabates@apple.com>
+
+        [iOS] Draw caps lock indicator in password fields
+        https://bugs.webkit.org/show_bug.cgi?id=190565
+        <rdar://problem/45262343>
+
+        Reviewed by Dean Jackson.
+
+        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.
+
 2018-11-11  Dan Bernstein  <mitz@apple.com>
 
         ProcessPoolConfiguration::copy() doesn’t copy m_customWebContentServiceBundleIdentifier
index 92f455f..4db7ef5 100644 (file)
 #import <WebCore/WebSQLiteDatabaseTrackerClient.h>
 #import <pal/spi/cg/CoreGraphicsSPI.h>
 #import <pal/spi/cocoa/QuartzCoreSPI.h>
+#import <pal/spi/ios/GraphicsServicesSPI.h>
 #import <wtf/cocoa/Entitlements.h>
 
 #define RELEASE_LOG_IF_ALLOWED(...) RELEASE_LOG_IF(_page && _page->isAlwaysOnLoggingAllowed(), ViewState, __VA_ARGS__)
@@ -712,6 +713,8 @@ static void validate(WKWebViewConfiguration *configuration)
 
     [[_configuration _contentProviderRegistry] addPage:*_page];
     _page->setForceAlwaysUserScalable([_configuration ignoresViewportScaleLimits]);
+
+    CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(), (__bridge const void *)(self), hardwareKeyboardAvailabilityChangedCallback, (CFStringRef)[NSString stringWithUTF8String:kGSEventHardwareKeyboardAvailabilityChangedNotification], nullptr, CFNotificationSuspensionBehaviorCoalesce);
 #endif
 
 #if PLATFORM(MAC)
@@ -849,6 +852,8 @@ static void validate(WKWebViewConfiguration *configuration)
     [[_configuration _contentProviderRegistry] removePage:*_page];
     [[NSNotificationCenter defaultCenter] removeObserver:self];
     [_scrollView setInternalDelegate:nil];
+
+    CFNotificationCenterRemoveObserver(CFNotificationCenterGetDarwinNotifyCenter(), (__bridge const void *)(self), (CFStringRef)[NSString stringWithUTF8String:kGSEventHardwareKeyboardAvailabilityChangedNotification], nullptr);
 #endif
 
 #if ENABLE(ACCESSIBILITY_EVENTS)
@@ -3107,6 +3112,13 @@ static int32_t activeOrientation(WKWebView *webView)
     [self _keyboardChangedWithInfo:notification.userInfo adjustScrollView:YES];
 }
 
+static void hardwareKeyboardAvailabilityChangedCallback(CFNotificationCenterRef, void* observer, CFStringRef, const void*, CFDictionaryRef)
+{
+    ASSERT(observer);
+    WKWebView *webView = (__bridge WKWebView *)observer;
+    webView._page->hardwareKeyboardAvailabilityChanged();
+}
+
 - (void)_windowDidRotate:(NSNotification *)notification
 {
     if (!_overridesInterfaceOrientation)
index 7bc6c32..f6fda75 100644 (file)
@@ -8150,7 +8150,7 @@ void WebPageProxy::getIsViewVisible(bool& result)
 
 void WebPageProxy::updateCurrentModifierState()
 {
-#if PLATFORM(MAC) && ENABLE(WEBPROCESS_WINDOWSERVER_BLOCKING)
+#if PLATFORM(MAC) && ENABLE(WEBPROCESS_WINDOWSERVER_BLOCKING) || PLATFORM(IOS_FAMILY)
     auto modifiers = PlatformKeyboardEvent::currentStateOfModifierKeys();
     m_process->send(Messages::WebPage::UpdateCurrentModifierState(modifiers), m_pageID);
 #endif
index a4ea91f..f10d615 100644 (file)
@@ -649,6 +649,7 @@ public:
     void storeSelectionForAccessibility(bool);
     void startAutoscrollAtPosition(const WebCore::FloatPoint& positionInWindow);
     void cancelAutoscroll();
+    void hardwareKeyboardAvailabilityChanged();
 #if ENABLE(DATA_INTERACTION)
     void didHandleStartDataInteractionRequest(bool started);
     void didHandleAdditionalDragItemsRequest(bool added);
@@ -1369,6 +1370,8 @@ public:
     void didCloseSuggestions();
 #endif
 
+    void updateCurrentModifierState();
+
 private:
     WebPageProxy(PageClient&, WebProcessProxy&, uint64_t pageID, Ref<API::PageConfiguration>&&);
     void platformInitialize();
@@ -1851,8 +1854,6 @@ private:
     void stopDisplayLink(unsigned observerID);
 #endif
 
-    void updateCurrentModifierState();
-
     void reportPageLoadResult(const WebCore::ResourceError& = { });
 
     void continueNavigationInNewProcess(API::Navigation&, Ref<WebProcessProxy>&&);
index 7e71a22..70c8836 100644 (file)
@@ -3797,9 +3797,13 @@ static NSString *contentTypeFromFieldName(WebCore::AutofillFieldName fieldName)
 
 - (void)_handleKeyUIEvent:(::UIEvent *)event
 {
+    bool isHardwareKeyboardEvent = !!event._hidEvent;
+    if (isHardwareKeyboardEvent && ((UIPhysicalKeyboardEvent *)event)._inputFlags & kUIKeyboardInputModifierFlagsChanged)
+        _page->updateCurrentModifierState();
+
     // We only want to handle key event from the hardware keyboard when we are
     // first responder and we are not interacting with editable content.
-    if ([self isFirstResponder] && event._hidEvent && !_page->editorState().isContentEditable) {
+    if ([self isFirstResponder] && isHardwareKeyboardEvent && !_page->editorState().isContentEditable) {
         [self handleKeyEvent:event];
         return;
     }
index 434f425..dc80283 100644 (file)
@@ -1089,6 +1089,12 @@ void WebPageProxy::setIsScrollingOrZooming(bool isScrollingOrZooming)
         m_validationBubble->show();
 }
 
+void WebPageProxy::hardwareKeyboardAvailabilityChanged()
+{
+    updateCurrentModifierState();
+    m_process->send(Messages::WebPage::HardwareKeyboardAvailabilityChanged(), m_pageID);
+}
+
 #if ENABLE(DATA_INTERACTION)
 
 void WebPageProxy::didHandleStartDataInteractionRequest(bool started)
index 2fbc66b..650a752 100644 (file)
@@ -913,6 +913,8 @@ public:
 
     bool platformPrefersTextLegibilityBasedZoomScaling() const;
     const WebCore::ViewportConfiguration& viewportConfiguration() const { return m_viewportConfiguration; }
+
+    void hardwareKeyboardAvailabilityChanged();
 #endif
 
 #if ENABLE(IOS_TOUCH_EVENTS)
index fe4430c..dbc6812 100644 (file)
@@ -106,6 +106,7 @@ messages -> WebPage LegacyReceiver {
     StartAutoscrollAtPosition(WebCore::FloatPoint positionInWindow)
     CancelAutoscroll()
     RequestAssistedNodeInformation(WebKit::CallbackID callbackID)
+    HardwareKeyboardAvailabilityChanged()
 #endif
 
     SetControlledByAutomation(bool controlled)
index 3ad9ace..ef3a5f3 100644 (file)
@@ -3087,6 +3087,12 @@ String WebPage::platformUserAgent(const URL&) const
     return String();
 }
 
+void WebPage::hardwareKeyboardAvailabilityChanged()
+{
+    if (auto* focusedFrame = m_page->focusController().focusedFrame())
+        focusedFrame->eventHandler().capsLockStateMayHaveChanged();
+}
+
 #if USE(QUICK_LOOK)
 void WebPage::didReceivePasswordForQuickLookDocument(const String& password)
 {
index 000b356..a59bb21 100644 (file)
@@ -1,3 +1,18 @@
+2018-11-11  Daniel Bates  <dabates@apple.com>
+
+        [iOS] Draw caps lock indicator in password fields
+        https://bugs.webkit.org/show_bug.cgi?id=190565
+        <rdar://problem/45262343>
+
+        Reviewed by Dean Jackson.
+
+        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.
+
 2018-11-11  Benjamin Poulain  <benjamin@webkit.org>
 
         Fix a fixme: rename wtfObjcMsgSend to wtfObjCMsgSend
index 1f4218c..88a9e4b 100644 (file)
 #import <WebCore/WAKScrollView.h>
 #import <WebCore/WAKWindow.h>
 #import <WebCore/WKGraphics.h>
+#import <WebCore/WebCoreThreadRun.h>
 #import <WebCore/WebEvent.h>
+#import <pal/spi/ios/GraphicsServicesSPI.h>
 #endif
 
 using namespace WebCore;
@@ -814,6 +816,16 @@ static CachedImageClient& promisedDataClient()
 
 #if PLATFORM(IOS_FAMILY)
 static NSString * const WebMarkedTextUpdatedNotification = @"WebMarkedTextUpdated";
+
+static void hardwareKeyboardAvailabilityChangedCallback(CFNotificationCenterRef, void* observer, CFStringRef, const void*, CFDictionaryRef)
+{
+    ASSERT(observer);
+    WebThreadRun(^{
+        WebHTMLView *webView = (__bridge WebHTMLView *)observer;
+        if (Frame* coreFrame = core([webView _frame]))
+            coreFrame->eventHandler().capsLockStateMayHaveChanged();
+    });
+}
 #endif
 
 @interface WebHTMLView (WebHTMLViewFileInternal)
@@ -2610,6 +2622,7 @@ ALLOW_DEPRECATED_DECLARATIONS_END
     [[NSNotificationCenter defaultCenter] 
             addObserver:self selector:@selector(markedTextUpdate:) 
                    name:WebMarkedTextUpdatedNotification object:nil];
+    CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(), (__bridge const void *)(self), hardwareKeyboardAvailabilityChangedCallback, (CFStringRef)[NSString stringWithUTF8String:kGSEventHardwareKeyboardAvailabilityChangedNotification], nullptr, CFNotificationSuspensionBehaviorCoalesce);
 #endif
 
 #if PLATFORM(MAC)
@@ -2626,6 +2639,7 @@ ALLOW_DEPRECATED_DECLARATIONS_END
 
 #if PLATFORM(IOS_FAMILY)
     [[NSNotificationCenter defaultCenter] removeObserver:self name:WebMarkedTextUpdatedNotification object:nil];
+    CFNotificationCenterRemoveObserver(CFNotificationCenterGetDarwinNotifyCenter(), (__bridge const void *)(self), (CFStringRef)[NSString stringWithUTF8String:kGSEventHardwareKeyboardAvailabilityChangedNotification], nullptr);
 #endif
 
     // We can't assert that close has already been called because
index 00403ac..84817b6 100644 (file)
@@ -1,3 +1,15 @@
+2018-11-11  Daniel Bates  <dabates@apple.com>
+
+        [iOS] Draw caps lock indicator in password fields
+        https://bugs.webkit.org/show_bug.cgi?id=190565
+        <rdar://problem/45262343>
+
+        Reviewed by Dean Jackson.
+
+        Expose some more symbols.
+
+        * WebKitPrivateFrameworkStubs/iOS/12/GraphicsServices.framework/GraphicsServices.tbd:
+
 2018-11-09  Ryan Haddad  <ryanhaddad@apple.com>
 
         Unreviewed, rolling out r238047.
index ab1c406..d354324 100644 (file)
@@ -15,10 +15,13 @@ exports:
       - x86_64
     symbols:
       - _GSCurrentEventTimestamp
+      - _GSEventIsHardwareKeyboardAttached
       - _GSFontInitialize
       - _GSFontPurgeFontCache
       - _GSInitialize
+      - _GSKeyboardGetModifierState
       - _GSSystemRootDirectory
+      - _kGSEventHardwareKeyboardAvailabilityChangedNotification
 install-name: /System/Library/PrivateFrameworks/GraphicsServices.framework/GraphicsServices
 objc-constraint: none
 platform: ios