COMMIT_MESSAGE

 1[iOS] Keyups for non-modifier keys identified as "Dead" when not focused in a content-editable element
 2https://bugs.webkit.org/show_bug.cgi?id=192824
 3<rdar://problem/47100332>
 4
 5Reviewed by Wenson Hsieh.
 6
 7Source/WebCore:
 8
 9When building with USE(UIKIT_KEYBOARD_ADDITIONS) enabled, normalize input strings for some more key codes
 10now that hardware key events to non-editable elements use the same code path as for editable elements.
 11
 12* platform/ios/KeyEventIOS.mm:
 13(WebCore::windowsKeyCodeForCharCode): Demarcate mappings that are only needed when building with
 14!USE(UIKIT_KEYBOARD_ADDITIONS) in the hope that one day we can remove this code.
 15(WebCore::isFunctionKey): Ditto.
 16* platform/ios/WebEvent.mm:
 17(normalizedStringWithAppKitCompatibilityMapping): Normalize some more input strings when building with
 18USE(UIKIT_KEYBOARD_ADDITIONS) enabled.
 19
 20Source/WebCore/PAL:
 21
 22Expose more enumerators.
 23
 24* pal/spi/cocoa/IOKitSPI.h:
 25
 26Source/WebKit:
 27
 28Use the same code path for key events to editable elements and non-editable elements.
 29
 30Currently we have different code paths for hardware key events depending on whether the active element
 31is editable or non-editable. Historically to support dispatching DOM keyboard events for hardware key
 32presses this differentiation was a necessary workaround for UIKit's event processing precedence of
 33interpreting key events for system text editing commands and app commands before dispatching unhandled
 34key events to WebKit. This workaround intercepted raw key UIEvents and manually reconstructed a
 35WebEvent from it. However there is not enough information in an UIEvent to reconstruct a WebEvent that
 36is identical to the WebEvent that UIKit would have dispatched. In particular, keyup UIEvents always have
 37empty modified and unmodified input strings. The UIKit keyboard machinery maintains additional state
 38that is necessary to manufacture the correct WebEvent corresponding to a UIEvent.
 39
 40As a side benefit of this change, with the exception of modifier flag changes, both hardware and software
 41key events use the same code path.
 42
 43* UIProcess/ios/WKContentViewInteraction.h:
 44* UIProcess/ios/WKContentViewInteraction.mm:
 45(-[WKContentView _disableAutomaticKeyboardUI]): Implement UIKit SPI to prevent showing the keyboard UI
 46when there is no focused element now that we are no longer intercepting key UIEvents. Formerly the
 47keyboard UI was disabled as a side effect of not becoming first responder when there was no focused
 48element (by returning NO in -_requiresKeyboardWhenFirstResponder).
 49(-[WKContentView _requiresKeyboardWhenFirstResponder]): Return YES when there is no focused element.
 50(-[WKContentView textInputTraits]): Do not update traits when the keyboard is going to be dismissed
 51now that we require a keyboard when first responder even if the focused element is non-editable.
 52(-[WKContentView _didHandleKeyEvent:eventWasHandled:]): Skip logic for re-sending UIEvents to UIKit
 53as UIKit now processes the event first. This logic was necessary in order to finally allow UIKit
 54its chance to interpret the UIEvent, we intercepted, for app key commands.
 55
 56Tools:
 57
 58Fix a bug where the wrong usage code was used for F13 thru F24.
 59
 60* WebKitTestRunner/ios/HIDEventGenerator.mm:
 61(keyCodeForDOMFunctionKey):
 62
 63LayoutTests:
 64
 65Update tests and expected results. As it turns out fixing the bug in WebKitTestRunner/ios/HIDEventGenerator.mm
 66so that we now dispatch key events for F17 thru F24 exposed a bug in UIKit. See <rdar://problem/47128940>.
 67This same bug is also responsible for a lack of key events when the Insert key is pressed.
 68
 69Added sub-test for Tab key to keypress-keys-in-non-editable-element.html. Changed expected result in test
 70keypress-keys-in-non-editable-element.html for the forward delete key to expect failure. We expect that pressing
 71the forward delete key will not dispatch a keypress to match the behavior on Mac. This will be addressed by a
 72UIKit fix.
 73
 74* fast/events/ios/keydown-keyup-special-keys-in-non-editable-element-expected.txt:
 75* fast/events/ios/keydown-keyup-special-keys-in-non-editable-element.html:
 76* fast/events/ios/keypress-keys-in-non-editable-element-expected.txt:
 77* fast/events/ios/keypress-keys-in-non-editable-element.html:

