Changeset 257214 in webkit
- Timestamp:
- Feb 24, 2020 10:05:20 AM (4 years ago)
- Location:
- trunk/Source/WebKit
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit/ChangeLog
r257211 r257214 1 2020-02-24 Wenson Hsieh <wenson_hsieh@apple.com> 2 3 REGRESSION (r248481): drag animation of a link starts from the incorrect location 4 https://bugs.webkit.org/show_bug.cgi?id=208113 5 <rdar://problem/59448696> 6 7 Reviewed by Tim Horton. 8 9 For both dragging and context menu interactions, UIKit asks us for targeted previews, which are hosted under 10 container views provided by WebKit. These container views must be in the hierarchy (i.e. they must have a 11 UIWindow); otherwise, UIKit incorrectly computes some geometry when animating the previews. Prior to the fix for 12 <rdar://problem/57172514>, this caused targeted drag previews to animate in from a seemingly random location; 13 however, UIKit worked around this by falling back to the same codepath used for remotely hosted views, which 14 uses the last known touch location as an approximation of where to start the drag preview animation. This mostly 15 makes the bug go away, but the delta between the touch location and the actual location of the dragged element 16 in the page still causes some very minor visual differences. 17 18 Due to r248481, a separate UIView (_contextMenuHintContainerView) under the content view is used when generating 19 targeted previews for both drag and drop and context menu hints. This view is removed when the context menu 20 interaction ends; however, when starting a drag, the context menu interaction ends right before the drag session 21 actually begins, which means that when UIKit actually starts to animate the drag preview, the container view has 22 already been unparented. 23 24 To address this, introduce a separate _dragPreviewContainerView alongside _contextMenuHintContainerView, and use 25 this new view when generating targeted previews for dragging. This view is generated lazily and cleaned up 26 (unparented and cleared out) when the drag interaction has ended, in -cleanUpDragSourceSessionState. 27 28 * UIProcess/ios/WKContentViewInteraction.h: 29 30 Add _dragPreviewContainerView. 31 32 * UIProcess/ios/WKContentViewInteraction.mm: 33 (-[WKContentView _didCommitLoadForMainFrame]): 34 (-[WKContentView dataDetectionContextForPositionInformation:]): 35 (-[WKContentView containerForDragPreviews]): 36 (-[WKContentView containerForContextMenuHintPreviews]): 37 38 Split -containerViewForTargetedPreviews into -containerForDragPreviews and -containerForContextMenuHintPreviews, 39 and use them as appropriate. 40 41 (-[WKContentView _hideTargetedPreviewContainerViews]): 42 43 Renamed from _hideContextMenuHintContainer, since it hides both types of targeted preview containers now. 44 45 (-[WKContentView cleanUpDragSourceSessionState]): 46 47 Clear out and remove _dragPreviewContainerView here. 48 49 (-[WKContentView _deliverDelayedDropPreviewIfPossible:]): 50 (-[WKContentView dragInteraction:previewForLiftingItem:session:]): 51 52 Use -containerForDragPreviews when creating previews for dragging. 53 54 (-[WKContentView _createTargetedContextMenuHintPreviewIfPossible]): 55 (-[WKContentView contextMenuInteraction:previewForHighlightingMenuWithConfiguration:]): 56 57 Use -containerForContextMenuHintPreviews when creating previews for the context menu hint. 58 59 (-[WKContentView containerViewForTargetedPreviews]): Deleted. 60 (-[WKContentView _hideContextMenuHintContainer]): Deleted. 61 (-[WKContentView _createTargetedPreviewIfPossible]): Deleted. 62 1 63 2020-02-24 Rob Buis <rbuis@igalia.com> 2 64 -
trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.h
r256864 r257214 253 253 RetainPtr<UIView> _interactionViewsContainerView; 254 254 RetainPtr<UIView> _contextMenuHintContainerView; 255 RetainPtr<UIView> _dragPreviewContainerView; 255 256 RetainPtr<NSString> _markedText; 256 257 RetainPtr<WKActionSheetAssistant> _actionSheetAssistant; … … 487 488 - (void)_updateInputContextAfterBlurringAndRefocusingElement; 488 489 - (void)_elementDidBlur; 489 - (void)_hide ContextMenuHintContainer;490 - (void)_hideTargetedPreviewContainerViews; 490 491 - (void)_didUpdateInputMode:(WebCore::InputMode)mode; 491 492 - (void)_didUpdateEditorState; -
trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm
r256921 r257214 4258 4258 [self _elementDidBlur]; 4259 4259 [self _cancelLongPressGestureRecognizer]; 4260 [self _hide ContextMenuHintContainer];4260 [self _hideTargetedPreviewContainerViews]; 4261 4261 [_webView _didCommitLoadForMainFrame]; 4262 4262 … … 6762 6762 sourceRect = positionInformation.bounds; 6763 6763 6764 CGRect frameInContainerViewCoordinates = [self convertRect:sourceRect toView:self.container ViewForTargetedPreviews];6764 CGRect frameInContainerViewCoordinates = [self convertRect:sourceRect toView:self.containerForContextMenuHintPreviews]; 6765 6765 context.get()[getkDataDetectorsSourceRectKey()] = [NSValue valueWithCGRect:frameInContainerViewCoordinates]; 6766 6766 #endif … … 6822 6822 } 6823 6823 6824 // FIXME: This is used for drag previews and context menu hints; it needs a better name. 6825 - (UIView *)containerViewForTargetedPreviews 6824 - (UIView *)containerForDragPreviews 6825 { 6826 if (_dragPreviewContainerView) { 6827 ASSERT([_dragPreviewContainerView superview]); 6828 [_dragPreviewContainerView setHidden:NO]; 6829 return _dragPreviewContainerView.get(); 6830 } 6831 6832 _dragPreviewContainerView = adoptNS([[UIView alloc] init]); 6833 [_dragPreviewContainerView layer].anchorPoint = CGPointZero; 6834 [_dragPreviewContainerView layer].name = @"Drag Preview Container"; 6835 [_interactionViewsContainerView addSubview:_dragPreviewContainerView.get()]; 6836 6837 return _dragPreviewContainerView.get(); 6838 } 6839 6840 - (UIView *)containerForContextMenuHintPreviews 6826 6841 { 6827 6842 if (_contextMenuHintContainerView) { … … 6833 6848 _contextMenuHintContainerView = adoptNS([[UIView alloc] init]); 6834 6849 [_contextMenuHintContainerView layer].anchorPoint = CGPointZero; 6835 [_contextMenuHintContainerView layer].name = @"Context Menu Container";6850 [_contextMenuHintContainerView layer].name = @"Context Menu Hint Container"; 6836 6851 [_interactionViewsContainerView addSubview:_contextMenuHintContainerView.get()]; 6837 6852 … … 6839 6854 } 6840 6855 6841 - (void)_hideContextMenuHintContainer 6842 { 6856 - (void)_hideTargetedPreviewContainerViews 6857 { 6858 [_dragPreviewContainerView setHidden:YES]; 6843 6859 [_contextMenuHintContainerView setHidden:YES]; 6844 6860 } … … 7068 7084 [self _restoreCalloutBarIfNeeded]; 7069 7085 7086 [std::exchange(_dragPreviewContainerView, nil) removeFromSuperview]; 7070 7087 [std::exchange(_visibleContentViewSnapshot, nil) removeFromSuperview]; 7071 7088 [_editDropCaretView remove]; … … 7135 7152 7136 7153 [self insertSubview:_unselectedContentSnapshot.get() belowSubview:_visibleContentViewSnapshot.get()]; 7137 _dragDropInteractionState.deliverDelayedDropPreview(self, self.container ViewForTargetedPreviews, data.value());7154 _dragDropInteractionState.deliverDelayedDropPreview(self, self.containerForDragPreviews, data.value()); 7138 7155 } 7139 7156 … … 7572 7589 return overriddenPreview; 7573 7590 } 7574 return _dragDropInteractionState.previewForDragItem(item, self, self.container ViewForTargetedPreviews);7591 return _dragDropInteractionState.previewForDragItem(item, self, self.containerForDragPreviews); 7575 7592 } 7576 7593 … … 8755 8772 } 8756 8773 8757 - (UITargetedPreview *)_createTargeted PreviewIfPossible8774 - (UITargetedPreview *)_createTargetedContextMenuHintPreviewIfPossible 8758 8775 { 8759 8776 RetainPtr<UITargetedPreview> targetedPreview; … … 8762 8779 auto indicator = _positionInformation.linkIndicator; 8763 8780 auto textIndicatorImage = uiImageForImage(indicator.contentImage.get()); 8764 targetedPreview = createTargetedPreview(textIndicatorImage.get(), self, self.container ViewForTargetedPreviews, indicator.textBoundingRectInRootViewCoordinates, indicator.textRectsInBoundingRectCoordinates, [UIColor colorWithCGColor:cachedCGColor(indicator.estimatedBackgroundColor)]);8781 targetedPreview = createTargetedPreview(textIndicatorImage.get(), self, self.containerForContextMenuHintPreviews, indicator.textBoundingRectInRootViewCoordinates, indicator.textRectsInBoundingRectCoordinates, [UIColor colorWithCGColor:cachedCGColor(indicator.estimatedBackgroundColor)]); 8765 8782 } else if ((_positionInformation.isAttachment || _positionInformation.isImage) && _positionInformation.image) { 8766 8783 auto cgImage = _positionInformation.image->makeCGImageCopy(); 8767 8784 auto image = adoptNS([[UIImage alloc] initWithCGImage:cgImage.get()]); 8768 targetedPreview = createTargetedPreview(image.get(), self, self.container ViewForTargetedPreviews, _positionInformation.bounds, { }, nil);8785 targetedPreview = createTargetedPreview(image.get(), self, self.containerForContextMenuHintPreviews, _positionInformation.bounds, { }, nil); 8769 8786 } 8770 8787 8771 8788 if (!targetedPreview) 8772 targetedPreview = createFallbackTargetedPreview(self, self.container ViewForTargetedPreviews, _positionInformation.bounds);8789 targetedPreview = createFallbackTargetedPreview(self, self.containerForContextMenuHintPreviews, _positionInformation.bounds); 8773 8790 8774 8791 if (_positionInformation.containerScrollingNodeID) { … … 8788 8805 { 8789 8806 [self _startSuppressingSelectionAssistantForReason:WebKit::InteractionIsHappening]; 8790 return [self _createTargeted PreviewIfPossible];8807 return [self _createTargetedContextMenuHintPreviewIfPossible]; 8791 8808 } 8792 8809
Note: See TracChangeset
for help on using the changeset viewer.