Changeset 219287 in webkit


Ignore:
Timestamp:
Jul 10, 2017 3:04:53 AM (7 years ago)
Author:
Wenson Hsieh
Message:

[WK2] Action sheets for links fail to present in WebKit2 PDF view
https://bugs.webkit.org/show_bug.cgi?id=174307
<rdar://problem/31412128>

Reviewed by Tim Horton.

Currently, presenting an action sheet for a link always uses the WKActionSheetPresentAtClosestIndicatorRect
codepath, which requires text indicator data for the link. However, when showing an action sheet for a link via
WKPDFView, a text indicator for the link is not included, so the popover rect ends up being an empty rect at the
origin, which causes us to bail from presenting the popover.

To address this, we tweak our heuristic for determining which action sheet presentation style to use, so that we
only use the closest indicator rect for a link if the text indicator data is also present (otherwise, we fall
back to using the element rect). All other behavior is the same.

  • UIProcess/ios/WKActionSheetAssistant.mm:

(-[WKActionSheetAssistant showImageSheet]):
(presentationStyleForView):

Refactor _shouldPresentAtTouchLocationForElementRect into presentationStyleForView, a static function that
returns a WKActionSheetPresentationStyle.

(-[WKActionSheetAssistant showLinkSheet]):
(-[WKActionSheetAssistant _shouldPresentAtTouchLocationForElementRect:]): Deleted.

Location:
trunk/Source/WebKit2
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r219283 r219287  
     12017-07-10  Wenson Hsieh  <wenson_hsieh@apple.com>
     2
     3        [WK2] Action sheets for links fail to present in WebKit2 PDF view
     4        https://bugs.webkit.org/show_bug.cgi?id=174307
     5        <rdar://problem/31412128>
     6
     7        Reviewed by Tim Horton.
     8
     9        Currently, presenting an action sheet for a link always uses the WKActionSheetPresentAtClosestIndicatorRect
     10        codepath, which requires text indicator data for the link. However, when showing an action sheet for a link via
     11        WKPDFView, a text indicator for the link is not included, so the popover rect ends up being an empty rect at the
     12        origin, which causes us to bail from presenting the popover.
     13
     14        To address this, we tweak our heuristic for determining which action sheet presentation style to use, so that we
     15        only use the closest indicator rect for a link if the text indicator data is also present (otherwise, we fall
     16        back to using the element rect). All other behavior is the same.
     17
     18        * UIProcess/ios/WKActionSheetAssistant.mm:
     19        (-[WKActionSheetAssistant showImageSheet]):
     20        (presentationStyleForView):
     21
     22        Refactor _shouldPresentAtTouchLocationForElementRect into presentationStyleForView, a static function that
     23        returns a WKActionSheetPresentationStyle.
     24
     25        (-[WKActionSheetAssistant showLinkSheet]):
     26        (-[WKActionSheetAssistant _shouldPresentAtTouchLocationForElementRect:]): Deleted.
     27
    1282017-07-09  Brady Eidson  <beidson@apple.com>
    229
  • trunk/Source/WebKit2/UIProcess/ios/WKActionSheetAssistant.mm

    r219191 r219287  
    372372        _elementInfo = WTFMove(elementInfo);
    373373
    374         if (![_interactionSheet presentSheet:[self _shouldPresentAtTouchLocationForElementRect:elementBounds] ? WKActionSheetPresentAtTouchLocation : WKActionSheetPresentAtElementRect])
     374        if (![_interactionSheet presentSheet:presentationStyleForView(_view.getAutoreleased(), _positionInformation.value(), _elementInfo.get())])
    375375            [self cleanupSheet];
    376376    };
     
    394394}
    395395
    396 - (BOOL)_shouldPresentAtTouchLocationForElementRect:(CGRect)elementRect
    397 {
    398     UIView *view = _view.getAutoreleased();
    399     auto apparentElementRect = [view convertRect:elementRect toView:view.window];
     396static WKActionSheetPresentationStyle presentationStyleForView(UIView *view, const InteractionInformationAtPosition& positionInfo, _WKActivatedElementInfo *elementInfo)
     397{
     398    auto apparentElementRect = [view convertRect:positionInfo.bounds toView:view.window];
    400399    auto windowRect = view.window.bounds;
    401400    apparentElementRect = CGRectIntersection(apparentElementRect, windowRect);
     
    409408    // Otherwise, there is not enough space to position the popover around the element, so revert to using the touch location instead.
    410409    static const CGFloat minimumAvailableWidthOrHeightRatio = 0.4;
    411     return std::max(leftInset, rightInset) <= minimumAvailableWidthOrHeightRatio * CGRectGetWidth(windowRect) && std::max(topInset, bottomInset) <= minimumAvailableWidthOrHeightRatio * CGRectGetHeight(windowRect);
     410    if (std::max(leftInset, rightInset) <= minimumAvailableWidthOrHeightRatio * CGRectGetWidth(windowRect) && std::max(topInset, bottomInset) <= minimumAvailableWidthOrHeightRatio * CGRectGetHeight(windowRect))
     411        return WKActionSheetPresentAtTouchLocation;
     412
     413    if (elementInfo.type == _WKActivatedElementTypeLink && positionInfo.linkIndicator.textRectsInBoundingRectCoordinates.size())
     414        return WKActionSheetPresentAtClosestIndicatorRect;
     415
     416    return WKActionSheetPresentAtElementRect;
    412417}
    413418
     
    531536    _elementInfo = WTFMove(elementInfo);
    532537
    533     if (![_interactionSheet presentSheet:[self _shouldPresentAtTouchLocationForElementRect:_positionInformation->bounds] ? WKActionSheetPresentAtTouchLocation : WKActionSheetPresentAtClosestIndicatorRect])
     538    if (![_interactionSheet presentSheet:presentationStyleForView(_view.getAutoreleased(), _positionInformation.value(), _elementInfo.get())])
    534539        [self cleanupSheet];
    535540}
Note: See TracChangeset for help on using the changeset viewer.