Changeset 246697 in webkit


Ignore:
Timestamp:
Jun 21, 2019 2:22:51 PM (5 years ago)
Author:
timothy_horton@apple.com
Message:

WebKit context menu highlights include extra padding
https://bugs.webkit.org/show_bug.cgi?id=199080
<rdar://problem/51140126>

Reviewed by Dean Jackson.

  • Shared/ios/InteractionInformationRequest.cpp:

(WebKit::InteractionInformationRequest::encode const):
(WebKit::InteractionInformationRequest::decode):
(WebKit::InteractionInformationRequest::isValidForRequest):
(WebKit::InteractionInformationRequest::isApproximatelyValidForRequest):

  • Shared/ios/InteractionInformationRequest.h:
  • UIProcess/ios/WKContentViewInteraction.mm:

(-[WKContentView gestureRecognizerShouldBegin:]):
(-[WKContentView positionInformationForActionSheetAssistant:]):
(-[WKContentView updatePositionInformationForActionSheetAssistant:]):
(-[WKContentView _contextMenuInteraction:configurationForMenuAtLocation:completion:]):
(-[WKContentView _interactionShouldBeginFromPreviewItemController:forPosition:]):

  • WebProcess/WebPage/ios/WebPageIOS.mm:

(WebKit::linkIndicatorPositionInformation):
Disable the margin going forward, but leave it if we're using the legacy
API, because there is no way to add margin at the platform level with
the legacy API.

In the future we should always have no margin in our indicator, and just
apply it in whatever consumes the indicator, so that there is no
disagreement between clients about the size of the margin.

