Changeset 246622 in webkit
- Timestamp:
- Jun 19, 2019, 5:50:30 PM (7 years ago)
- Location:
- trunk/Source/WebKit
- Files:
-
- 3 edited
-
ChangeLog (modified) (1 diff)
-
UIProcess/ios/WKContentViewInteraction.h (modified) (2 diffs)
-
UIProcess/ios/WKContentViewInteraction.mm (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit/ChangeLog
r246616 r246622 1 2019-06-19 Andy Estes <aestes@apple.com> 2 3 [iOS] Fall back to taking a UIView snapshohot for UITargetedPreviews if InteractionInformationAtPosition does not have an image 4 https://bugs.webkit.org/show_bug.cgi?id=199038 5 <rdar://problem/50555810> 6 7 Reviewed by Tim Horton. 8 9 In -contextMenuInteraction:previewForHighlightingMenuWithConfiguration: and friend, we 10 should always return a non-nil UITargetedPreview. When we do return nil, UIKit uses the web 11 view itself as the snapshot view, creating an unsightly animation. 12 13 For cases where we fail to create a UITargetedPreview from the information in 14 InteractionInformationAtPosition, this patch falls back to creating a UITargetedPreview with 15 a snapshot view obtained from 16 -[UIView resizableSnapshotViewFromRect:afterScreenUpdates:withCapInsets:]. 17 18 Also renamed -targetedPreview to -_ensureTargetedPreview and cached the UITargetedPreview 19 for reuse in -contextMenuInteraction:previewForDismissingMenuWithConfiguration:. 20 21 * UIProcess/ios/WKContentViewInteraction.h: 22 * UIProcess/ios/WKContentViewInteraction.mm: 23 (createFallbackTargetedPreview): 24 (-[WKContentView _ensureTargetedPreview]): 25 (-[WKContentView contextMenuInteraction:previewForHighlightingMenuWithConfiguration:]): 26 (-[WKContentView contextMenuInteraction:previewForDismissingMenuWithConfiguration:]): 27 (-[WKContentView contextMenuInteractionDidEnd:]): 28 (-[WKContentView _targetedPreview]): Renamed to _ensureTargetedPreview. 29 1 30 2019-06-19 Devin Rousso <drousso@apple.com> 2 31 -
trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.h
r246583 r246622 96 96 @class _UIWebHighlightLongPressGestureRecognizer; 97 97 @class UIHoverGestureRecognizer; 98 @class UITargetedPreview; 98 99 @class WebEvent; 99 100 @class WKActionSheetAssistant; … … 250 251 RetainPtr<UIMenu> _contextMenuLegacyMenu; 251 252 BOOL _contextMenuHasRequestedLegacyData; 253 RetainPtr<UITargetedPreview> _contextMenuInteractionTargetedPreview; 252 254 #else 253 255 RetainPtr<UIPreviewItemController> _previewItemController; -
trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm
r246583 r246622 7860 7860 } 7861 7861 7862 - (UITargetedPreview *)_targetedPreview 7863 { 7862 static RetainPtr<UITargetedPreview> createFallbackTargetedPreview(UIView *rootView, UIView *containerView, const WebCore::FloatRect& frameInRootViewCoordinates) 7863 { 7864 auto parameters = adoptNS([[UIPreviewParameters alloc] init]); 7865 UIView *snapshotView = [rootView resizableSnapshotViewFromRect:frameInRootViewCoordinates afterScreenUpdates:NO withCapInsets:UIEdgeInsetsZero]; 7866 7867 CGRect frameInContainerViewCoordinates = [rootView convertRect:frameInRootViewCoordinates toView:containerView]; 7868 snapshotView.frame = frameInContainerViewCoordinates; 7869 7870 CGPoint centerInContainerViewCoordinates = CGPointMake(CGRectGetMidX(frameInContainerViewCoordinates), CGRectGetMidY(frameInContainerViewCoordinates)); 7871 auto target = adoptNS([[UIPreviewTarget alloc] initWithContainer:containerView center:centerInContainerViewCoordinates]); 7872 7873 return adoptNS([[UITargetedPreview alloc] initWithView:snapshotView parameters:parameters.get() target:target.get()]); 7874 } 7875 7876 - (UITargetedPreview *)_ensureTargetedPreview 7877 { 7878 if (_contextMenuInteractionTargetedPreview) 7879 return _contextMenuInteractionTargetedPreview.get(); 7880 7881 RetainPtr<UITargetedPreview> targetedPreview; 7882 7864 7883 if (_positionInformation.isLink && _positionInformation.linkIndicator.contentImage) { 7865 [self _startSuppressingSelectionAssistantForReason:WebKit::InteractionIsHappening];7866 7867 7884 auto indicator = _positionInformation.linkIndicator; 7868 7885 auto textIndicatorImage = uiImageForImage(indicator.contentImage.get()); 7869 7870 return createTargetedPreview(textIndicatorImage.get(), self, self.unscaledView, indicator.textBoundingRectInRootViewCoordinates, indicator.textRectsInBoundingRectCoordinates, [UIColor colorWithCGColor:cachedCGColor(indicator.estimatedBackgroundColor)]).autorelease(); 7871 } 7872 7873 if ((_positionInformation.isAttachment || _positionInformation.isImage) && _positionInformation.image) { 7874 [self _startSuppressingSelectionAssistantForReason:WebKit::InteractionIsHappening]; 7875 7876 RetainPtr<CGImageRef> cgImage = _positionInformation.image->makeCGImageCopy(); 7886 targetedPreview = createTargetedPreview(textIndicatorImage.get(), self, self.unscaledView, indicator.textBoundingRectInRootViewCoordinates, indicator.textRectsInBoundingRectCoordinates, [UIColor colorWithCGColor:cachedCGColor(indicator.estimatedBackgroundColor)]); 7887 } else if ((_positionInformation.isAttachment || _positionInformation.isImage) && _positionInformation.image) { 7888 auto cgImage = _positionInformation.image->makeCGImageCopy(); 7877 7889 auto image = adoptNS([[UIImage alloc] initWithCGImage:cgImage.get()]); 7878 7879 return createTargetedPreview(image.get(), self, self.unscaledView, _positionInformation.bounds, { }, nil).autorelease(); 7880 } 7881 7882 return nil; 7890 targetedPreview = createTargetedPreview(image.get(), self, self.unscaledView, _positionInformation.bounds, { }, nil); 7891 } 7892 7893 if (!targetedPreview) 7894 targetedPreview = createFallbackTargetedPreview(self, self.unscaledView, _positionInformation.bounds); 7895 7896 _contextMenuInteractionTargetedPreview = WTFMove(targetedPreview); 7897 return _contextMenuInteractionTargetedPreview.get(); 7883 7898 } 7884 7899 7885 7900 - (UITargetedPreview *)contextMenuInteraction:(UIContextMenuInteraction *)interaction previewForHighlightingMenuWithConfiguration:(UIContextMenuConfiguration *)configuration 7886 7901 { 7887 return [self _targetedPreview]; 7902 [self _startSuppressingSelectionAssistantForReason:WebKit::InteractionIsHappening]; 7903 return [self _ensureTargetedPreview]; 7888 7904 } 7889 7905 … … 7906 7922 - (UITargetedPreview *)contextMenuInteraction:(UIContextMenuInteraction *)interaction previewForDismissingMenuWithConfiguration:(UIContextMenuConfiguration *)configuration 7907 7923 { 7908 return [self _ targetedPreview];7924 return [self _ensureTargetedPreview]; 7909 7925 } 7910 7926 … … 7986 8002 _contextMenuHasRequestedLegacyData = NO; 7987 8003 _contextMenuElementInfo = nullptr; 8004 _contextMenuInteractionTargetedPreview = nil; 7988 8005 } 7989 8006
Note:
See TracChangeset
for help on using the changeset viewer.