Changeset 237738 in webkit


Ignore:
Timestamp:
Nov 2, 2018 10:17:09 AM (6 years ago)
Author:
dbates@webkit.org
Message:

[iOS] WebKit should dispatch DOM events when a modifier key is pressed
https://bugs.webkit.org/show_bug.cgi?id=190487

Reviewed by Tim Horton.

Source/WebCore:

Add support for modifier flags change events.

  • platform/ios/PlatformEventFactoryIOS.mm:

(WebCore::modifiersForEvent): Modifier keys do not have an associated character and do not
participate in key repeat.
(WebCore::keyIdentifierForKeyEvent): Identify modifier keys, returning "Unidentified" if
the modifier key is unidentified. This matches the behavior on Mac.
(WebCore::keyForKeyEvent): Identify modifier keys, returning the empty string if the modifier
key is unidentified. This matches the behavior on Mac.
(WebCore::PlatformKeyboardEventBuilder::PlatformKeyboardEventBuilder):

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

(-[WebEvent initWithKeyEventType:timeStamp:characters:charactersIgnoringModifiers:modifiers:isRepeating:withFlags:keyCode:isTabKey:characterSet:]):
(-[WebEvent initWithKeyEventType:timeStamp:characters:charactersIgnoringModifiers:modifiers:isRepeating:withFlags:withInputManagerHint:keyCode:isTabKey:]):
Modifier keys do not have an associated character and do not participate in key repeat.

(-[WebEvent _eventDescription]): Modified to print a description for a keydown or keyup event
that represents a modifier flags change.
(-[WebEvent characters]): Modifier keys do not have an associated character. Assert this
invariant as it is a programming error. On Mac, the same operation would result in a
NSInternalInconsistencyException exception being raised.
(-[WebEvent charactersIgnoringModifiers]): Ditto.

Source/WebKit:

Add support for modifier flags change events dispatched by UIKit.

  • Shared/ios/WebIOSEventFactory.mm:

(modifiersForEvent): Update for renamed enumerations.
(WebIOSEventFactory::createWebKeyboardEvent): Modifier keys do not have an associated
character and do not participate in key repeat.

  • UIProcess/Automation/ios/WebAutomationSessionIOS.mm:

(WebKit::WebAutomationSession::platformSimulateKeyboardInteraction): Update for renamed enumerations.

  • UIProcess/ios/WKContentViewInteraction.mm:

(-[WKContentView _interpretKeyEvent:isCharEvent:]): Return NO if the event represents a
modifier flags change to allow the default handling.

  • UIProcess/ios/WKKeyboardScrollingAnimator.mm:

(-[WKKeyboardScrollingAnimator keyboardScrollForEvent:]): Update for renamed enumerations.

Source/WebKitLegacy/mac:

Having Legacy WebKit return NO if the editing event represents a modifier flags change to
allow the default handling.

  • WebView/WebHTMLView.mm:

(-[WebHTMLView _handleEditingKeyEvent:]):

Tools:

Update the code for renamed enumerations. For WebKitTestRunner, removed comment that does not
match my observations when using the simulator to simulate iOS 12 and add support for testing
right-hand side modifiers.

  • DumpRenderTree/mac/EventSendingController.mm:

(modifierFlags):
(-[EventSendingController keyDown:withModifiers:withLocation:]):
(-[EventSendingController setTouchModifier:value:]):

  • WebKitTestRunner/ios/HIDEventGenerator.mm:

(hidUsageCodeForCharacter):

LayoutTests:

Update expected results of an existing test now that we identify modifier keys.

  • fast/events/ios/keydown-keyup-special-keys-in-non-editable-element-expected.txt:
