⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 249514 in webkit


Ignore:
Timestamp:
Sep 4, 2019, 7:36:28 PM (7 years ago)
Author:
Wenson Hsieh
Message:

MobileSafari may crash when invoking the C++ lambda in -[WKContentView _shareForWebView:]
https://bugs.webkit.org/show_bug.cgi?id=201479
<rdar://problem/51511834>

Reviewed by Tim Horton.

Source/WebKit:

Fix the crash by making -_shareForWebView: robust in the case where there are no selection rects
known in the UI process when -[WKContentView _share:] is invoked.

  • UIProcess/ios/WKContentViewInteraction.mm:

(-[WKContentView _shareForWebView:]):

Tools:

Add a test to verify that the UI process doesn't crash when invoking _share: while there's no selection.

  • TestWebKitAPI/Tests/WebKitCocoa/WKContentViewEditingActions.mm:
  • TestWebKitAPI/ios/UIKitSPI.h:
Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r249512 r249514  
     12019-09-04  Wenson Hsieh  <wenson_hsieh@apple.com>
     2
     3        MobileSafari may crash when invoking the C++ lambda in -[WKContentView _shareForWebView:]
     4        https://bugs.webkit.org/show_bug.cgi?id=201479
     5        <rdar://problem/51511834>
     6
     7        Reviewed by Tim Horton.
     8
     9        Fix the crash by making -_shareForWebView: robust in the case where there are no selection rects
     10        known in the UI process when -[WKContentView _share:] is invoked.
     11
     12        * UIProcess/ios/WKContentViewInteraction.mm:
     13        (-[WKContentView _shareForWebView:]):
     14
    1152019-09-04  Ryosuke Niwa  <rniwa@webkit.org>
    216
  • trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm

    r249431 r249514  
    28012801        if (error != WebKit::CallbackBase::Error::None)
    28022802            return;
    2803         if (!string)
     2803
     2804        if (!view->_textSelectionAssistant || !string || view->_page->editorState().isMissingPostLayoutData)
    28042805            return;
    28052806
    2806         CGRect presentationRect = view->_page->editorState().postLayoutData().selectionRects[0].rect();
    2807 
    2808         if (view->_textSelectionAssistant)
    2809             [view->_textSelectionAssistant showShareSheetFor:string fromRect:presentationRect];
     2807        auto& selectionRects = view->_page->editorState().postLayoutData().selectionRects;
     2808        if (selectionRects.isEmpty())
     2809            return;
     2810
     2811        [view->_textSelectionAssistant showShareSheetFor:string fromRect:selectionRects.first().rect()];
    28102812    });
    28112813}
  • trunk/Tools/ChangeLog

    r249508 r249514  
     12019-09-04  Wenson Hsieh  <wenson_hsieh@apple.com>
     2
     3        MobileSafari may crash when invoking the C++ lambda in -[WKContentView _shareForWebView:]
     4        https://bugs.webkit.org/show_bug.cgi?id=201479
     5        <rdar://problem/51511834>
     6
     7        Reviewed by Tim Horton.
     8
     9        Add a test to verify that the UI process doesn't crash when invoking `_share:` while there's no selection.
     10
     11        * TestWebKitAPI/Tests/WebKitCocoa/WKContentViewEditingActions.mm:
     12        * TestWebKitAPI/ios/UIKitSPI.h:
     13
    1142019-09-04  Wenson Hsieh  <wenson_hsieh@apple.com>
    215
  • trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/WKContentViewEditingActions.mm

    r243354 r249514  
    3232#import "TestNavigationDelegate.h"
    3333#import "TestWKWebView.h"
     34#import "UIKitSPI.h"
    3435#import <WebKit/WebKit.h>
    3536#import <wtf/RetainPtr.h>
     
    6364}
    6465
     66TEST(WebKit, InvokeShareWithoutSelection)
     67{
     68    auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:CGRectMake(0, 0, 320, 568)]);
     69    [webView synchronouslyLoadTestPageNamed:@"simple"];
     70    [[webView textInputContentView] _share:nil];
     71    [webView waitForNextPresentationUpdate];
     72}
     73
    6574#endif
  • trunk/Tools/TestWebKitAPI/ios/UIKitSPI.h

    r249508 r249514  
    256256@end
    257257
     258@interface UIResponder (Internal)
     259- (void)_share:(id)sender;
     260@end
     261
    258262#endif // PLATFORM(IOS_FAMILY)
Note: See TracChangeset for help on using the changeset viewer.