Bug 176077

Summary: [iOS] REGRESSION (r218144) -[WKContentView targetForAction:withSender:] returns the content view for actions implemented only by the WKWebView, causing a crash
Product: WebKit Reporter: mitz
Component: WebKit2Assignee: mitz
Status: RESOLVED FIXED    
Severity: Normal CC: buildbot, commit-queue, sam, thorton, wenson_hsieh
Priority: P1 Keywords: InRadar, Regression
Version: Other   
Hardware: Unspecified   
OS: Unspecified   
See Also: https://bugs.webkit.org/show_bug.cgi?id=173277
Attachments:
Description Flags
Forward -targetForAction:withSender: from the content view to the web view
none
Forward -targetForAction:withSender: from the content view to the web view none

Description mitz 2017-08-29 15:51:52 PDT
<https://trac.webkit.org/r218144> made -[WKContentView canPerformAction:withSender:] return YES for actions implemented by the WKWebView, but didn’t take care to override -targetForAction:withSender: to return the WKWebView as well. Without an override, the base implementation returns the WKContentView itself, which then gets sent an unrecognized selector.
Comment 1 mitz 2017-08-29 15:54:14 PDT
<rdar://problem/34145200>
Comment 2 mitz 2017-08-30 12:42:34 PDT
Created attachment 319387 [details]
Forward -targetForAction:withSender: from the content view to the web view
Comment 3 Build Bot 2017-08-30 12:44:33 PDT
Attachment 319387 [details] did not pass style-queue:


ERROR: Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm:1258:  preprocessor directives (e.g., #ifdef, #define, #import) should never be indented.  [whitespace/indent] [4]
ERROR: Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm:1264:  preprocessor directives (e.g., #ifdef, #define, #import) should never be indented.  [whitespace/indent] [4]
Total errors found: 2 in 7 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 4 Wenson Hsieh 2017-08-30 12:48:03 PDT
Comment on attachment 319387 [details]
Forward -targetForAction:withSender: from the content view to the web view

View in context: https://bugs.webkit.org/attachment.cgi?id=319387&action=review

> Tools/TestWebKitAPI/Tests/WebKitCocoa/WKContentViewTargetForAction.mm:36
> +static UIView *recursiveFindWKContentView(UIView *view)

Hm...I wonder if this functionality should be in a testing category on WKWebView in TestWKWebView.h instead -- I imagine it could be useful for other tests as well, not just this test (at a brief glance, WKContentViewEditingActions.mm also needs the same functionality).

> Tools/TestWebKitAPI/Tests/WebKitCocoa/WKContentViewTargetForAction.mm:63
> +    RetainPtr<TestWKContentViewTargetForActionView> webView = adoptNS([[TestWKContentViewTargetForActionView alloc] init]);

Nit - I would prefer auto here.
Comment 5 mitz 2017-08-30 13:50:10 PDT
Created attachment 319393 [details]
Forward -targetForAction:withSender: from the content view to the web view
Comment 6 Build Bot 2017-08-30 13:52:30 PDT
Attachment 319393 [details] did not pass style-queue:


ERROR: Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm:1258:  preprocessor directives (e.g., #ifdef, #define, #import) should never be indented.  [whitespace/indent] [4]
ERROR: Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm:1264:  preprocessor directives (e.g., #ifdef, #define, #import) should never be indented.  [whitespace/indent] [4]
Total errors found: 2 in 7 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 7 WebKit Commit Bot 2017-08-30 21:07:38 PDT
Comment on attachment 319393 [details]
Forward -targetForAction:withSender: from the content view to the web view

Clearing flags on attachment: 319393

Committed r221415: <http://trac.webkit.org/changeset/221415>
Comment 8 WebKit Commit Bot 2017-08-30 21:07:39 PDT
All reviewed patches have been landed.  Closing bug.