WebKit Bugzilla
Attachment 372500 Details for
Bug 199038
: [iOS] Fall back to taking a UIView snapshohot for UITargetedPreviews if InteractionInformationAtPosition does not have an image
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-199038-20190619164935.patch (text/plain), 8.18 KB, created by
Andy Estes
on 2019-06-19 16:49:36 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Andy Estes
Created:
2019-06-19 16:49:36 PDT
Size:
8.18 KB
patch
obsolete
>Subversion Revision: 246594 >diff --git a/Source/WebKit/ChangeLog b/Source/WebKit/ChangeLog >index 564d89968df83943c5f03a2bef2fa87c6814eb5a..b026efb9316f2426c0e8484c0ba4ff816c9dd511 100644 >--- a/Source/WebKit/ChangeLog >+++ b/Source/WebKit/ChangeLog >@@ -1,3 +1,32 @@ >+2019-06-19 Andy Estes <aestes@apple.com> >+ >+ [iOS] Fall back to taking a UIView snapshohot for UITargetedPreviews if InteractionInformationAtPosition does not have an image >+ https://bugs.webkit.org/show_bug.cgi?id=199038 >+ <rdar://problem/50555810> >+ >+ Reviewed by Tim Horton. >+ >+ In -contextMenuInteraction:previewForHighlightingMenuWithConfiguration: and friend, we >+ should always return a non-nil UITargetedPreview. When we do return nil, UIKit uses the web >+ view itself as the snapshot view, creating an unsightly animation. >+ >+ For cases where we fail to create a UITargetedPreview from the information in >+ InteractionInformationAtPosition, this patch falls back to creating a UITargetedPreview with >+ a snapshot view obtained from >+ -[UIView resizableSnapshotViewFromRect:afterScreenUpdates:withCapInsets:]. >+ >+ Also renamed -targetedPreview to -_ensureTargetedPreview and cached the UITargetedPreview >+ for reuse in -contextMenuInteraction:previewForDismissingMenuWithConfiguration:. >+ >+ * UIProcess/ios/WKContentViewInteraction.h: >+ * UIProcess/ios/WKContentViewInteraction.mm: >+ (createFallbackTargetedPreview): >+ (-[WKContentView _ensureTargetedPreview]): >+ (-[WKContentView contextMenuInteraction:previewForHighlightingMenuWithConfiguration:]): >+ (-[WKContentView contextMenuInteraction:previewForDismissingMenuWithConfiguration:]): >+ (-[WKContentView contextMenuInteractionDidEnd:]): >+ (-[WKContentView _targetedPreview]): Renamed to _ensureTargetedPreview. >+ > 2019-06-19 Alexander Mikhaylenko <exalm7659@gmail.com> > > [GTK] Page blinks after navigation swipe if it triggered PSON >diff --git a/Source/WebKit/UIProcess/ios/WKContentViewInteraction.h b/Source/WebKit/UIProcess/ios/WKContentViewInteraction.h >index 30c0adb21ab7cb1dd7d928244813e62a308c43d5..27dadb8a987b8e9e096d78a5093fb27f231395dc 100644 >--- a/Source/WebKit/UIProcess/ios/WKContentViewInteraction.h >+++ b/Source/WebKit/UIProcess/ios/WKContentViewInteraction.h >@@ -95,6 +95,7 @@ struct WebAutocorrectionContext; > @class _UIHighlightView; > @class _UIWebHighlightLongPressGestureRecognizer; > @class UIHoverGestureRecognizer; >+@class UITargetedPreview; > @class WebEvent; > @class WKActionSheetAssistant; > @class WKContextMenuElementInfo; >@@ -249,6 +250,7 @@ struct WKAutoCorrectionData { > RetainPtr<UIViewController> _contextMenuLegacyPreviewController; > RetainPtr<UIMenu> _contextMenuLegacyMenu; > BOOL _contextMenuHasRequestedLegacyData; >+ RetainPtr<UITargetedPreview> _contextMenuInteractionTargetedPreview; > #else > RetainPtr<UIPreviewItemController> _previewItemController; > #endif >diff --git a/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm b/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm >index c8c4dc5c460466b427b3acb908c7a4bad91f1ca4..0398202611bf3a7d8870f98a4777ebee8a7671ba 100644 >--- a/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm >+++ b/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm >@@ -7859,32 +7859,48 @@ static RetainPtr<UITargetedPreview> createTargetedPreview(UIImage *image, UIView > return adoptNS([[UITargetedPreview alloc] initWithView:imageView.get() parameters:parameters.get() target:target.get()]); > } > >-- (UITargetedPreview *)_targetedPreview >+static RetainPtr<UITargetedPreview> createFallbackTargetedPreview(UIView *rootView, UIView *containerView, const WebCore::FloatRect& frameInRootViewCoordinates) > { >- if (_positionInformation.isLink && _positionInformation.linkIndicator.contentImage) { >- [self _startSuppressingSelectionAssistantForReason:WebKit::InteractionIsHappening]; >+ auto parameters = adoptNS([[UIPreviewParameters alloc] init]); >+ UIView *snapshotView = [rootView resizableSnapshotViewFromRect:frameInRootViewCoordinates afterScreenUpdates:NO withCapInsets:UIEdgeInsetsZero]; > >- auto indicator = _positionInformation.linkIndicator; >- auto textIndicatorImage = uiImageForImage(indicator.contentImage.get()); >+ CGRect frameInContainerViewCoordinates = [rootView convertRect:frameInRootViewCoordinates toView:containerView]; >+ snapshotView.frame = frameInContainerViewCoordinates; > >- return createTargetedPreview(textIndicatorImage.get(), self, self.unscaledView, indicator.textBoundingRectInRootViewCoordinates, indicator.textRectsInBoundingRectCoordinates, [UIColor colorWithCGColor:cachedCGColor(indicator.estimatedBackgroundColor)]).autorelease(); >- } >+ CGPoint centerInContainerViewCoordinates = CGPointMake(CGRectGetMidX(frameInContainerViewCoordinates), CGRectGetMidY(frameInContainerViewCoordinates)); >+ auto target = adoptNS([[UIPreviewTarget alloc] initWithContainer:containerView center:centerInContainerViewCoordinates]); > >- if ((_positionInformation.isAttachment || _positionInformation.isImage) && _positionInformation.image) { >- [self _startSuppressingSelectionAssistantForReason:WebKit::InteractionIsHappening]; >+ return adoptNS([[UITargetedPreview alloc] initWithView:snapshotView parameters:parameters.get() target:target.get()]); >+} > >- RetainPtr<CGImageRef> cgImage = _positionInformation.image->makeCGImageCopy(); >- auto image = adoptNS([[UIImage alloc] initWithCGImage:cgImage.get()]); >+- (UITargetedPreview *)_ensureTargetedPreview >+{ >+ if (_contextMenuInteractionTargetedPreview) >+ return _contextMenuInteractionTargetedPreview.get(); > >- return createTargetedPreview(image.get(), self, self.unscaledView, _positionInformation.bounds, { }, nil).autorelease(); >+ RetainPtr<UITargetedPreview> targetedPreview; >+ >+ if (_positionInformation.isLink && _positionInformation.linkIndicator.contentImage) { >+ auto indicator = _positionInformation.linkIndicator; >+ auto textIndicatorImage = uiImageForImage(indicator.contentImage.get()); >+ targetedPreview = createTargetedPreview(textIndicatorImage.get(), self, self.unscaledView, indicator.textBoundingRectInRootViewCoordinates, indicator.textRectsInBoundingRectCoordinates, [UIColor colorWithCGColor:cachedCGColor(indicator.estimatedBackgroundColor)]); >+ } else if ((_positionInformation.isAttachment || _positionInformation.isImage) && _positionInformation.image) { >+ auto cgImage = _positionInformation.image->makeCGImageCopy(); >+ auto image = adoptNS([[UIImage alloc] initWithCGImage:cgImage.get()]); >+ targetedPreview = createTargetedPreview(image.get(), self, self.unscaledView, _positionInformation.bounds, { }, nil); > } > >- return nil; >+ if (!targetedPreview) >+ targetedPreview = createFallbackTargetedPreview(self, self.unscaledView, _positionInformation.bounds); >+ >+ _contextMenuInteractionTargetedPreview = WTFMove(targetedPreview); >+ return _contextMenuInteractionTargetedPreview.get(); > } > > - (UITargetedPreview *)contextMenuInteraction:(UIContextMenuInteraction *)interaction previewForHighlightingMenuWithConfiguration:(UIContextMenuConfiguration *)configuration > { >- return [self _targetedPreview]; >+ [self _startSuppressingSelectionAssistantForReason:WebKit::InteractionIsHappening]; >+ return [self _ensureTargetedPreview]; > } > > - (void)contextMenuInteractionWillPresent:(UIContextMenuInteraction *)interaction >@@ -7905,7 +7921,7 @@ - (void)contextMenuInteractionWillPresent:(UIContextMenuInteraction *)interactio > > - (UITargetedPreview *)contextMenuInteraction:(UIContextMenuInteraction *)interaction previewForDismissingMenuWithConfiguration:(UIContextMenuConfiguration *)configuration > { >- return [self _targetedPreview]; >+ return [self _ensureTargetedPreview]; > } > > - (void)contextMenuInteraction:(UIContextMenuInteraction *)interaction willCommitWithAnimator:(id<UIContextMenuInteractionCommitAnimating>)animator >@@ -7985,6 +8001,7 @@ - (void)contextMenuInteractionDidEnd:(UIContextMenuInteraction *)interaction > _contextMenuLegacyMenu = nullptr; > _contextMenuHasRequestedLegacyData = NO; > _contextMenuElementInfo = nullptr; >+ _contextMenuInteractionTargetedPreview = nil; > } > > @end
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 199038
:
372498
| 372500