Changeset 247342 in webkit


Ignore:
Timestamp:
Jul 10, 2019 9:09:52 PM (5 years ago)
Author:
timothy_horton@apple.com
Message:

Long pressing on attachments will crash the WebContent process
https://bugs.webkit.org/show_bug.cgi?id=199696
<rdar://problem/52920241>

Reviewed by Dean Jackson.

Source/WebKit:

  • WebProcess/WebPage/ios/WebPageIOS.mm:

(WebKit::linkIndicatorPositionInformation):
(WebKit::elementPositionInformation):
(WebKit::selectionPositionInformation):
(WebKit::WebPage::positionInformation):
Instead of one-off creating a node snapshot for <attachment>, just
use TextIndicator. This way, we get an estimated background color,
paint at the right resolution, etc.

Also, hitNode was often null where we were previously calling
shareableBitmapSnapshotForNode, because it depends on the element
having click event handlers. selectionPositionInformation() re-hit-tests
more permissively to find the <attachment>, so moving this code
inside that function ensures that we don't try to snapshot a null node.

Tools:

  • TestWebKitAPI/Tests/WebKitCocoa/WKRequestActivatedElementInfo.mm:

(TestWebKitAPI::TEST):
Add a test that previously crashed.

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r247340 r247342  
     12019-07-10  Tim Horton  <timothy_horton@apple.com>
     2
     3        Long pressing on attachments will crash the WebContent process
     4        https://bugs.webkit.org/show_bug.cgi?id=199696
     5        <rdar://problem/52920241>
     6
     7        Reviewed by Dean Jackson.
     8
     9        * WebProcess/WebPage/ios/WebPageIOS.mm:
     10        (WebKit::linkIndicatorPositionInformation):
     11        (WebKit::elementPositionInformation):
     12        (WebKit::selectionPositionInformation):
     13        (WebKit::WebPage::positionInformation):
     14        Instead of one-off creating a node snapshot for <attachment>, just
     15        use TextIndicator. This way, we get an estimated background color,
     16        paint at the right resolution, etc.
     17
     18        Also, hitNode was often null where we were previously calling
     19        shareableBitmapSnapshotForNode, because it depends on the element
     20        having click event handlers. selectionPositionInformation() re-hit-tests
     21        more permissively to find the <attachment>, so moving this code
     22        inside that function ensures that we don't try to snapshot a null node.
     23
    1242019-07-10  Dean Jackson  <dino@apple.com>
    225
  • trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm

    r247317 r247342  
    25242524}
    25252525
    2526 static void linkIndicatorPositionInformation(WebPage& page, Element& element, Element& linkElement, const InteractionInformationRequest& request, InteractionInformationAtPosition& info)
     2526static void linkIndicatorPositionInformation(WebPage& page, Element& linkElement, const InteractionInformationRequest& request, InteractionInformationAtPosition& info)
    25272527{
    25282528    if (!request.includeLinkIndicator)
     
    26362636        info.url = linkElement->document().completeURL(stripLeadingAndTrailingHTMLSpaces(linkElement->getAttribute(HTMLNames::hrefAttr)));
    26372637
    2638         linkIndicatorPositionInformation(page, element, *linkElement, request, info);
     2638        linkIndicatorPositionInformation(page, *linkElement, request, info);
    26392639#if ENABLE(DATA_DETECTION)
    26402640        dataDetectorLinkPositionInformation(element, info);
     
    26632663    if (is<HTMLAttachmentElement>(*hitNode)) {
    26642664        info.isAttachment = true;
    2665         const HTMLAttachmentElement& attachment = downcast<HTMLAttachmentElement>(*hitNode);
     2665        HTMLAttachmentElement& attachment = downcast<HTMLAttachmentElement>(*hitNode);
    26662666        info.title = attachment.attachmentTitle();
     2667        linkIndicatorPositionInformation(page, attachment, request, info);
    26672668        if (attachment.file())
    26682669            info.url = URL::fileURLWithFileSystemPath(downcast<HTMLAttachmentElement>(*hitNode).file()->path());
     
    27262727    }
    27272728
    2728     if (!(info.isLink || info.isImage)) {
     2729    if (!(info.isLink || info.isImage))
    27292730        selectionPositionInformation(*this, request, info);
    2730 
    2731         if (info.isAttachment && request.includeSnapshot) {
    2732             Element& element = downcast<Element>(*hitNode);
    2733             info.image = shareableBitmapSnapshotForNode(element);
    2734         }
    2735     }
    27362731
    27372732    // Prevent the callout bar from showing when tapping on the datalist button.
  • trunk/Tools/ChangeLog

    r247336 r247342  
     12019-07-10  Tim Horton  <timothy_horton@apple.com>
     2
     3        Long pressing on attachments will crash the WebContent process
     4        https://bugs.webkit.org/show_bug.cgi?id=199696
     5        <rdar://problem/52920241>
     6
     7        Reviewed by Dean Jackson.
     8
     9        * TestWebKitAPI/Tests/WebKitCocoa/WKRequestActivatedElementInfo.mm:
     10        (TestWebKitAPI::TEST):
     11        Add a test that previously crashed.
     12
    1132019-07-10  Dean Jackson  <dino@apple.com>
    214
  • trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/WKRequestActivatedElementInfo.mm

    r245872 r247342  
    3131#import "TestWKWebView.h"
    3232#import <WebKit/WKWebView.h>
     33#import <WebKit/WKWebViewConfigurationPrivate.h>
    3334#import <WebKit/_WKActivatedElementInfo.h>
    3435#import <wtf/RetainPtr.h>
     
    135136}
    136137
     138TEST(WebKit, RequestActivatedElementInfoForAttachment)
     139{
     140    auto configuration = adoptNS([[WKWebViewConfiguration alloc] init]);
     141    [configuration _setAttachmentElementEnabled:YES];
     142
     143    auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:CGRectMake(0, 0, 320, 500) configuration:configuration.get()]);
     144    [webView loadHTMLString:@"<html><head><meta name='viewport' content='initial-scale=1'></head><body style='margin: 0px;'><attachment  /></body></html>" baseURL:nil];
     145    [webView _test_waitForDidFinishNavigation];
     146
     147    __block bool finished = false;
     148    [webView _requestActivatedElementAtPosition:CGPointMake(20, 20) completionBlock:^(_WKActivatedElementInfo *elementInfo) {
     149        EXPECT_TRUE(elementInfo.type == _WKActivatedElementTypeAttachment);
     150
     151        finished = true;
     152    }];
     153
     154    TestWebKitAPI::Util::run(&finished);
     155}
     156
    137157TEST(WebKit, RequestActivatedElementInfoWithNestedSynchronousUpdates)
    138158{
Note: See TracChangeset for help on using the changeset viewer.