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

Changeset 249693 in webkit


Ignore:
Timestamp:
Sep 9, 2019, 8:19:42 PM (7 years ago)
Author:
Alan Coon
Message:

Cherry-pick r249514. rdar://problem/55182886

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:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@249514 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Location:
branches/safari-608-branch
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • branches/safari-608-branch/Source/WebKit/ChangeLog

    r249691 r249693  
     12019-09-09  Kocsen Chung  <kocsen_chung@apple.com>
     2
     3        Cherry-pick r249514. rdar://problem/55182886
     4
     5    MobileSafari may crash when invoking the C++ lambda in -[WKContentView _shareForWebView:]
     6    https://bugs.webkit.org/show_bug.cgi?id=201479
     7    <rdar://problem/51511834>
     8   
     9    Reviewed by Tim Horton.
     10   
     11    Source/WebKit:
     12   
     13    Fix the crash by making -_shareForWebView: robust in the case where there are no selection rects
     14    known in the UI process when -[WKContentView _share:] is invoked.
     15   
     16    * UIProcess/ios/WKContentViewInteraction.mm:
     17    (-[WKContentView _shareForWebView:]):
     18   
     19    Tools:
     20   
     21    Add a test to verify that the UI process doesn't crash when invoking `_share:` while there's no selection.
     22   
     23    * TestWebKitAPI/Tests/WebKitCocoa/WKContentViewEditingActions.mm:
     24    * TestWebKitAPI/ios/UIKitSPI.h:
     25   
     26   
     27    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@249514 268f45cc-cd09-0410-ab3c-d52691b4dbfc
     28
     29    2019-09-04  Wenson Hsieh  <wenson_hsieh@apple.com>
     30
     31            MobileSafari may crash when invoking the C++ lambda in -[WKContentView _shareForWebView:]
     32            https://bugs.webkit.org/show_bug.cgi?id=201479
     33            <rdar://problem/51511834>
     34
     35            Reviewed by Tim Horton.
     36
     37            Fix the crash by making -_shareForWebView: robust in the case where there are no selection rects
     38            known in the UI process when -[WKContentView _share:] is invoked.
     39
     40            * UIProcess/ios/WKContentViewInteraction.mm:
     41            (-[WKContentView _shareForWebView:]):
     42
    1432019-09-09  Kocsen Chung  <kocsen_chung@apple.com>
    244
  • branches/safari-608-branch/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm

    r249550 r249693  
    28062806        if (error != WebKit::CallbackBase::Error::None)
    28072807            return;
    2808         if (!string)
     2808
     2809        if (!view->_textSelectionAssistant || !string || view->_page->editorState().isMissingPostLayoutData)
    28092810            return;
    28102811
    2811         CGRect presentationRect = view->_page->editorState().postLayoutData().selectionRects[0].rect();
    2812 
    2813         if (view->_textSelectionAssistant)
    2814             [view->_textSelectionAssistant showShareSheetFor:string fromRect:presentationRect];
     2812        auto& selectionRects = view->_page->editorState().postLayoutData().selectionRects;
     2813        if (selectionRects.isEmpty())
     2814            return;
     2815
     2816        [view->_textSelectionAssistant showShareSheetFor:string fromRect:selectionRects.first().rect()];
    28152817    });
    28162818}
  • branches/safari-608-branch/Tools/ChangeLog

    r249550 r249693  
     12019-09-09  Kocsen Chung  <kocsen_chung@apple.com>
     2
     3        Cherry-pick r249514. rdar://problem/55182886
     4
     5    MobileSafari may crash when invoking the C++ lambda in -[WKContentView _shareForWebView:]
     6    https://bugs.webkit.org/show_bug.cgi?id=201479
     7    <rdar://problem/51511834>
     8   
     9    Reviewed by Tim Horton.
     10   
     11    Source/WebKit:
     12   
     13    Fix the crash by making -_shareForWebView: robust in the case where there are no selection rects
     14    known in the UI process when -[WKContentView _share:] is invoked.
     15   
     16    * UIProcess/ios/WKContentViewInteraction.mm:
     17    (-[WKContentView _shareForWebView:]):
     18   
     19    Tools:
     20   
     21    Add a test to verify that the UI process doesn't crash when invoking `_share:` while there's no selection.
     22   
     23    * TestWebKitAPI/Tests/WebKitCocoa/WKContentViewEditingActions.mm:
     24    * TestWebKitAPI/ios/UIKitSPI.h:
     25   
     26   
     27    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@249514 268f45cc-cd09-0410-ab3c-d52691b4dbfc
     28
     29    2019-09-04  Wenson Hsieh  <wenson_hsieh@apple.com>
     30
     31            MobileSafari may crash when invoking the C++ lambda in -[WKContentView _shareForWebView:]
     32            https://bugs.webkit.org/show_bug.cgi?id=201479
     33            <rdar://problem/51511834>
     34
     35            Reviewed by Tim Horton.
     36
     37            Add a test to verify that the UI process doesn't crash when invoking `_share:` while there's no selection.
     38
     39            * TestWebKitAPI/Tests/WebKitCocoa/WKContentViewEditingActions.mm:
     40            * TestWebKitAPI/ios/UIKitSPI.h:
     41
    1422019-09-05  Kocsen Chung  <kocsen_chung@apple.com>
    243
  • branches/safari-608-branch/Tools/TestWebKitAPI/Tests/WebKitCocoa/WKContentViewEditingActions.mm

    r243354 r249693  
    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
  • branches/safari-608-branch/Tools/TestWebKitAPI/ios/UIKitSPI.h

    r248620 r249693  
    250250@end
    251251
     252@interface UIResponder (Internal)
     253- (void)_share:(id)sender;
     254@end
     255
    252256#endif // PLATFORM(IOS_FAMILY)
Note: See TracChangeset for help on using the changeset viewer.