Location:
trunk
Files:
16 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r237737 r237738  
     12018-11-02  Daniel Bates  <dabates@apple.com>
     2
     3        [iOS] WebKit should dispatch DOM events when a modifier key is pressed
     4        https://bugs.webkit.org/show_bug.cgi?id=190487
     5
     6        Reviewed by Tim Horton.
     7
     8        Update expected results of an existing test now that we identify modifier keys.
     9
     10        * fast/events/ios/keydown-keyup-special-keys-in-non-editable-element-expected.txt:
     11
    1122018-11-02  Ali Juma  <ajuma@chromium.org>
    213
  • trunk/LayoutTests/fast/events/ios/keydown-keyup-special-keys-in-non-editable-element-expected.txt

    r236678 r237738  
    2121type: keydown, key: Dead, code: Unidentified, keyIdentifier: Unidentified, keyCode: 45, charCode: 0, keyCode: 45, which: 45
    2222type: keyup, key: Dead, code: Unidentified, keyIdentifier: Unidentified, keyCode: 45, charCode: 0, keyCode: 45, which: 45
    23 type: keydown, key: Dead, code: Unidentified, keyIdentifier: Unidentified, keyCode: 18, charCode: 0, keyCode: 18, which: 18
    24 type: keyup, key: Dead, code: Unidentified, keyIdentifier: Unidentified, keyCode: 18, charCode: 0, keyCode: 18, which: 18
    25 type: keydown, key: Dead, code: MetaLeft, keyIdentifier: Unidentified, keyCode: 91, charCode: 0, keyCode: 91, which: 91
    26 type: keyup, key: Dead, code: MetaLeft, keyIdentifier: Unidentified, keyCode: 91, charCode: 0, keyCode: 91, which: 91
    27 type: keydown, key: Dead, code: ControlLeft, keyIdentifier: Unidentified, keyCode: 17, charCode: 0, keyCode: 17, which: 17
    28 type: keyup, key: Dead, code: ControlLeft, keyIdentifier: Unidentified, keyCode: 17, charCode: 0, keyCode: 17, which: 17
    29 type: keydown, key: Dead, code: ShiftLeft, keyIdentifier: Unidentified, keyCode: 16, charCode: 0, keyCode: 16, which: 16
    30 type: keyup, key: Dead, code: ShiftLeft, keyIdentifier: Unidentified, keyCode: 16, charCode: 0, keyCode: 16, which: 16
     23type: keydown, key: Alt, code: Unidentified, keyIdentifier: Alt, keyCode: 18, charCode: 0, keyCode: 18, which: 18
     24type: keyup, key: Alt, code: Unidentified, keyIdentifier: Alt, keyCode: 18, charCode: 0, keyCode: 18, which: 18
     25type: keydown, key: Meta, code: MetaLeft, keyIdentifier: Meta, keyCode: 91, charCode: 0, keyCode: 91, which: 91
     26type: keyup, key: Meta, code: MetaLeft, keyIdentifier: Meta, keyCode: 91, charCode: 0, keyCode: 91, which: 91
     27type: keydown, key: Control, code: ControlLeft, keyIdentifier: Control, keyCode: 17, charCode: 0, keyCode: 17, which: 17
     28type: keyup, key: Control, code: ControlLeft, keyIdentifier: Control, keyCode: 17, charCode: 0, keyCode: 17, which: 17
     29type: keydown, key: Shift, code: ShiftLeft, keyIdentifier: Shift, keyCode: 16, charCode: 0, keyCode: 16, which: 16
     30type: keyup, key: Shift, code: ShiftLeft, keyIdentifier: Shift, keyCode: 16, charCode: 0, keyCode: 16, which: 16
    3131type: keydown, key: PageDown, code: PageDown, keyIdentifier: PageDown, keyCode: 34, charCode: 0, keyCode: 34, which: 34
    3232type: keyup, key: PageDown, code: PageDown, keyIdentifier: PageDown, keyCode: 34, charCode: 0, keyCode: 34, which: 34
     
    3535type: keydown, key: Enter, code: Enter, keyIdentifier: Enter, keyCode: 13, charCode: 0, keyCode: 13, which: 13
    3636type: keyup, key: Dead, code: Enter, keyIdentifier: Unidentified, keyCode: 13, charCode: 0, keyCode: 13, which: 13
    37 type: keydown, key: Dead, code: Unidentified, keyIdentifier: Unidentified, keyCode: 18, charCode: 0, keyCode: 18, which: 18
    38 type: keyup, key: Dead, code: Unidentified, keyIdentifier: Unidentified, keyCode: 18, charCode: 0, keyCode: 18, which: 18
    39 type: keydown, key: Dead, code: Unidentified, keyIdentifier: Unidentified, keyCode: 93, charCode: 0, keyCode: 93, which: 93
    40 type: keyup, key: Dead, code: Unidentified, keyIdentifier: Unidentified, keyCode: 93, charCode: 0, keyCode: 93, which: 93
    41 type: keydown, key: Dead, code: ControlLeft, keyIdentifier: Unidentified, keyCode: 17, charCode: 0, keyCode: 17, which: 17
    42 type: keyup, key: Dead, code: ControlLeft, keyIdentifier: Unidentified, keyCode: 17, charCode: 0, keyCode: 17, which: 17
    43 type: keydown, key: Dead, code: ShiftLeft, keyIdentifier: Unidentified, keyCode: 16, charCode: 0, keyCode: 16, which: 16
    44 type: keyup, key: Dead, code: ShiftLeft, keyIdentifier: Unidentified, keyCode: 16, charCode: 0, keyCode: 16, which: 16
     37type: keydown, key: Alt, code: Unidentified, keyIdentifier: Alt, keyCode: 18, charCode: 0, keyCode: 18, which: 18
     38type: keyup, key: Alt, code: Unidentified, keyIdentifier: Alt, keyCode: 18, charCode: 0, keyCode: 18, which: 18
     39type: keydown, key: Meta, code: Unidentified, keyIdentifier: Meta, keyCode: 93, charCode: 0, keyCode: 93, which: 93
     40type: keyup, key: Meta, code: Unidentified, keyIdentifier: Meta, keyCode: 93, charCode: 0, keyCode: 93, which: 93
     41type: keydown, key: Control, code: ControlRight, keyIdentifier: Control, keyCode: 17, charCode: 0, keyCode: 17, which: 17
     42type: keyup, key: Control, code: ControlRight, keyIdentifier: Control, keyCode: 17, charCode: 0, keyCode: 17, which: 17
     43type: keydown, key: Shift, code: ShiftRight, keyIdentifier: Shift, keyCode: 16, charCode: 0, keyCode: 16, which: 16
     44type: keyup, key: Shift, code: ShiftRight, keyIdentifier: Shift, keyCode: 16, charCode: 0, keyCode: 16, which: 16
    4545type: keydown, key: , code: F1, keyIdentifier: U+0010, keyCode: 112, charCode: 0, keyCode: 112, which: 112
    4646type: keyup, key: Dead, code: F1, keyIdentifier: Unidentified, keyCode: 112, charCode: 0, keyCode: 112, which: 112
  • trunk/Source/WebCore/ChangeLog

    r237737 r237738  
     12018-11-02  Daniel Bates  <dabates@apple.com>
     2
     3        [iOS] WebKit should dispatch DOM events when a modifier key is pressed
     4        https://bugs.webkit.org/show_bug.cgi?id=190487
     5
     6        Reviewed by Tim Horton.
     7
     8        Add support for modifier flags change events.
     9
     10        * platform/ios/PlatformEventFactoryIOS.mm:
     11        (WebCore::modifiersForEvent): Modifier keys do not have an associated character and do not
     12        participate in key repeat.
     13        (WebCore::keyIdentifierForKeyEvent): Identify modifier keys, returning "Unidentified" if
     14        the modifier key is unidentified. This matches the behavior on Mac.
     15        (WebCore::keyForKeyEvent): Identify modifier keys, returning the empty string if the modifier
     16        key is unidentified. This matches the behavior on Mac.
     17        (WebCore::PlatformKeyboardEventBuilder::PlatformKeyboardEventBuilder):
     18        * platform/ios/WebEvent.h:
     19
     20        * platform/ios/WebEvent.mm:
     21        (-[WebEvent initWithKeyEventType:timeStamp:characters:charactersIgnoringModifiers:modifiers:isRepeating:withFlags:keyCode:isTabKey:characterSet:]):
     22        (-[WebEvent initWithKeyEventType:timeStamp:characters:charactersIgnoringModifiers:modifiers:isRepeating:withFlags:withInputManagerHint:keyCode:isTabKey:]):
     23        Modifier keys do not have an associated character and do not participate in key repeat.
     24
     25        (-[WebEvent _eventDescription]): Modified to print a description for a keydown or keyup event
     26        that represents a modifier flags change.
     27        (-[WebEvent characters]): Modifier keys do not have an associated character. Assert this
     28        invariant as it is a programming error. On Mac, the same operation would result in a
     29        NSInternalInconsistencyException exception being raised.
     30        (-[WebEvent charactersIgnoringModifiers]): Ditto.
     31
    1322018-11-02  Ali Juma  <ajuma@chromium.org>
    233
  • trunk/Source/WebCore/platform/ios/PlatformEventFactoryIOS.mm

    r237266 r237738  
    4545    OptionSet<PlatformEvent::Modifier> modifiers;
    4646
    47     if (event.modifierFlags & WebEventFlagMaskShift)
     47    if (event.modifierFlags & WebEventFlagMaskShiftKey)
    4848        modifiers.add(PlatformEvent::Modifier::ShiftKey);
    49     if (event.modifierFlags & WebEventFlagMaskControl)
     49    if (event.modifierFlags & WebEventFlagMaskControlKey)
    5050        modifiers.add(PlatformEvent::Modifier::CtrlKey);
    51     if (event.modifierFlags & WebEventFlagMaskAlternate)
     51    if (event.modifierFlags & WebEventFlagMaskOptionKey)
    5252        modifiers.add(PlatformEvent::Modifier::AltKey);
    53     if (event.modifierFlags & WebEventFlagMaskCommand)
     53    if (event.modifierFlags & WebEventFlagMaskCommandKey)
    5454        modifiers.add(PlatformEvent::Modifier::MetaKey);
    55     if (event.modifierFlags & WebEventFlagMaskAlphaShift)
     55    if (event.modifierFlags & WebEventFlagMaskLeftCapsLockKey)
    5656        modifiers.add(PlatformEvent::Modifier::CapsLockKey);
    5757
     
    128128String keyIdentifierForKeyEvent(WebEvent *event)
    129129{
     130    if (event.keyboardFlags & WebEventKeyboardInputModifierFlagsChanged) {
     131        switch (event.keyCode) {
     132        case VK_LWIN: // Left Command
     133        case VK_APPS: // Right Command
     134            return "Meta"_s;
     135
     136        case VK_CAPITAL: // Caps Lock
     137            return "CapsLock"_s;
     138
     139        case VK_LSHIFT: // Left Shift
     140        case VK_RSHIFT: // Right Shift
     141            return "Shift"_s;
     142
     143        case VK_LMENU: // Left Alt
     144        case VK_RMENU: // Right Alt
     145            return "Alt"_s;
     146
     147        case VK_LCONTROL: // Left Ctrl
     148        case VK_RCONTROL: // Right Ctrl
     149            return "Control"_s;
     150
     151        default:
     152            ASSERT_NOT_REACHED();
     153            return emptyString();
     154        }
     155    }
    130156    NSString *characters = event.charactersIgnoringModifiers;
    131157    if ([characters length] != 1) {
     
    138164String keyForKeyEvent(WebEvent *event)
    139165{
     166    if (event.keyboardFlags & WebEventKeyboardInputModifierFlagsChanged) {
     167        switch (event.keyCode) {
     168        case VK_LWIN: // Left Command
     169        case VK_APPS: // Right Command
     170            return "Meta"_s;
     171
     172        case VK_CAPITAL: // Caps Lock
     173            return "CapsLock"_s;
     174
     175        case VK_LSHIFT: // Left Shift
     176        case VK_RSHIFT: // Right Shift
     177            return "Shift"_s;
     178
     179        case VK_LMENU: // Left Alt
     180        case VK_RMENU: // Right Alt
     181            return "Alt"_s;
     182
     183        case VK_LCONTROL: // Left Ctrl
     184        case VK_RCONTROL: // Right Ctrl
     185            return "Control"_s;
     186
     187        default:
     188            ASSERT_NOT_REACHED();
     189            return "Unidentified"_s;
     190        }
     191    }
     192
    140193    NSString *characters = event.characters;
    141194    auto length = [characters length];
     
    372425        m_timestamp = WallTime::now();
    373426
    374         m_text = event.characters;
    375         m_unmodifiedText = event.charactersIgnoringModifiers;
     427        if (event.keyboardFlags & WebEventKeyboardInputModifierFlagsChanged) {
     428            m_text = emptyString();
     429            m_unmodifiedText = emptyString();
     430            m_autoRepeat = false;
     431        } else {
     432            m_text = event.characters;
     433            m_unmodifiedText = event.charactersIgnoringModifiers;
     434            m_autoRepeat = event.isKeyRepeating;
     435        }
    376436        m_key = keyForKeyEvent(event);
    377437        m_code = codeForKeyEvent(event);
    378438        m_keyIdentifier = keyIdentifierForKeyEvent(event);
    379439        m_windowsVirtualKeyCode = event.keyCode;
    380         m_autoRepeat = event.isKeyRepeating;
    381440        m_isKeypad = false; // iOS does not distinguish the numpad. See <rdar://problem/7190835>.
    382441        m_isSystemKey = false;
  • trunk/Source/WebCore/platform/ios/WebEvent.h

    r237266 r237738  
    5757} WebEventTouchPhaseType;
    5858
    59 // These enum values are copied directly from GSEvent for compatibility.
    60 typedef enum {
    61     WebEventFlagMaskAlphaShift = 0x00010000,
    62     WebEventFlagMaskShift      = 0x00020000,
    63     WebEventFlagMaskControl    = 0x00040000,
    64     WebEventFlagMaskAlternate  = 0x00080000,
    65     WebEventFlagMaskCommand    = 0x00100000,
     59// These enum values correspond to the GraphicsServices kGSEvent* enumerators for compatibility.
     60enum {
     61    WebEventLeftCommandKey,
     62    WebEventLeftShiftKey,
     63    WebEventLeftCapsLockKey,
     64    WebEventLeftOptionKey,
     65    WebEventLeftControlKey,
     66    WebEventRightShiftKey,
     67    WebEventRightOptionKey,
     68    WebEventRightControlKey,
     69    WebEventRightCommandKey,
     70    WebEventDeadKey,
     71};
     72
     73// These enum values correspond to the GraphicsServices kGSEventFlagMask* enumerators for compatibility.
     74typedef enum {
     75    WebEventFlagMaskLeftCommandKey = 1 << (WebEventLeftCommandKey + 16),
     76    WebEventFlagMaskLeftShiftKey = 1 << (WebEventLeftShiftKey + 16),
     77    WebEventFlagMaskLeftCapsLockKey = 1 << (WebEventLeftCapsLockKey + 16),
     78    WebEventFlagMaskLeftOptionKey = 1 << (WebEventLeftOptionKey + 16),
     79    WebEventFlagMaskLeftControlKey = 1 << (WebEventLeftControlKey + 16),
     80    WebEventFlagMaskRightControlKey = 1 << (WebEventRightControlKey + 16),
     81    WebEventFlagMaskRightShiftKey = 1 << (WebEventRightShiftKey + 16),
     82    WebEventFlagMaskRightOptionKey = 1 << (WebEventRightOptionKey + 16),
     83    WebEventFlagMaskRightCommandKey = 1 << (WebEventRightCommandKey + 16),
    6684} WebEventFlagValues;
    6785typedef unsigned WebEventFlags;
    6886
    69 // These enum values are copied directly from GSEvent for compatibility.
     87// These enum values correspond to the GraphicsServices kGSEventFlagMask* enumerators for compatibility.
     88enum {
     89    WebEventFlagMaskCommandKey = WebEventFlagMaskLeftCommandKey | WebEventFlagMaskRightCommandKey,
     90    WebEventFlagMaskOptionKey = WebEventFlagMaskLeftOptionKey | WebEventFlagMaskRightOptionKey,
     91    WebEventFlagMaskControlKey = WebEventFlagMaskLeftControlKey | WebEventFlagMaskRightControlKey,
     92    WebEventFlagMaskShiftKey = WebEventFlagMaskLeftShiftKey | WebEventFlagMaskRightShiftKey,
     93};
     94
     95// These enum values correspond to the GraphicsServices kGSCharacterSet* constants for compatibility.
    7096typedef enum {
    7197    WebEventCharacterSetASCII           = 0,
     
    79105typedef enum {
    80106    WebEventKeyboardInputRepeat = 1 << 0,
     107    WebEventKeyboardInputModifierFlagsChanged = 1 << 5,
    81108} WebKeyboardInputFlagValues;
    82109typedef NSUInteger WebKeyboardInputFlags;
  • trunk/Source/WebCore/platform/ios/WebEvent.mm

    r237266 r237738  
    185185    _type = type;
    186186    _timestamp = timeStamp;
    187 
    188     _characters = [normalizedStringWithAppKitCompatibilityMapping(characters) retain];
    189     _charactersIgnoringModifiers = [normalizedStringWithAppKitCompatibilityMapping(charactersIgnoringModifiers) retain];
     187    _keyboardFlags = flags;
    190188    _modifierFlags = modifiers;
    191     _keyRepeating = repeating;
    192     _keyboardFlags = flags;
    193     _tabKey = tabKey;
    194    
    195189    if (keyCode)
    196190        _keyCode = windowsKeyCodeForKeyCode(keyCode);
     
    198192        // This event is likely for a software keyboard-generated event.
    199193        _keyCode = windowsKeyCodeForCharCodeIOS([charactersIgnoringModifiers characterAtIndex:0]);
     194    }
     195
     196    if (!(_keyboardFlags & WebEventKeyboardInputModifierFlagsChanged)) {
     197        _characters = [normalizedStringWithAppKitCompatibilityMapping(characters) retain];
     198        _charactersIgnoringModifiers = [normalizedStringWithAppKitCompatibilityMapping(charactersIgnoringModifiers) retain];
     199        _tabKey = tabKey;
     200        _keyRepeating = repeating;
    200201    }
    201202
     
    220221    _type = type;
    221222    _timestamp = timeStamp;
    222    
    223     _characters = [normalizedStringWithAppKitCompatibilityMapping(characters) retain];
    224     _charactersIgnoringModifiers = [normalizedStringWithAppKitCompatibilityMapping(charactersIgnoringModifiers) retain];
    225223    _modifierFlags = modifiers;
    226     _keyRepeating = repeating;
    227224    _keyboardFlags = flags;
    228225    _inputManagerHint = [hint retain];
    229     _tabKey = tabKey;
    230    
    231226    if (keyCode)
    232227        _keyCode = windowsKeyCodeForKeyCode(keyCode);
     
    234229        // This event is likely for a software keyboard-generated event.
    235230        _keyCode = windowsKeyCodeForCharCodeIOS([charactersIgnoringModifiers characterAtIndex:0]);
     231    }
     232
     233    if (!(_keyboardFlags & WebEventKeyboardInputModifierFlagsChanged)) {
     234        _characters = [normalizedStringWithAppKitCompatibilityMapping(characters) retain];
     235        _charactersIgnoringModifiers = [normalizedStringWithAppKitCompatibilityMapping(charactersIgnoringModifiers) retain];
     236        _tabKey = tabKey;
     237        _keyRepeating = repeating;
    236238    }
    237239
     
    374376    case WebEventKeyDown:
    375377    case WebEventKeyUp:
     378        if (_keyboardFlags & WebEventKeyboardInputModifierFlagsChanged)
     379            return [NSString stringWithFormat:@"flags: %d keyboardFlags: %lu keyCode %d", _modifierFlags, static_cast<unsigned long>(_keyboardFlags), _keyCode];
    376380        return [NSString stringWithFormat:@"chars: %@ charsNoModifiers: %@ flags: %d repeating: %d keyboardFlags: %lu keyCode %d, isTab: %d", _characters, _charactersIgnoringModifiers, _modifierFlags, _keyRepeating, static_cast<unsigned long>(_keyboardFlags), _keyCode, _tabKey];
    377381    case WebEventTouchBegin:
     
    403407{
    404408    ASSERT(_type == WebEventKeyDown || _type == WebEventKeyUp);
     409    ASSERT(!(_keyboardFlags & WebEventKeyboardInputModifierFlagsChanged));
    405410    return [[_characters retain] autorelease];
    406411}
     
    409414{
    410415    ASSERT(_type == WebEventKeyDown || _type == WebEventKeyUp);
     416    ASSERT(!(_keyboardFlags & WebEventKeyboardInputModifierFlagsChanged));
    411417    return [[_charactersIgnoringModifiers retain] autorelease];
    412418}
  • trunk/Source/WebKit/ChangeLog

    r237735 r237738  
     12018-11-02  Daniel Bates  <dabates@apple.com>
     2
     3        [iOS] WebKit should dispatch DOM events when a modifier key is pressed
     4        https://bugs.webkit.org/show_bug.cgi?id=190487
     5
     6        Reviewed by Tim Horton.
     7
     8        Add support for modifier flags change events dispatched by UIKit.
     9
     10        * Shared/ios/WebIOSEventFactory.mm:
     11        (modifiersForEvent): Update for renamed enumerations.
     12        (WebIOSEventFactory::createWebKeyboardEvent): Modifier keys do not have an associated
     13        character and do not participate in key repeat.
     14        * UIProcess/Automation/ios/WebAutomationSessionIOS.mm:
     15        (WebKit::WebAutomationSession::platformSimulateKeyboardInteraction): Update for renamed enumerations.
     16        * UIProcess/ios/WKContentViewInteraction.mm:
     17        (-[WKContentView _interpretKeyEvent:isCharEvent:]): Return NO if the event represents a
     18        modifier flags change to allow the default handling.
     19        * UIProcess/ios/WKKeyboardScrollingAnimator.mm:
     20        (-[WKKeyboardScrollingAnimator keyboardScrollForEvent:]): Update for renamed enumerations.
     21
    1222018-11-02  Chris Dumez  <cdumez@apple.com>
    223
  • trunk/Source/WebKit/Shared/ios/WebIOSEventFactory.mm

    r237266 r237738  
    3737    WebEventFlags eventModifierFlags = event.modifierFlags;
    3838
    39     if (eventModifierFlags & WebEventFlagMaskShift)
     39    if (eventModifierFlags & WebEventFlagMaskShiftKey)
    4040        modifiers |= WebKit::WebEvent::ShiftKey;
    41     if (eventModifierFlags & WebEventFlagMaskControl)
     41    if (eventModifierFlags & WebEventFlagMaskControlKey)
    4242        modifiers |= WebKit::WebEvent::ControlKey;
    43     if (eventModifierFlags & WebEventFlagMaskAlternate)
     43    if (eventModifierFlags & WebEventFlagMaskOptionKey)
    4444        modifiers |= WebKit::WebEvent::AltKey;
    45     if (eventModifierFlags & WebEventFlagMaskCommand)
     45    if (eventModifierFlags & WebEventFlagMaskCommandKey)
    4646        modifiers |= WebKit::WebEvent::MetaKey;
    47     if (eventModifierFlags & WebEventFlagMaskAlphaShift)
     47    if (eventModifierFlags & WebEventFlagMaskLeftCapsLockKey)
    4848        modifiers |= WebKit::WebEvent::CapsLockKey;
    4949
     
    5454{
    5555    WebKit::WebEvent::Type type = (event.type == WebEventKeyUp) ? WebKit::WebEvent::KeyUp : WebKit::WebEvent::KeyDown;
    56     String text = event.characters;
    57     String unmodifiedText = event.charactersIgnoringModifiers;
     56    String text;
     57    String unmodifiedText;
     58    bool autoRepeat;
     59    if (event.keyboardFlags & WebEventKeyboardInputModifierFlagsChanged) {
     60        text = emptyString();
     61        unmodifiedText = emptyString();
     62        autoRepeat = false;
     63    } else {
     64        text = event.characters;
     65        unmodifiedText = event.charactersIgnoringModifiers;
     66        autoRepeat = event.isKeyRepeating;
     67    }
    5868    String key = WebCore::keyForKeyEvent(event);
    5969    String code = WebCore::codeForKeyEvent(event);
     
    6373    int nativeVirtualKeyCode = event.keyCode;
    6474    int macCharCode = 0;
    65     bool autoRepeat = event.isKeyRepeating;
    6675    bool isKeypad = false;
    6776    bool isSystemKey = false;
  • trunk/Source/WebKit/UIProcess/Automation/ios/WebAutomationSessionIOS.mm

    r237266 r237738  
    8484            switch (virtualKey) {
    8585            case VirtualKey::Shift:
    86                 changedModifiers |= WebEventFlagMaskShift;
     86                changedModifiers |= WebEventFlagMaskShiftKey;
    8787                break;
    8888            case VirtualKey::Control:
    89                 changedModifiers |= WebEventFlagMaskControl;
     89                changedModifiers |= WebEventFlagMaskControlKey;
    9090                break;
    9191            case VirtualKey::Alternate:
    92                 changedModifiers |= WebEventFlagMaskAlternate;
     92                changedModifiers |= WebEventFlagMaskOptionKey;
    9393                break;
    9494            case VirtualKey::Meta:
     
    9696                // mapped to the Command key when using third-party keyboards.
    9797            case VirtualKey::Command:
    98                 changedModifiers |= WebEventFlagMaskCommand;
     98                changedModifiers |= WebEventFlagMaskCommandKey;
    9999                break;
    100100            default:
  • trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm

    r237658 r237738  
    37873787        return;
    37883788    }
    3789        
     3789
    37903790    // If we aren't interacting with editable content, we still need to call [super _handleKeyUIEvent:]
    37913791    // so that keyboard repeat will work correctly. If we are interacting with editable content,
     
    38163816    static const unsigned kWebDeleteForwardKey = 0xF728;
    38173817    static const unsigned kWebSpaceKey = 0x20;
     3818
     3819    if (event.keyboardFlags & WebEventKeyboardInputModifierFlagsChanged)
     3820        return NO;
    38183821
    38193822    BOOL contentEditable = _page->editorState().isContentEditable;
  • trunk/Source/WebKit/UIProcess/ios/WKKeyboardScrollingAnimator.mm

    r237266 r237738  
    217217        return std::nullopt;
    218218   
    219     BOOL shiftPressed = event.modifierFlags & WebEventFlagMaskShift;
    220     BOOL altPressed = event.modifierFlags & WebEventFlagMaskAlternate;
    221     BOOL cmdPressed = event.modifierFlags & WebEventFlagMaskCommand;
     219    BOOL shiftPressed = event.modifierFlags & WebEventFlagMaskShiftKey;
     220    BOOL altPressed = event.modifierFlags & WebEventFlagMaskOptionKey;
     221    BOOL cmdPressed = event.modifierFlags & WebEventFlagMaskCommandKey;
    222222
    223223    auto increment = ^{
  • trunk/Source/WebKitLegacy/mac/ChangeLog

    r237700 r237738  
     12018-11-02  Daniel Bates  <dabates@apple.com>
     2
     3        [iOS] WebKit should dispatch DOM events when a modifier key is pressed
     4        https://bugs.webkit.org/show_bug.cgi?id=190487
     5
     6        Reviewed by Tim Horton.
     7
     8        Having Legacy WebKit return NO if the editing event represents a modifier flags change to
     9        allow the default handling.
     10
     11        * WebView/WebHTMLView.mm:
     12        (-[WebHTMLView _handleEditingKeyEvent:]):
     13
    1142018-11-01  Sihui Liu  <sihui_liu@apple.com>
    215
  • trunk/Source/WebKitLegacy/mac/WebView/WebHTMLView.mm

    r237607 r237738  
    60686068    if (auto* platformEvent = wcEvent->underlyingPlatformEvent()) {
    60696069        WebEvent *event = platformEvent->event();
     6070        if (event.keyboardFlags & WebEventKeyboardInputModifierFlagsChanged)
     6071            return NO;
    60706072        if (![[self _webView] isEditable] && event.isTabKey)
    60716073            return NO;
  • trunk/Tools/ChangeLog

    r237735 r237738  
     12018-11-02  Daniel Bates  <dabates@apple.com>
     2
     3        [iOS] WebKit should dispatch DOM events when a modifier key is pressed
     4        https://bugs.webkit.org/show_bug.cgi?id=190487
     5
     6        Reviewed by Tim Horton.
     7
     8        Update the code for renamed enumerations. For WebKitTestRunner, removed comment that does not
     9        match my observations when using the simulator to simulate iOS 12 and add support for testing
     10        right-hand side modifiers.
     11
     12        * DumpRenderTree/mac/EventSendingController.mm:
     13        (modifierFlags):
     14        (-[EventSendingController keyDown:withModifiers:withLocation:]):
     15        (-[EventSendingController setTouchModifier:value:]):
     16        * WebKitTestRunner/ios/HIDEventGenerator.mm:
     17        (hidUsageCodeForCharacter):
     18
    1192018-11-02  Chris Dumez  <cdumez@apple.com>
    220
  • trunk/Tools/DumpRenderTree/mac/EventSendingController.mm

    r237266 r237738  
    526526    const int capsLockKeyMask = NSEventModifierFlagCapsLock;
    527527#else
    528     const int controlKeyMask = WebEventFlagMaskControl;
    529     const int shiftKeyMask = WebEventFlagMaskShift;
    530     const int alternateKeyMask = WebEventFlagMaskAlternate;
    531     const int commandKeyMask = WebEventFlagMaskCommand;
    532     const int capsLockKeyMask = WebEventFlagMaskAlphaShift;
     528    const int controlKeyMask = WebEventFlagMaskLeftControlKey;
     529    const int shiftKeyMask = WebEventFlagMaskLeftShiftKey;
     530    const int alternateKeyMask = WebEventFlagMaskLeftOptionKey;
     531    const int commandKeyMask = WebEventFlagMaskLeftCommandKey;
     532    const int capsLockKeyMask = WebEventFlagMaskLeftCapsLockKey;
    533533#endif
    534534
     
    11111111        modifierFlags |= NSEventModifierFlagShift;
    11121112#else
    1113         modifierFlags |= WebEventFlagMaskAlphaShift;
     1113        modifierFlags |= WebEventFlagMaskLeftShiftKey;
    11141114#endif
    11151115        charactersIgnoringModifiers = [character lowercaseString];
     
    14371437   
    14381438    if ([modifierName isEqualToString:@"alt"])
    1439         modifier = WebEventFlagMaskAlternate;
     1439        modifier = WebEventFlagMaskLeftOptionKey;
    14401440    else if ([modifierName isEqualToString:@"shift"])
    1441         modifier = WebEventFlagMaskShift;
     1441        modifier = WebEventFlagMaskLeftShiftKey;
    14421442    else if ([modifierName isEqualToString:@"meta"])
    1443         modifier = WebEventFlagMaskCommand;
     1443        modifier = WebEventFlagMaskLeftCommandKey;
    14441444    else if ([modifierName isEqualToString:@"ctrl"])
    1445         modifier = WebEventFlagMaskControl;
     1445        modifier = WebEventFlagMaskLeftControlKey;
    14461446
    14471447    if (!modifier)
  • trunk/Tools/WebKitTestRunner/ios/HIDEventGenerator.mm

    r236678 r237738  
    961961    if ([key isEqualToString:@"clear"]) // Num Lock / Clear
    962962        return kHIDUsage_KeypadNumLock;
    963     // The simulator keyboard interprets both left and right modifier keys using the left version of the usage code.
    964     if ([key isEqualToString:@"leftControl"] || [key isEqualToString:@"rightControl"])
     963    if ([key isEqualToString:@"leftControl"])
    965964        return kHIDUsage_KeyboardLeftControl;
    966     if ([key isEqualToString:@"leftShift"] || [key isEqualToString:@"rightShift"])
     965    if ([key isEqualToString:@"rightControl"])
     966        return kHIDUsage_KeyboardRightControl;
     967    if ([key isEqualToString:@"leftShift"])
    967968        return kHIDUsage_KeyboardLeftShift;
    968     if ([key isEqualToString:@"leftAlt"] || [key isEqualToString:@"rightAlt"])
     969    if ([key isEqualToString:@"rightShift"])
     970        return kHIDUsage_KeyboardRightShift;
     971    if ([key isEqualToString:@"leftAlt"])
    969972        return kHIDUsage_KeyboardLeftAlt;
     973    if ([key isEqualToString:@"rightAlt"])
     974        return kHIDUsage_KeyboardRightAlt;
    970975
    971976    return 0;
Note: See TracChangeset for help on using the changeset viewer.