Location:
trunk/Source/WebKit
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r246694 r246697  
     12019-06-21  Tim Horton  <timothy_horton@apple.com>
     2
     3        WebKit context menu highlights include extra padding
     4        https://bugs.webkit.org/show_bug.cgi?id=199080
     5        <rdar://problem/51140126>
     6
     7        Reviewed by Dean Jackson.
     8
     9        * Shared/ios/InteractionInformationRequest.cpp:
     10        (WebKit::InteractionInformationRequest::encode const):
     11        (WebKit::InteractionInformationRequest::decode):
     12        (WebKit::InteractionInformationRequest::isValidForRequest):
     13        (WebKit::InteractionInformationRequest::isApproximatelyValidForRequest):
     14        * Shared/ios/InteractionInformationRequest.h:
     15        * UIProcess/ios/WKContentViewInteraction.mm:
     16        (-[WKContentView gestureRecognizerShouldBegin:]):
     17        (-[WKContentView positionInformationForActionSheetAssistant:]):
     18        (-[WKContentView updatePositionInformationForActionSheetAssistant:]):
     19        (-[WKContentView _contextMenuInteraction:configurationForMenuAtLocation:completion:]):
     20        (-[WKContentView _interactionShouldBeginFromPreviewItemController:forPosition:]):
     21        * WebProcess/WebPage/ios/WebPageIOS.mm:
     22        (WebKit::linkIndicatorPositionInformation):
     23        Disable the margin going forward, but leave it if we're using the legacy
     24        API, because there is no way to add margin at the platform level with
     25        the legacy API.
     26
     27        In the future we should always have no margin in our indicator, and just
     28        apply it in whatever consumes the indicator, so that there is no
     29        disagreement between clients about the size of the margin.
     30
    1312019-06-21  Youenn Fablet  <youenn@apple.com>
    232
  • trunk/Source/WebKit/Shared/ios/InteractionInformationRequest.cpp

    r242968 r246697  
    3939    encoder << includeSnapshot;
    4040    encoder << includeLinkIndicator;
     41    encoder << linkIndicatorShouldHaveLegacyMargins;
    4142    encoder << readonly;
    4243}
     
    5152
    5253    if (!decoder.decode(result.includeLinkIndicator))
     54        return false;
     55
     56    if (!decoder.decode(result.linkIndicatorShouldHaveLegacyMargins))
    5357        return false;
    5458
     
    7074        return false;
    7175
     76    if (other.linkIndicatorShouldHaveLegacyMargins != linkIndicatorShouldHaveLegacyMargins)
     77        return false;
     78
    7279    if (!other.readonly && readonly)
    7380        return false;
     
    8693    if (!other.readonly && readonly)
    8794        return false;
     95
     96    if (other.linkIndicatorShouldHaveLegacyMargins != linkIndicatorShouldHaveLegacyMargins)
     97        return false;
    8898   
    8999    return (other.point - point).diagonalLengthSquared() <= 4;
  • trunk/Source/WebKit/Shared/ios/InteractionInformationRequest.h

    r242968 r246697  
    4343    bool includeLinkIndicator { false };
    4444
     45    bool linkIndicatorShouldHaveLegacyMargins { false };
     46
    4547    // FIXME: This readonly flag ought to be true by default, but there are a number of interactions (e.g. selection) that currently
    4648    // rely on the fact that interaction information requests additionally change the focused frame. We should explicitly turn the
  • trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.h

    r246693 r246697  
    525525- (void)_didStartProvisionalLoadForMainFrame;
    526526
     527@property (nonatomic, readonly, getter=_shouldUseContextMenus) BOOL _shouldUseContextMenus;
     528
    527529@end
    528530
     
    549551@interface WKContentView (WKInteractionPreview) <UIPreviewItemDelegate>
    550552#endif
    551 - (bool)_shouldUseContextMenus;
    552553- (void)_registerPreview;
    553554- (void)_unregisterPreview;
  • trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm

    r246693 r246697  
    771771
    772772#if HAVE(LINK_PREVIEW)
    773     if (![self _shouldUseContextMenus]) {
     773    if (!self._shouldUseContextMenus) {
    774774        [self addGestureRecognizer:_highlightLongPressGestureRecognizer.get()];
    775775        [self _createAndConfigureLongPressGestureRecognizer];
     
    20672067            request.includeSnapshot = true;
    20682068            request.includeLinkIndicator = true;
     2069            request.linkIndicatorShouldHaveLegacyMargins = !self._shouldUseContextMenus;
    20692070        }
    20702071
     
    60756076    request.includeSnapshot = true;
    60766077    request.includeLinkIndicator = assistant.needsLinkIndicator;
     6078    request.linkIndicatorShouldHaveLegacyMargins = !self._shouldUseContextMenus;
    60776079    if (![self ensurePositionInformationIsUpToDate:request])
    60786080        return WTF::nullopt;
     
    60876089    request.includeSnapshot = true;
    60886090    request.includeLinkIndicator = assistant.needsLinkIndicator;
     6091    request.linkIndicatorShouldHaveLegacyMargins = !self._shouldUseContextMenus;
    60896092
    60906093    [self requestAsynchronousPositionInformationUpdate:request];
     
    62036206    } else
    62046207        completion(nil, nil);
     6208}
     6209
     6210- (BOOL)_shouldUseContextMenus
     6211{
     6212#if HAVE(LINK_PREVIEW) && USE(UICONTEXTMENU)
     6213    return linkedOnOrAfter(WebKit::SDKVersion::FirstThatHasUIContextMenuInteraction);
     6214#endif
     6215    return NO;
    62056216}
    62066217
     
    73837394#if HAVE(LINK_PREVIEW)
    73847395    if ([userInterfaceItem isEqualToString:@"linkPreviewPopoverContents"]) {
    7385         if ([self _shouldUseContextMenus])
     7396        if (self._shouldUseContextMenus)
    73867397            return @{ userInterfaceItem: @{ @"pageURL": WTF::userVisibleString(_positionInformation.url) } };
    73877398
     
    74287439@implementation WKContentView (WKInteractionPreview)
    74297440
    7430 - (bool)_shouldUseContextMenus
    7431 {
     7441- (void)_registerPreview
     7442{
     7443    if (!_webView.allowsLinkPreview)
     7444        return;
     7445
    74327446#if USE(UICONTEXTMENU)
    7433     return linkedOnOrAfter(WebKit::SDKVersion::FirstThatHasUIContextMenuInteraction);
    7434 #endif
    7435     return false;
    7436 }
    7437 
    7438 - (void)_registerPreview
    7439 {
    7440     if (!_webView.allowsLinkPreview)
    7441         return;
    7442 
    7443 #if USE(UICONTEXTMENU)
    7444     if ([self _shouldUseContextMenus]) {
     7447    if (self._shouldUseContextMenus) {
    74457448        _contextMenuInteraction = adoptNS([[UIContextMenuInteraction alloc] initWithDelegate:self]);
    74467449        _contextMenuHasRequestedLegacyData = NO;
     
    74617464#endif
    74627465
    7463     if (!_webView.allowsLinkPreview)
    7464         return;
    7465 
    74667466    _previewItemController = adoptNS([[UIPreviewItemController alloc] initWithView:self]);
    74677467    [_previewItemController setDelegate:self];
     
    74747474{
    74757475#if USE(UICONTEXTMENU)
    7476     if ([self _shouldUseContextMenus]) {
     7476    if (self._shouldUseContextMenus) {
    74777477        if (!_contextMenuInteraction)
    74787478            return;
     
    77137713    request.includeSnapshot = true;
    77147714    request.includeLinkIndicator = true;
     7715    request.linkIndicatorShouldHaveLegacyMargins = !self._shouldUseContextMenus;
    77157716
    77167717    [self doAfterPositionInformationUpdate:[weakSelf = WeakObjCPtr<WKContentView>(self), completion = makeBlockPtr(completion)] (WebKit::InteractionInformationAtPosition) {
     
    80688069    request.includeSnapshot = true;
    80698070    request.includeLinkIndicator = true;
     8071    request.linkIndicatorShouldHaveLegacyMargins = !self._shouldUseContextMenus;
    80708072    if (![self ensurePositionInformationIsUpToDate:request])
    80718073        return NO;
  • trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm

    r246535 r246697  
    24932493    auto linkRange = rangeOfContents(linkElement);
    24942494    float deviceScaleFactor = page.corePage()->deviceScaleFactor();
    2495     const float marginInPoints = 4;
     2495    const float marginInPoints = request.linkIndicatorShouldHaveLegacyMargins ? 4 : 0;
    24962496
    24972497    auto textIndicator = TextIndicator::createWithRange(linkRange.get(),
Note: See TracChangeset for help on using the changeset viewer.