LayoutTests/ChangeLog

 12019-01-11 Daniel Bates <dabates@apple.com>
 2
 3 [iOS] Keyups for non-modifier keys identified as "Dead" when not focused in a content-editable element
 4 https://bugs.webkit.org/show_bug.cgi?id=192824
 5 <rdar://problem/47100332>
 6
 7 Reviewed by Wenson Hsieh.
 8
 9 Update tests and expected results. As it turns out fixing the bug in WebKitTestRunner/ios/HIDEventGenerator.mm
 10 so that we now dispatch key events for F17 thru F24 exposed a bug in UIKit. See <rdar://problem/47128940>.
 11 This same bug is also responsible for a lack of key events when the Insert key is pressed.
 12
 13 Added sub-test for Tab key to keypress-keys-in-non-editable-element.html. Changed expected result in test
 14 keypress-keys-in-non-editable-element.html for the forward delete key to expect failure. We expect that pressing
 15 the forward delete key will not dispatch a keypress to match the behavior on Mac. This will be addressed by a
 16 UIKit fix.
 17
 18 * fast/events/ios/keydown-keyup-special-keys-in-non-editable-element-expected.txt:
 19 * fast/events/ios/keydown-keyup-special-keys-in-non-editable-element.html:
 20 * fast/events/ios/keypress-keys-in-non-editable-element-expected.txt:
 21 * fast/events/ios/keypress-keys-in-non-editable-element.html:
 22
1232018-12-05 Daniel Bates <dabates@apple.com>
224
325 [iOS] Add test to ensure that a web page can prevent the default for Command + A

LayoutTests/fast/events/ios/keydown-keyup-special-keys-in-non-editable-element-expected.txt

1 This tests that DOM keydown and keyup events are dispatched to a non-editable <body> on iOS when pressing special keys on a hardware keyboard. To run this test manually, verify that two messages are emitted when you press the following keys: ↑, ↓, ←, →, Delete, End, Enter, Escape, Home, Insert, left Alt, left ⌘ Command, left Ctrl, left ⇧ Shift, Page Down, Page Up, Return, right Alt, right ⌘ Command, right Ctrl, right ⇧ Shift, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, F13, F14, F15, F16, F17, F18, F19, F20, F21, F22, F23, F24.
 1This tests that DOM keydown and keyup events are dispatched to a non-editable <body> on iOS when pressing special keys on a hardware keyboard. To run this test manually, verify that two messages are emitted when you press the following keys: Tab, ↑, ↓, ←, →, Delete, End, Enter, Escape, Home, left Alt, left ⌘ Command, left Ctrl, left ⇧ Shift, Page Down, Page Up, Return, right Alt, right ⌘ Command, right Ctrl, right ⇧ Shift, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, F13, F14, F15, F16.
22
 3type: keydown, key: Tab, code: Tab, keyIdentifier: U+0009, keyCode: 9, charCode: 0, keyCode: 9, which: 9
 4type: keyup, key: Dead, code: Tab, keyIdentifier: Unidentified, keyCode: 9, charCode: 0, keyCode: 9, which: 9
35type: keydown, key: ArrowUp, code: ArrowUp, keyIdentifier: Up, keyCode: 38, charCode: 0, keyCode: 38, which: 38
46type: keyup, key: ArrowUp, code: ArrowUp, keyIdentifier: Up, keyCode: 38, charCode: 0, keyCode: 38, which: 38
57type: keydown, key: ArrowDown, code: ArrowDown, keyIdentifier: Down, keyCode: 40, charCode: 0, keyCode: 40, which: 40

LayoutTests/fast/events/ios/keydown-keyup-special-keys-in-non-editable-element.html

