Changeset 246907 in webkit


Ignore:
Timestamp:
Jun 27, 2019 3:03:29 PM (5 years ago)
Author:
aestes@apple.com
Message:

[iOS] Stop using cached UITargetedPreviews from previous interactions when starting a new context menu interaction
https://bugs.webkit.org/show_bug.cgi?id=199285
<rdar://problem/52074916>

Reviewed by Tim Horton.

WKContentView was caching the UITargetedPreview created in
-contextMenuInteraction:previewForHighlightingMenuWithConfiguration: for later reuse by
-contextMenuInteraction:previewForDismissingMenuWithConfiguration:. The cached value was
then cleared in -contextMenuInteractionDidEnd:.

This was wrong, because -contextMenuInteractionDidEnd: can be called before
-contextMenuInteraction:previewForDismissingMenuWithConfiguration:, so we would clear the
cache then create and cache a new UITargetedPreview during dismissal. Then when a new
context menu interaction started, we'd reuse the targeted preview created for the previous
dismissal (which has the wrong geometry).

Stop assuming an ordering between
-contextMenuInteraction:previewForDismissingMenuWithConfiguration: and
-contextMenuInteractionDidEnd:. Instead, always create and cache a new UITargetedPreview in
-contextMenuInteraction:previewForHighlightingMenuWithConfiguration:, then reuse it and
clear the cache in -contextMenuInteraction:previewForDismissingMenuWithConfiguration:.

  • UIProcess/ios/WKContentViewInteraction.mm:

(-[WKContentView _createTargetedPreviewIfPossible]):
(-[WKContentView contextMenuInteraction:previewForDismissingMenuWithConfiguration:]):
(-[WKContentView contextMenuInteractionDidEnd:]):

Location:
trunk/Source/WebKit
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r246901 r246907  
     12019-06-27  Andy Estes  <aestes@apple.com>
     2
     3        [iOS] Stop using cached UITargetedPreviews from previous interactions when starting a new context menu interaction
     4        https://bugs.webkit.org/show_bug.cgi?id=199285
     5        <rdar://problem/52074916>
     6
     7        Reviewed by Tim Horton.
     8
     9        WKContentView was caching the UITargetedPreview created in
     10        -contextMenuInteraction:previewForHighlightingMenuWithConfiguration: for later reuse by
     11        -contextMenuInteraction:previewForDismissingMenuWithConfiguration:. The cached value was
     12        then cleared in -contextMenuInteractionDidEnd:.
     13
     14        This was wrong, because -contextMenuInteractionDidEnd: can be called before
     15        -contextMenuInteraction:previewForDismissingMenuWithConfiguration:, so we would clear the
     16        cache then create and cache a new UITargetedPreview during dismissal. Then when a new
     17        context menu interaction started, we'd reuse the targeted preview created for the previous
     18        dismissal (which has the wrong geometry).
     19
     20        Stop assuming an ordering between
     21        -contextMenuInteraction:previewForDismissingMenuWithConfiguration: and
     22        -contextMenuInteractionDidEnd:. Instead, always create and cache a new UITargetedPreview in
     23        -contextMenuInteraction:previewForHighlightingMenuWithConfiguration:, then reuse it and
     24        clear the cache in -contextMenuInteraction:previewForDismissingMenuWithConfiguration:.
     25
     26        * UIProcess/ios/WKContentViewInteraction.mm:
     27        (-[WKContentView _createTargetedPreviewIfPossible]):
     28        (-[WKContentView contextMenuInteraction:previewForDismissingMenuWithConfiguration:]):
     29        (-[WKContentView contextMenuInteractionDidEnd:]):
     30
    1312019-06-27  Sihui Liu  <sihui_liu@apple.com>
    232
  • trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm

    r246892 r246907  
    79457945- (UITargetedPreview *)_createTargetedPreviewIfPossible
    79467946{
    7947     if (_contextMenuInteractionTargetedPreview)
    7948         return _contextMenuInteractionTargetedPreview.get();
    7949 
    79507947    RetainPtr<UITargetedPreview> targetedPreview;
    79517948
     
    79917988- (UITargetedPreview *)contextMenuInteraction:(UIContextMenuInteraction *)interaction previewForDismissingMenuWithConfiguration:(UIContextMenuConfiguration *)configuration
    79927989{
    7993     return [self _createTargetedPreviewIfPossible];
     7990    return std::exchange(_contextMenuInteractionTargetedPreview, nil).autorelease();
    79947991}
    79957992
     
    80718068    _contextMenuHasRequestedLegacyData = NO;
    80728069    _contextMenuElementInfo = nullptr;
    8073     _contextMenuInteractionTargetedPreview = nil;
    80748070}
    80758071
Note: See TracChangeset for help on using the changeset viewer.