Bug 158323 - Fix typo in -[WebDefaultUIKitDelegate deleteFromInputwithFlags:]
Summary: Fix typo in -[WebDefaultUIKitDelegate deleteFromInputwithFlags:]
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKit Misc. (show other bugs)
Version: Other
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: David Kilzer (:ddkilzer)
Keywords: InRadar
Depends on:
Reported: 2016-06-02 15:50 PDT by David Kilzer (:ddkilzer)
Modified: 2016-06-02 20:46 PDT (History)
7 users (show)

See Also:

Patch v1 (1.33 KB, patch)
2016-06-02 16:01 PDT, David Kilzer (:ddkilzer)
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description David Kilzer (:ddkilzer) 2016-06-02 15:50:06 PDT
In Source/WebKit/ios/DefaultDelegates/WebDefaultUIKitDelegate.m, this method is defined as:

- (void)deleteFromInputwithFlags:(NSUInteger)flags

However, in Source/WebKit/ios/WebView/WebUIKitDelegate.h, it's defined in a category (not a protocol) as:

- (void)deleteFromInputWithFlags:(NSUInteger)flags;

This causes problems in Source/WebKit/mac/WebView/WebHTMLView.mm in -_handleEditingKeyEvent: where we use -_UIKitDelegateForwarder to forward the method:

        switch ([s characterAtIndex:0]) {
        case kWebBackspaceKey:
        case kWebDeleteKey:
            [[webView _UIKitDelegateForwarder] deleteFromInputWithFlags:event.keyboardFlags];
            return YES;

This was recently changed for Bug 157689 in r200979 from this:

        switch ([s characterAtIndex:0]) {
        case kWebBackspaceKey:
        case kWebDeleteKey:
            // FIXME: remove the call to deleteFromInput when UIKit implements deleteFromInputWithFlags.
            if ([webView respondsToSelector:@selector(deleteFromInputWithFlags:)])
                [[webView _UIKitDelegateForwarder] deleteFromInputWithFlags:event.keyboardFlags];
                [[webView _UIKitDelegateForwarder] deleteFromInput];
            return YES;

Finally, since the _UIKitDelegateForwarded always uses the WebDefaultUIKitDelegate to check whether the method exists, -[_WebSafeForwarder methodSignatureForSelector:] in Source/WebKit/mac/WebView/WebView.mm would return NO, which results in the NSException being thrown, leading to the crash:

- (NSMethodSignature *)methodSignatureForSelector:(SEL)aSelector
    return [defaultTarget methodSignatureForSelector:aSelector];

The fix is trivial--fix the typo in WebDefaultUIKitDelegate.m.
Comment 1 David Kilzer (:ddkilzer) 2016-06-02 15:50:44 PDT
Comment 2 David Kilzer (:ddkilzer) 2016-06-02 16:01:53 PDT
Created attachment 280378 [details]
Patch v1
Comment 3 WebKit Commit Bot 2016-06-02 18:32:58 PDT
Comment on attachment 280378 [details]
Patch v1

Clearing flags on attachment: 280378

Committed r201631: <http://trac.webkit.org/changeset/201631>
Comment 4 WebKit Commit Bot 2016-06-02 18:33:02 PDT
All reviewed patches have been landed.  Closing bug.