Changeset 246626 in webkit


Ignore:
Timestamp:
Jun 19, 2019 7:17:53 PM (5 years ago)
Author:
dino@apple.com
Message:

No menu pop-up when long pressing on a link in Firefox app
https://bugs.webkit.org/show_bug.cgi?id=199045
<rdar://problem/51422407>

Reviewed by Tim Horton.

Add a version check for linking on-or-after iOS 13. When
that isn't true, we don't use UIContextMenuInteraction
and instead fall back on the legacy UIPreviewItem API.

  • UIProcess/Cocoa/VersionChecks.h: Add FirstThatHasUIContextMenuInteraction.
  • UIProcess/ios/WKContentViewInteraction.h:
  • UIProcess/ios/WKContentViewInteraction.mm:

(-[WKContentView _shouldUseContextMenus]): New method to decide if we should
use context menus or preview items.
(-[WKContentView setupInteraction]): Make the decision at runtime rather than
compile time.
(-[WKContentView _contentsOfUserInterfaceItem:]): Ditto.
(-[WKContentView _registerPreview]): Ditto.
(-[WKContentView _unregisterPreview]): Ditto.

Location:
trunk/Source
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WTF/wtf/spi/darwin/dyldSPI.h

    r234778 r246626  
    4242#endif
    4343
     44#ifndef DYLD_IOS_VERSION_13_0
     45#define DYLD_IOS_VERSION_13_0 0x000D0000
     46#endif
     47
    4448#ifndef DYLD_MACOSX_VERSION_10_13
    4549#define DYLD_MACOSX_VERSION_10_13 0x000A0D00
     
    6266#define DYLD_IOS_VERSION_11_3 0x000B0300
    6367#define DYLD_IOS_VERSION_12_0 0x000C0000
     68#define DYLD_IOS_VERSION_13_0 0x000D0000
    6469
    6570#define DYLD_MACOSX_VERSION_10_11 0x000A0B00
  • trunk/Source/WebKit/ChangeLog

    r246622 r246626  
     12019-06-19  Dean Jackson  <dino@apple.com>
     2
     3        No menu pop-up when long pressing on a link in Firefox app
     4        https://bugs.webkit.org/show_bug.cgi?id=199045
     5        <rdar://problem/51422407>
     6
     7        Reviewed by Tim Horton.
     8
     9        Add a version check for linking on-or-after iOS 13. When
     10        that isn't true, we don't use UIContextMenuInteraction
     11        and instead fall back on the legacy UIPreviewItem API.
     12
     13        * UIProcess/Cocoa/VersionChecks.h: Add FirstThatHasUIContextMenuInteraction.
     14        * UIProcess/ios/WKContentViewInteraction.h:
     15        * UIProcess/ios/WKContentViewInteraction.mm:
     16        (-[WKContentView _shouldUseContextMenus]): New method to decide if we should
     17        use context menus or preview items.
     18        (-[WKContentView setupInteraction]): Make the decision at runtime rather than
     19        compile time.
     20        (-[WKContentView _contentsOfUserInterfaceItem:]): Ditto.
     21        (-[WKContentView _registerPreview]): Ditto.
     22        (-[WKContentView _unregisterPreview]): Ditto.
     23
    1242019-06-19  Andy Estes  <aestes@apple.com>
    225
  • trunk/Source/WebKit/UIProcess/Cocoa/VersionChecks.h

    r244512 r246626  
    7373    FirstWithExceptionsForRelatedWebViewsUsingDifferentDataStores = DYLD_IOS_VERSION_FIRST_WITH_EXCEPTIONS_FOR_RELATED_WEBVIEWS_USING_DIFFERENT_DATA_STORES,
    7474    FirstWithModernCompabilityModeByDefault = DYLD_IOS_VERSION_FIRST_WITH_MODERN_COMPATIBILITY_MODE_BY_DEFAULT,
     75    FirstThatHasUIContextMenuInteraction = DYLD_IOS_VERSION_13_0,
    7576#elif PLATFORM(MAC)
    7677    FirstWithNetworkCache = DYLD_MACOSX_VERSION_10_11,
  • trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.h

    r246622 r246626  
    252252    BOOL _contextMenuHasRequestedLegacyData;
    253253    RetainPtr<UITargetedPreview> _contextMenuInteractionTargetedPreview;
    254 #else
     254#endif
    255255    RetainPtr<UIPreviewItemController> _previewItemController;
    256 #endif
    257256#endif
    258257
     
    538537#if HAVE(LINK_PREVIEW)
    539538#if USE(UICONTEXTMENU)
    540 @interface WKContentView (WKInteractionPreview) <UIContextMenuInteractionDelegate>
     539@interface WKContentView (WKInteractionPreview) <UIContextMenuInteractionDelegate, UIPreviewItemDelegate>
    541540#else
    542541@interface WKContentView (WKInteractionPreview) <UIPreviewItemDelegate>
    543542#endif
     543- (bool)_shouldUseContextMenus;
    544544- (void)_registerPreview;
    545545- (void)_unregisterPreview;
  • trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm

    r246622 r246626  
    4343#import "TextInputSPI.h"
    4444#import "UIKitSPI.h"
     45#import "VersionChecks.h"
    4546#import "WKActionSheetAssistant.h"
    4647#import "WKContextMenuElementInfoInternal.h"
     
    769770    [_highlightLongPressGestureRecognizer setDelegate:self];
    770771
    771 #if HAVE(LINK_PREVIEW) && !USE(UICONTEXTMENU)
    772     [self addGestureRecognizer:_highlightLongPressGestureRecognizer.get()];
    773     [self _createAndConfigureLongPressGestureRecognizer];
     772#if HAVE(LINK_PREVIEW)
     773    if (![self _shouldUseContextMenus]) {
     774        [self addGestureRecognizer:_highlightLongPressGestureRecognizer.get()];
     775        [self _createAndConfigureLongPressGestureRecognizer];
     776    }
    774777#endif
    775778
     
    73687371#if HAVE(LINK_PREVIEW)
    73697372    if ([userInterfaceItem isEqualToString:@"linkPreviewPopoverContents"]) {
    7370 #if USE(UICONTEXTMENU)
    7371         return @{ userInterfaceItem: @{ @"pageURL": WTF::userVisibleString(_positionInformation.url) } };
    7372 #else
     7373        if ([self _shouldUseContextMenus])
     7374            return @{ userInterfaceItem: @{ @"pageURL": WTF::userVisibleString(_positionInformation.url) } };
     7375
    73737376        NSString *url = [_previewItemController previewData][UIPreviewDataLink];
    73747377        return @{ userInterfaceItem: @{ @"pageURL": url } };
    7375 #endif
    73767378    }
    73777379#endif
     
    74127414}
    74137415
     7416@implementation WKContentView (WKInteractionPreview)
     7417
     7418- (bool)_shouldUseContextMenus
     7419{
    74147420#if USE(UICONTEXTMENU)
    7415 
    7416 @implementation WKContentView (WKInteractionPreview)
     7421    return linkedOnOrAfter(WebKit::SDKVersion::FirstThatHasUIContextMenuInteraction);
     7422#endif
     7423    return false;
     7424}
    74177425
    74187426- (void)_registerPreview
     
    74217429        return;
    74227430
    7423     _contextMenuInteraction = adoptNS([[UIContextMenuInteraction alloc] initWithDelegate:self]);
    7424     _contextMenuHasRequestedLegacyData = NO;
    7425     [self addInteraction:_contextMenuInteraction.get()];
    7426 
    7427     [self _showLinkPreviewsPreferenceChanged:nil];
    7428 
    7429     [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_showLinkPreviewsPreferenceChanged:) name:webkitShowLinkPreviewsPreferenceChangedNotification object:nil];
     7431#if USE(UICONTEXTMENU)
     7432    if ([self _shouldUseContextMenus]) {
     7433        _contextMenuInteraction = adoptNS([[UIContextMenuInteraction alloc] initWithDelegate:self]);
     7434        _contextMenuHasRequestedLegacyData = NO;
     7435        [self addInteraction:_contextMenuInteraction.get()];
     7436
     7437        [self _showLinkPreviewsPreferenceChanged:nil];
     7438
     7439        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_showLinkPreviewsPreferenceChanged:) name:webkitShowLinkPreviewsPreferenceChangedNotification object:nil];
     7440
     7441        return;
     7442    }
     7443#endif
     7444
     7445    if (!_webView.allowsLinkPreview)
     7446        return;
     7447
     7448    _previewItemController = adoptNS([[UIPreviewItemController alloc] initWithView:self]);
     7449    [_previewItemController setDelegate:self];
     7450    _previewGestureRecognizer = _previewItemController.get().presentationGestureRecognizer;
     7451    if ([_previewItemController respondsToSelector:@selector(presentationSecondaryGestureRecognizer)])
     7452        _previewSecondaryGestureRecognizer = _previewItemController.get().presentationSecondaryGestureRecognizer;
    74307453}
    74317454
    74327455- (void)_unregisterPreview
    74337456{
    7434     if (!_contextMenuInteraction)
    7435         return;
    7436 
    7437     [self removeInteraction:_contextMenuInteraction.get()];
    7438     _contextMenuInteraction = nil;
    7439 
    7440     [[NSNotificationCenter defaultCenter] removeObserver:self name:webkitShowLinkPreviewsPreferenceChangedNotification object:nil];
    7441 }
     7457#if USE(UICONTEXTMENU)
     7458    if ([self _shouldUseContextMenus]) {
     7459        if (!_contextMenuInteraction)
     7460            return;
     7461
     7462        [self removeInteraction:_contextMenuInteraction.get()];
     7463        _contextMenuInteraction = nil;
     7464
     7465        [[NSNotificationCenter defaultCenter] removeObserver:self name:webkitShowLinkPreviewsPreferenceChangedNotification object:nil];
     7466        return;
     7467    }
     7468#endif
     7469
     7470    [_previewItemController setDelegate:nil];
     7471    _previewGestureRecognizer = nil;
     7472    _previewSecondaryGestureRecognizer = nil;
     7473    _previewItemController = nil;
     7474}
     7475
     7476#if USE(UICONTEXTMENU)
    74427477
    74437478- (void)_showLinkPreviewsPreferenceChanged:(NSNotification *)notification
     
    80058040}
    80068041
    8007 @end
    8008 
    8009 #else
    8010 
    8011 @implementation WKContentView (WKInteractionPreview)
    8012 
    8013 - (void)_registerPreview
    8014 {
    8015     if (!_webView.allowsLinkPreview)
    8016         return;
    8017 
    8018     _previewItemController = adoptNS([[UIPreviewItemController alloc] initWithView:self]);
    8019     [_previewItemController setDelegate:self];
    8020     _previewGestureRecognizer = _previewItemController.get().presentationGestureRecognizer;
    8021     if ([_previewItemController respondsToSelector:@selector(presentationSecondaryGestureRecognizer)])
    8022         _previewSecondaryGestureRecognizer = _previewItemController.get().presentationSecondaryGestureRecognizer;
    8023 }
    8024 
    8025 - (void)_unregisterPreview
    8026 {
    8027     [_previewItemController setDelegate:nil];
    8028     _previewGestureRecognizer = nil;
    8029     _previewSecondaryGestureRecognizer = nil;
    8030     _previewItemController = nil;
    8031 }
     8042#endif // USE(UICONTEXTMENU)
    80328043
    80338044- (BOOL)_interactionShouldBeginFromPreviewItemController:(UIPreviewItemController *)controller forPosition:(CGPoint)position
     
    83558366@end
    83568367
    8357 #endif // USE(UICONTEXTMENU)
    8358 
    83598368#endif // HAVE(LINK_PREVIEW)
    83608369
Note: See TracChangeset for help on using the changeset viewer.