Changeset 236669 in webkit


Ignore:
Timestamp:
Oct 1, 2018 10:41:25 AM (6 years ago)
Author:
dbates@webkit.org
Message:

[iOS] Wrong key event may be sent to UIKit
https://bugs.webkit.org/show_bug.cgi?id=189992

Reviewed by Simon Fraser.

Retain a clone of a received UIEvent if it is for a hardware key event so as to ensure that we
notify the UIKit keyboard code of the correct keyboard event.

Currently the UIProcess retains the UIEvent associated with a keyboard event so as to defer
notifying the UIKit keyboard code (via -_handleKeyUIEvent) about a received keyboard event until
after the WebProcess has processed the raw key event. If this UIEvent is for a hardware keyboard
event then it is not sufficient to retain it to preserve its value because UIKit uses a singleton
UIEvent for all hardware keyboard events ;=> its value will be clobbered as each hardware keyboard
event is received. Instead we need to explicitly clone a UIEvent for a hardware key event before
retaining it.

  • Platform/spi/ios/UIKitSPI.h: Forward declare SPI.
  • UIProcess/ios/WKContentViewInteraction.mm:

(-[WKContentView handleKeyEvent:]): Clone the UIEvent if it is for a hardware key event.

Location:
trunk/Source/WebKit
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r236665 r236669  
     12018-10-01  Daniel Bates  <dabates@apple.com>
     2
     3        [iOS] Wrong key event may be sent to UIKit
     4        https://bugs.webkit.org/show_bug.cgi?id=189992
     5
     6        Reviewed by Simon Fraser.
     7
     8        Retain a clone of a received UIEvent if it is for a hardware key event so as to ensure that we
     9        notify the UIKit keyboard code of the correct keyboard event.
     10
     11        Currently the UIProcess retains the UIEvent associated with a keyboard event so as to defer
     12        notifying the UIKit keyboard code (via -_handleKeyUIEvent) about a received keyboard event until
     13        after the WebProcess has processed the raw key event. If this UIEvent is for a hardware keyboard
     14        event then it is not sufficient to retain it to preserve its value because UIKit uses a singleton
     15        UIEvent for all hardware keyboard events ;=> its value will be clobbered as each hardware keyboard
     16        event is received. Instead we need to explicitly clone a UIEvent for a hardware key event before
     17        retaining it.
     18
     19        * Platform/spi/ios/UIKitSPI.h: Forward declare SPI.
     20        * UIProcess/ios/WKContentViewInteraction.mm:
     21        (-[WKContentView handleKeyEvent:]): Clone the UIEvent if it is for a hardware key event.
     22
    1232018-10-01  Alex Christensen  <achristensen@webkit.org>
    224
  • trunk/Source/WebKit/Platform/spi/ios/UIKitSPI.h

    r236619 r236669  
    10041004
    10051005@interface UIPhysicalKeyboardEvent ()
     1006- (UIPhysicalKeyboardEvent *)_cloneEvent NS_RETURNS_RETAINED;
    10061007@property (nonatomic, readonly) CFIndex _keyCode;
    10071008@end
  • trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm

    r236619 r236669  
    37463746        return;
    37473747
     3748    uint16_t keyCode;
     3749    BOOL isHardwareKeyboardEvent = !!event._hidEvent;
     3750    if (!isHardwareKeyboardEvent)
     3751        keyCode = 0;
     3752    else {
     3753        UIPhysicalKeyboardEvent *keyEvent = (UIPhysicalKeyboardEvent *)event;
     3754        keyCode = keyEvent._keyCode;
     3755        event = [[keyEvent _cloneEvent] autorelease]; // UIKit uses a singleton for hardware keyboard events.
     3756    }
    37483757    WKWebEvent *webEvent = [[[WKWebEvent alloc] initWithKeyEventType:(event._isKeyDown) ? WebEventKeyDown : WebEventKeyUp
    37493758                                                           timeStamp:event.timestamp
     
    37533762                                                         isRepeating:(event._inputFlags & kUIKeyboardInputRepeat)
    37543763                                                           withFlags:event._inputFlags
    3755                                                              keyCode:event._hidEvent ? ((UIPhysicalKeyboardEvent *)event)._keyCode : 0
     3764                                                             keyCode:keyCode
    37563765                                                            isTabKey:[event._modifiedInput isEqualToString:@"\t"]
    37573766                                                        characterSet:WebEventCharacterSetUnicode] autorelease];
Note: See TracChangeset for help on using the changeset viewer.