@@if (window.testRunner) {
1212</script>
1313</head>
1414<body onkeydown="handleKeyDown(event)" onkeyup="handleKeyUp(event)">
15 <p>This tests that DOM keydown and keyup events are dispatched to a non-editable &lt;body&gt; on iOS when pressing special keys on a hardware keyboard. To run this test manually, verify that two messages are emitted when you press the following keys: <kbd>↑</kbd>, <kbd>↓</kbd>, <kbd>←</kbd>, <kbd>→</kbd>, <kbd>Delete</kbd>, <kbd>End</kbd>, <kbd>Enter</kbd>, <kbd>Escape</kbd>, <kbd>Home</kbd>, <kbd>Insert</kbd>, left <kbd>Alt</kbd>, left <kbd>⌘ Command</kbd>, left <kbd>Ctrl</kbd>, left <kbd>⇧ Shift</kbd>, <kbd>Page Down</kbd>, <kbd>Page Up</kbd>, <kbd>Return</kbd>, right <kbd>Alt</kbd>, right <kbd>⌘ Command</kbd>, right <kbd>Ctrl</kbd>, right <kbd>⇧ Shift</kbd>, <kbd>F1</kbd>, <kbd>F2</kbd>, <kbd>F3</kbd>, <kbd>F4</kbd>, <kbd>F5</kbd>, <kbd>F6</kbd>, <kbd>F7</kbd>, <kbd>F8</kbd>, <kbd>F9</kbd>, <kbd>F10</kbd>, <kbd>F11</kbd>, <kbd>F12</kbd>, <kbd>F13</kbd>, <kbd>F14</kbd>, <kbd>F15</kbd>, <kbd>F16</kbd>, <kbd>F17</kbd>, <kbd>F18</kbd>, <kbd>F19</kbd>, <kbd>F20</kbd>, <kbd>F21</kbd>, <kbd>F22</kbd>, <kbd>F23</kbd>, <kbd>F24</kbd>.
 15<p>This tests that DOM keydown and keyup events are dispatched to a non-editable &lt;body&gt; on iOS when pressing special keys on a hardware keyboard. To run this test manually, verify that two messages are emitted when you press the following keys: <kbd>Tab</kbd>, <kbd>↑</kbd>, <kbd>↓</kbd>, <kbd>←</kbd>, <kbd>→</kbd>, <kbd>Delete</kbd>, <kbd>End</kbd>, <kbd>Enter</kbd>, <kbd>Escape</kbd>, <kbd>Home</kbd><!-- FIXME: Add <kbd>Insert</kbd> once <rdar://problem/47128940> is fixed. -->, left <kbd>Alt</kbd>, left <kbd>⌘ Command</kbd>, left <kbd>Ctrl</kbd>, left <kbd>⇧ Shift</kbd>, <kbd>Page Down</kbd>, <kbd>Page Up</kbd>, <kbd>Return</kbd>, right <kbd>Alt</kbd>, right <kbd>⌘ Command</kbd>, right <kbd>Ctrl</kbd>, right <kbd>⇧ Shift</kbd>, <kbd>F1</kbd>, <kbd>F2</kbd>, <kbd>F3</kbd>, <kbd>F4</kbd>, <kbd>F5</kbd>, <kbd>F6</kbd>, <kbd>F7</kbd>, <kbd>F8</kbd>, <kbd>F9</kbd>, <kbd>F10</kbd>, <kbd>F11</kbd>, <kbd>F12</kbd>, <kbd>F13</kbd>, <kbd>F14</kbd>, <kbd>F15</kbd>, <kbd>F16</kbd><!-- FIXME: Add <kbd>F17</kbd>, <kbd>F18</kbd>, <kbd>F19</kbd>, <kbd>F20</kbd>, <kbd>F21</kbd>, <kbd>F22</kbd>, <kbd>F23</kbd>, <kbd>F24</kbd> once <rdar://problem/47128940> is fixed.-->.
1616</p>
1717<pre id="console"></pre>
1818<script>
1919var remainingKeysToPress = [
 20 "\t",
2021 "upArrow",
2122 "downArrow",
2223 "leftArrow",

@@var remainingKeysToPress = [
2627 "enter",
2728 "escape",
2829 "home",
29  "insert",
 30 // FIXME: Add "insert" once <rdar://problem/47128940> is fixed.
3031 "leftAlt",
3132 "leftCommand",
3233 "leftControl",

@@var remainingKeysToPress = [
4041 "rightShift",
4142];
4243
43 for (let i = 1; i <= 24; ++i)
 44// FIXME: Check function keys up to F24 once <rdar://problem/47128940> is fixed.
 45for (let i = 1; i <= 16; ++i)
4446 remainingKeysToPress.push("F" + i);
4547
4648async function nextKeyPress()

LayoutTests/fast/events/ios/keypress-keys-in-non-editable-element-expected.txt

@@PASS delete did dispatch a keypress event.
5454PASS enter did dispatch a keypress event.
5555PASS escape did dispatch a keypress event.
5656PASS return did dispatch a keypress event.
57 PASS forwardDelete did dispatch a keypress event.
 57FAIL forwardDelete should not have dispatched a keypress event. It did dispatch one.
5858PASS upArrow did not dispatch a keypress event.
5959PASS downArrow did not dispatch a keypress event.
6060PASS leftArrow did not dispatch a keypress event.

@@PASS F13 did not dispatch a keypress event.
8989PASS F14 did not dispatch a keypress event.
9090PASS F15 did not dispatch a keypress event.
9191PASS F16 did not dispatch a keypress event.
92 PASS F17 did not dispatch a keypress event.
93 PASS F18 did not dispatch a keypress event.
94 PASS F19 did not dispatch a keypress event.
95 PASS F20 did not dispatch a keypress event.
96 PASS F21 did not dispatch a keypress event.
97 PASS F22 did not dispatch a keypress event.
98 PASS F23 did not dispatch a keypress event.
99 PASS F24 did not dispatch a keypress event.
10092PASS successfullyParsed is true
10193
10294TEST COMPLETE

LayoutTests/fast/events/ios/keypress-keys-in-non-editable-element.html

@@tests.push(new TestKeyPressDispatchedFor("enter"));
4141tests.push(new TestKeyPressDispatchedFor("escape"));
4242tests.push(new TestKeyPressDispatchedFor("return"));
4343
44 // The forward delete key is mapped to the delete key on iOS and dispatches a keypress event.
45 // On Mac it is treated as its own key and does not dispatch a keypress event.
46 tests.push(new TestKeyPressDispatchedFor("forwardDelete"));
47 
4844// Special keys: KeyPress should not be dispatched.
 45tests.push(new TestKeyPressNotDispatchedFor("forwardDelete"));
4946tests.push(new TestKeyPressNotDispatchedFor("upArrow"));
5047tests.push(new TestKeyPressNotDispatchedFor("downArrow"));
5148tests.push(new TestKeyPressNotDispatchedFor("leftArrow"));

@@tests.push(new TestKeyPressNotDispatchedFor("rightArrow"));
5350tests.push(new TestKeyPressNotDispatchedFor("clear"));
5451tests.push(new TestKeyPressNotDispatchedFor("end"));
5552tests.push(new TestKeyPressNotDispatchedFor("home"));
56 tests.push(new TestKeyPressNotDispatchedFor("insert"));
 53// FIXME: Test that keypress is not dispatched for "insert" once <rdar://problem/47128940> is fixed.
5754tests.push(new TestKeyPressNotDispatchedFor("leftAlt"));
5855tests.push(new TestKeyPressNotDispatchedFor("leftCommand"));
5956tests.push(new TestKeyPressNotDispatchedFor("leftControl"));

@@tests.push(new TestKeyPressNotDispatchedFor("rightAlt"));
6461tests.push(new TestKeyPressNotDispatchedFor("rightCommand"));
6562tests.push(new TestKeyPressNotDispatchedFor("rightControl"));
6663tests.push(new TestKeyPressNotDispatchedFor("rightShift"));
67 for (let i = 1; i <= 24; ++i)
 64// FIXME: Check function keys up to F24 once <rdar://problem/47128940> is fixed.
 65for (let i = 1; i <= 16; ++i)
6866 tests.push(new TestKeyPressNotDispatchedFor("F" + i));
6967
7068function nextKeyPress()

Source/WebCore/ChangeLog

 12019-01-11 Daniel Bates <dabates@apple.com>
 2
 3 [iOS] Keyups for non-modifier keys identified as "Dead" when not focused in a content-editable element
 4 https://bugs.webkit.org/show_bug.cgi?id=192824
 5 <rdar://problem/47100332>
 6
 7 Reviewed by Wenson Hsieh.
 8
 9 When building with USE(UIKIT_KEYBOARD_ADDITIONS) enabled, normalize input strings for some more key codes
 10 now that hardware key events to non-editable elements use the same code path as for editable elements.
 11
 12 * platform/ios/KeyEventIOS.mm:
 13 (WebCore::windowsKeyCodeForCharCode): Demarcate mappings that are only needed when building with
 14 !USE(UIKIT_KEYBOARD_ADDITIONS) in the hope that one day we can remove this code.
 15 (WebCore::isFunctionKey): Ditto.
 16 * platform/ios/WebEvent.mm:
 17 (normalizedStringWithAppKitCompatibilityMapping): Normalize some more input strings when building with
 18 USE(UIKIT_KEYBOARD_ADDITIONS) enabled.
 19
1202019-01-15 Chris Dumez <cdumez@apple.com>
221
322 Regression(PSON) View becomes blank after click a cross-site download link

Source/WebCore/PAL/ChangeLog

 12019-01-11 Daniel Bates <dabates@apple.com>
 2
 3 [iOS] Keyups for non-modifier keys identified as "Dead" when not focused in a content-editable element
 4 https://bugs.webkit.org/show_bug.cgi?id=192824
 5 <rdar://problem/47100332>
 6
 7 Reviewed by Wenson Hsieh.
 8
 9 Expose more enumerators.
 10
 11 * pal/spi/cocoa/IOKitSPI.h:
 12
1132019-01-14 Commit Queue <commit-queue@webkit.org>
214
315 Unreviewed, rolling out r239901, r239909, r239910, r239912,

Source/WebCore/PAL/pal/spi/cocoa/IOKitSPI.h

@@enum {
185185 kHIDUsage_KeyboardSlash = 0x38,
186186 kHIDUsage_KeyboardCapsLock = 0x39,
187187 kHIDUsage_KeyboardF1 = 0x3A,
 188 kHIDUsage_KeyboardF12 = 0x45,
188189 kHIDUsage_KeyboardPrintScreen = 0x46,
189190 kHIDUsage_KeyboardInsert = 0x49,
190191 kHIDUsage_KeyboardHome = 0x4A,

@@enum {
198199 kHIDUsage_KeyboardUpArrow = 0x52,
199200 kHIDUsage_KeypadNumLock = 0x53,
200201 kHIDUsage_KeyboardF13 = 0x68,
 202 kHIDUsage_KeyboardF24 = 0x73,
201203 kHIDUsage_KeyboardMenu = 0x76,
202204 kHIDUsage_KeyboardLeftControl = 0xE0,
203205 kHIDUsage_KeyboardLeftShift = 0xE1,

Source/WebCore/platform/ios/KeyEventIOS.mm

@@int windowsKeyCodeForKeyCode(uint16_t keyCode)
199199 return 0; // Unknown key
200200}
201201
 202// This function is only used to map software keyboard events because they lack a key code.
 203// When !USE(UIKIT_KEYBOARD_ADDITIONS), this function is also used to map hardware keyboard
 204// keyup events because they lack a key code.
202205int windowsKeyCodeForCharCode(unichar charCode)
203206{
204207 switch (charCode) {
205208 case 8: case 0x7F: return VK_BACK;
206209 case 9: return VK_TAB;
207210 case 0xD: case 3: return VK_RETURN;
208  case 0x1B: return VK_ESCAPE; // WebKit generated code for Escape.
209211 case ' ': return VK_SPACE;
210212
211213 case '0': case ')': return VK_0;

@@int windowsKeyCodeForCharCode(unichar charCode)
245247 case 'y': case 'Y': return VK_Y;
246248 case 'z': case 'Z': return VK_Z;
247249
 250#if !USE(UIKIT_KEYBOARD_ADDITIONS)
 251 case 0x1B: return VK_ESCAPE; // WebKit generated code for Escape.
 252
248253 // WebKit uses Unicode PUA codes in the OpenStep reserve range for some special keys.
249254 case NSUpArrowFunctionKey: return VK_UP;
250255 case NSDownArrowFunctionKey: return VK_DOWN;

@@int windowsKeyCodeForCharCode(unichar charCode)
252257 case NSRightArrowFunctionKey: return VK_RIGHT;
253258 case NSPageUpFunctionKey: return VK_PRIOR;
254259 case NSPageDownFunctionKey: return VK_NEXT;
 260#endif
255261
256262 // This is for U.S. keyboard mapping, and doesn't necessarily make sense for different keyboard layouts.
257263 // For example, '"' on Windows Russian layout is VK_2, not VK_OEM_7.

@@int windowsKeyCodeForCharCode(unichar charCode)
273279static bool isFunctionKey(UChar charCode)
274280{
275281 switch (charCode) {
 282#if !USE(UIKIT_KEYBOARD_ADDITIONS)
276283 case 1: // Home
277284 case 4: // End
278285 case 5: // FIXME: For some reason WebKitTestRunner generates this code for F14 (why?).
279286 case 0x7F: // Forward Delete
280287 case 0x10: // Function key (e.g. F1, F2, ...)
 288#endif
281289
282290 // WebKit uses Unicode PUA codes in the OpenStep reserve range for some special keys.
283291 case NSUpArrowFunctionKey:

@@static bool isFunctionKey(UChar charCode)
287295 case NSPageUpFunctionKey:
288296 case NSPageDownFunctionKey:
289297 case NSClearLineFunctionKey: // Num Lock / Clear
 298#if USE(UIKIT_KEYBOARD_ADDITIONS)
 299 case NSDeleteFunctionKey: // Forward delete
 300 case NSEndFunctionKey:
 301 case NSInsertFunctionKey:
 302 case NSHomeFunctionKey:
 303#endif
290304 return true;
291305 }
 306#if USE(UIKIT_KEYBOARD_ADDITIONS)
 307 if (charCode >= NSF1FunctionKey && charCode <= NSF24FunctionKey)
 308 return true;
 309#endif
292310 return false;
293311}
294312

Source/WebCore/platform/ios/WebEvent.mm

@@static NSString *normalizedStringWithAppKitCompatibilityMapping(NSString *charac
153153 return @"\x1B";
154154 case kHIDUsage_KeypadNumLock: // Num Lock / Clear
155155 return makeNSStringWithCharacter(NSClearLineFunctionKey);
 156#if USE(UIKIT_KEYBOARD_ADDITIONS)
 157 case kHIDUsage_KeyboardDeleteForward:
 158 return makeNSStringWithCharacter(NSDeleteFunctionKey);
 159 case kHIDUsage_KeyboardEnd:
 160 return makeNSStringWithCharacter(NSEndFunctionKey);
 161 case kHIDUsage_KeyboardInsert:
 162 return makeNSStringWithCharacter(NSInsertFunctionKey);
 163 case kHIDUsage_KeyboardHome:
 164 return makeNSStringWithCharacter(NSHomeFunctionKey);
 165#endif
156166 }
 167#if USE(UIKIT_KEYBOARD_ADDITIONS)
 168 if (keyCode >= kHIDUsage_KeyboardF1 && keyCode <= kHIDUsage_KeyboardF12)
 169 return makeNSStringWithCharacter(NSF1FunctionKey + (keyCode - kHIDUsage_KeyboardF1));
 170 if (keyCode >= kHIDUsage_KeyboardF13 && keyCode <= kHIDUsage_KeyboardF24)
 171 return makeNSStringWithCharacter(NSF13FunctionKey + (keyCode - kHIDUsage_KeyboardF13));
 172#endif
157173 return characters;
158174}
159175

Source/WebKit/ChangeLog

 12019-01-11 Daniel Bates <dabates@apple.com>
 2
 3 [iOS] Keyups for non-modifier keys identified as "Dead" when not focused in a content-editable element
 4 https://bugs.webkit.org/show_bug.cgi?id=192824
 5 <rdar://problem/47100332>
 6
 7 Reviewed by Wenson Hsieh.
 8
 9 Use the same code path for key events to editable elements and non-editable elements.
 10
 11 Currently we have different code paths for hardware key events depending on whether the active element
 12 is editable or non-editable. Historically to support dispatching DOM keyboard events for hardware key
 13 presses this differentiation was a necessary workaround for UIKit's event processing precedence of
 14 interpreting key events for system text editing commands and app commands before dispatching unhandled
 15 key events to WebKit. This workaround intercepted raw key UIEvents and manually reconstructed a
 16 WebEvent from it. However there is not enough information in an UIEvent to reconstruct a WebEvent that
 17 is identical to the WebEvent that UIKit would have dispatched. In particular, keyup UIEvents always have
 18 empty modified and unmodified input strings. The UIKit keyboard machinery maintains additional state
 19 that is necessary to manufacture the correct WebEvent corresponding to a UIEvent.
 20
 21 As a side benefit of this change, with the exception of modifier flag changes, both hardware and software
 22 key events use the same code path.
 23
 24 * UIProcess/ios/WKContentViewInteraction.h:
 25 * UIProcess/ios/WKContentViewInteraction.mm:
 26 (-[WKContentView _disableAutomaticKeyboardUI]): Implement UIKit SPI to prevent showing the keyboard UI
 27 when there is no focused element now that we are no longer intercepting key UIEvents. Formerly the
 28 keyboard UI was disabled as a side effect of not becoming first responder when there was no focused
 29 element (by returning NO in -_requiresKeyboardWhenFirstResponder).
 30 (-[WKContentView _requiresKeyboardWhenFirstResponder]): Return YES when there is no focused element.
 31 (-[WKContentView textInputTraits]): Do not update traits when the keyboard is going to be dismissed
 32 now that we require a keyboard when first responder even if the focused element is non-editable.
 33 (-[WKContentView _didHandleKeyEvent:eventWasHandled:]): Skip logic for re-sending UIEvents to UIKit
 34 as UIKit now processes the event first. This logic was necessary in order to finally allow UIKit
 35 its chance to interpret the UIEvent, we intercepted, for app key commands.
 36
1372019-01-02 Daniel Bates <dabates@apple.com>
238
339 [iOS] Pressing Tab key doesn't move to next cell with Google Sheets

Source/WebKit/UIProcess/ios/WKContentViewInteraction.h

@@struct WKAutoCorrectionData {
256256 WebKit::InteractionInformationAtPosition _positionInformation;
257257 WebKit::FocusedElementInformation _focusedElementInformation;
258258 RetainPtr<NSObject<WKFormPeripheral>> _inputPeripheral;
 259#if !USE(UIKIT_KEYBOARD_ADDITIONS)
259260 RetainPtr<UIEvent> _uiEventBeingResent;
 261#endif
260262 BlockPtr<void(::WebEvent *, BOOL)> _keyWebEventHandler;
261263
262264 CGPoint _lastInteractionLocation;

Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm

6060#import "WKTextInputListViewController.h"
6161#import "WKTimePickerViewController.h"
6262#import "WKUIDelegatePrivate.h"
63 #import "WKWebEvent.h"
6463#import "WKWebViewConfiguration.h"
6564#import "WKWebViewConfigurationPrivate.h"
6665#import "WKWebViewInternal.h"

125124#import "WKFormColorControl.h"
126125#endif
127126
 127#if !USE(UIKIT_KEYBOARD_ADDITIONS)
 128#import "WKWebEvent.h"
 129#endif
 130
128131#if USE(APPLE_INTERNAL_SDK) && __has_include(<WebKitAdditions/WKPlatformFileUploadPanel.mm>)
129132#import <WebKitAdditions/WKPlatformFileUploadPanel.mm>
130133#endif

@@- (void)_scrollingNodeScrollingDidEnd
13711374 [_textSelectionAssistant didEndScrollingOverflow];
13721375}
13731376
 1377#if USE(UIKIT_KEYBOARD_ADDITIONS)
 1378- (BOOL)_disableAutomaticKeyboardUI
 1379{
 1380 return [self isFirstResponder] && _focusedElementInformation.elementType == WebKit::InputType::None;
 1381}
 1382#endif
 1383
13741384- (BOOL)_requiresKeyboardWhenFirstResponder
13751385{
13761386 // FIXME: We should add the logic to handle keyboard visibility during focus redirects.
13771387 switch (_focusedElementInformation.elementType) {
13781388 case WebKit::InputType::None:
 1389#if USE(UIKIT_KEYBOARD_ADDITIONS)
 1390 return YES;
 1391#else
 1392 return NO;
 1393#endif
13791394 case WebKit::InputType::Drawing:
13801395 return NO;
13811396 case WebKit::InputType::Select:

@@- (UITextInputTraits *)textInputTraits
37913806 if (!_traits)
37923807 _traits = adoptNS([[UITextInputTraits alloc] init]);
37933808
 3809 // Do not change traits when dismissing the keyboard.
 3810 if (_isBlurringFocusedNode)
 3811 return _traits.get();
 3812
37943813 [_traits setSecureTextEntry:_focusedElementInformation.elementType == WebKit::InputType::Password || [_formInputSession forceSecureTextEntry]];
37953814 [_traits setShortcutConversionType:_focusedElementInformation.elementType == WebKit::InputType::Password ? UITextShortcutConversionTypeNo : UITextShortcutConversionTypeDefault];
37963815

@@- (BOOL)requiresKeyEvents
39493968 return YES;
39503969}
39513970
 3971#if !USE(UIKIT_KEYBOARD_ADDITIONS)
39523972- (void)_handleKeyUIEvent:(::UIEvent *)event
39533973{
39543974 bool isHardwareKeyboardEvent = !!event._hidEvent;

@@- (void)handleKeyEvent:(::UIEvent *)event
39733993
39743994 [self handleKeyWebEvent:webEvent.get()];
39753995}
 3996#endif
39763997
39773998- (void)handleKeyWebEvent:(::WebEvent *)theEvent
39783999{

@@- (void)_didHandleKeyEvent:(::WebEvent *)event eventWasHandled:(BOOL)eventWasHan
40004021 return;
40014022 }
40024023
 4024#if !USE(UIKIT_KEYBOARD_ADDITIONS)
40034025 // If we aren't interacting with editable content, we still need to call [super _handleKeyUIEvent:]
40044026 // so that keyboard repeat will work correctly. If we are interacting with editable content,
40054027 // we already did so in _handleKeyUIEvent.

@@- (void)_didHandleKeyEvent:(::WebEvent *)event eventWasHandled:(BOOL)eventWasHan
40184040 _uiEventBeingResent = [(WKWebEvent *)event uiEvent];
40194041 [super _handleKeyUIEvent:_uiEventBeingResent.get()];
40204042 _uiEventBeingResent = nil;
 4043#endif
40214044}
40224045
40234046- (BOOL)_interpretKeyEvent:(::WebEvent *)event isCharEvent:(BOOL)isCharEvent

Tools/ChangeLog

 12019-01-11 Daniel Bates <dabates@apple.com>
 2
 3 [iOS] Keyups for non-modifier keys identified as "Dead" when not focused in a content-editable element
 4 https://bugs.webkit.org/show_bug.cgi?id=192824
 5 <rdar://problem/47100332>
 6
 7 Reviewed by Wenson Hsieh.
 8
 9 Fix a bug where the wrong usage code was used for F13 thru F24.
 10
 11 * WebKitTestRunner/ios/HIDEventGenerator.mm:
 12 (keyCodeForDOMFunctionKey):
 13
1142019-01-15 Chris Dumez <cdumez@apple.com>
215
316 Regression(PSON) View becomes blank after click a cross-site download link

Tools/WebKitTestRunner/ios/HIDEventGenerator.mm

@@static Optional<uint32_t> keyCodeForDOMFunctionKey(NSString *key)
834834 }
835835 for (int i = 13; i <= 24; ++i) {
836836 if ([key isEqualToString:[NSString stringWithFormat:@"F%d", i]])
837  return kHIDUsage_KeyboardF13 + i - 1;
 837 return kHIDUsage_KeyboardF13 + i - 13;
838838 }
839839 return WTF::nullopt;
840840}