Bug 158323

Summary: Fix typo in -[WebDefaultUIKitDelegate deleteFromInputwithFlags:]
Product: WebKit Reporter: David Kilzer (:ddkilzer) <ddkilzer>
Component: WebKit Misc.Assignee: David Kilzer (:ddkilzer) <ddkilzer>
Status: RESOLVED FIXED    
Severity: Normal CC: aestes, benjamin, commit-queue, enrica, pgomez_81, sam, thorton
Priority: P2 Keywords: InRadar
Version: Other   
Hardware: Unspecified   
OS: Unspecified   
See Also: https://bugs.webkit.org/show_bug.cgi?id=157689
https://bugs.webkit.org/show_bug.cgi?id=141216
Attachments:
Description Flags
Patch v1 none

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];
            else
                [[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
<rdar://problem/26549165>
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.