Changeset 247326 in webkit
- Timestamp:
- Jul 10, 2019 1:40:05 PM (5 years ago)
- Location:
- trunk/Source/WebKit
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit/ChangeLog
r247322 r247326 1 2019-07-10 Dean Jackson <dino@apple.com> 2 3 Share or Copy image from context menu does not share the correct data 4 https://bugs.webkit.org/show_bug.cgi?id=199681 5 <rdar://problem/50538771> 6 7 Reviewed by Tim Horton. 8 9 The UIContextMenuInteraction calls didEndInteraction before executing the 10 actions of a selected menu item. This means we were assuming the interaction 11 had finished before performing the action triggered in the interaction, ending 12 up in the state where we had forgotten which element we were working with. 13 14 Rather than ask for UIKit to change, I'm just starting the interaction again 15 as the action is run. Thankfully we already had the location of the interaction. 16 There is a small risk that the page has changed in the meantime, but I'm not 17 sure what to do about that. 18 19 While here, I moved a method only used by us into _WKElementActionInternal, 20 and changed the location stored by _WKActivatedElementInfo from a CGPoint 21 to an WebCore::IntPoint (since it doesn't escape WebKit). 22 23 * UIProcess/API/Cocoa/_WKActivatedElementInfo.mm: Use a WebCore::IntPoint rather than a CGPoint. 24 (-[_WKActivatedElementInfo _initWithType:URL:imageURL:location:title:ID:rect:image:]): 25 (-[_WKActivatedElementInfo _initWithType:URL:imageURL:location:title:ID:rect:image:userInfo:]): 26 (-[_WKActivatedElementInfo _interactionLocation]): 27 * UIProcess/API/Cocoa/_WKActivatedElementInfoInternal.h: 28 29 * UIProcess/API/Cocoa/_WKElementAction.h: Move uiActionForElementInfo to Internal. 30 * UIProcess/API/Cocoa/_WKElementActionInternal.h: 31 32 * UIProcess/API/Cocoa/_WKElementAction.mm: When executing the handlers, restart the interaction 33 using the location in _WKActivatedElementInfo. 34 (+[_WKElementAction _elementActionWithType:customTitle:assistant:]): 35 36 * UIProcess/ios/WKContentViewInteraction.mm: Explicitly start and stop interactions at 37 the appropriate points in the UIContextMenu flow. This isn't really needed since we're 38 doing it in the handlers, but it will be correct if the UIKit delegate order changes. 39 (-[WKContentView continueContextMenuInteraction:]): 40 (-[WKContentView contextMenuInteractionDidEnd:]): 41 1 42 2019-07-10 Chris Dumez <cdumez@apple.com> 2 43 -
trunk/Source/WebKit/UIProcess/API/Cocoa/_WKActivatedElementInfo.mm
r246224 r247326 42 42 RetainPtr<NSURL> _imageURL; 43 43 RetainPtr<NSString> _title; 44 CGPoint _interactionLocation;44 WebCore::IntPoint _interactionLocation; 45 45 RetainPtr<NSString> _ID; 46 46 RefPtr<WebKit::ShareableBitmap> _image; … … 89 89 #endif 90 90 91 - (instancetype)_initWithType:(_WKActivatedElementType)type URL:(NSURL *)url imageURL:(NSURL *)imageURL location:( CGPoint)location title:(NSString *)title ID:(NSString *)ID rect:(CGRect)rect image:(WebKit::ShareableBitmap*)image91 - (instancetype)_initWithType:(_WKActivatedElementType)type URL:(NSURL *)url imageURL:(NSURL *)imageURL location:(const WebCore::IntPoint&)location title:(NSString *)title ID:(NSString *)ID rect:(CGRect)rect image:(WebKit::ShareableBitmap*)image 92 92 { 93 93 return [self _initWithType:type URL:url imageURL:imageURL location:location title:title ID:ID rect:rect image:image userInfo:nil]; 94 94 } 95 95 96 - (instancetype)_initWithType:(_WKActivatedElementType)type URL:(NSURL *)url imageURL:(NSURL *)imageURL location:( CGPoint)location title:(NSString *)title ID:(NSString *)ID rect:(CGRect)rect image:(WebKit::ShareableBitmap*)image userInfo:(NSDictionary *)userInfo96 - (instancetype)_initWithType:(_WKActivatedElementType)type URL:(NSURL *)url imageURL:(NSURL *)imageURL location:(const WebCore::IntPoint&)location title:(NSString *)title ID:(NSString *)ID rect:(CGRect)rect image:(WebKit::ShareableBitmap*)image userInfo:(NSDictionary *)userInfo 97 97 { 98 98 if (!(self = [super init])) … … 134 134 } 135 135 136 - ( CGPoint)_interactionLocation136 - (WebCore::IntPoint)_interactionLocation 137 137 { 138 138 return _interactionLocation; -
trunk/Source/WebKit/UIProcess/API/Cocoa/_WKActivatedElementInfoInternal.h
r244368 r247326 29 29 #import "_WKActivatedElementInfo.h" 30 30 31 #import <WebCore/IntPoint.h> 32 31 33 namespace WebKit { 32 34 class ShareableBitmap; … … 39 41 - (instancetype)_initWithInteractionInformationAtPosition:(const WebKit::InteractionInformationAtPosition&)information; 40 42 #endif 41 - (instancetype)_initWithType:(_WKActivatedElementType)type URL:(NSURL *)url imageURL:(NSURL *)imageURL location:( CGPoint)location title:(NSString *)title ID:(NSString *)ID rect:(CGRect)rect image:(WebKit::ShareableBitmap*)image;42 - (instancetype)_initWithType:(_WKActivatedElementType)type URL:(NSURL *)url imageURL:(NSURL *)imageURL location:( CGPoint)location title:(NSString *)title ID:(NSString *)ID rect:(CGRect)rect image:(WebKit::ShareableBitmap*)image userInfo:(NSDictionary *)userInfo;43 - (instancetype)_initWithType:(_WKActivatedElementType)type URL:(NSURL *)url imageURL:(NSURL *)imageURL location:(const WebCore::IntPoint&)location title:(NSString *)title ID:(NSString *)ID rect:(CGRect)rect image:(WebKit::ShareableBitmap*)image; 44 - (instancetype)_initWithType:(_WKActivatedElementType)type URL:(NSURL *)url imageURL:(NSURL *)imageURL location:(const WebCore::IntPoint&)location title:(NSString *)title ID:(NSString *)ID rect:(CGRect)rect image:(WebKit::ShareableBitmap*)image userInfo:(NSDictionary *)userInfo; 43 45 44 @property (nonatomic, readonly) CGPoint _interactionLocation;46 @property (nonatomic, readonly) WebCore::IntPoint _interactionLocation; 45 47 46 48 @end -
trunk/Source/WebKit/UIProcess/API/Cocoa/_WKElementAction.h
r246865 r247326 68 68 - (void)runActionWithElementInfo:(_WKActivatedElementInfo *)info WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(9.0)); 69 69 70 - (UIAction *)uiActionForElementInfo:(_WKActivatedElementInfo *)elementInfo WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(13.0));71 72 70 @property (nonatomic, readonly) _WKElementActionType type; 73 71 @property (nonatomic, readonly) NSString* title; -
trunk/Source/WebKit/UIProcess/API/Cocoa/_WKElementAction.mm
r247185 r247326 124 124 title = WEB_UI_STRING_KEY("Copy", "Copy (ActionSheet)", "Title for Copy Link or Image action button"); 125 125 handler = ^(WKActionSheetAssistant *assistant, _WKActivatedElementInfo *actionInfo) { 126 if ([assistant.delegate respondsToSelector:@selector(actionSheetAssistant:willStartInteractionWithElement:)]) 127 [assistant.delegate actionSheetAssistant:assistant willStartInteractionWithElement:actionInfo]; 126 128 [assistant.delegate actionSheetAssistant:assistant performAction:WebKit::SheetAction::Copy]; 129 if ([assistant.delegate respondsToSelector:@selector(actionSheetAssistantDidStopInteraction:)]) 130 [assistant.delegate actionSheetAssistantDidStopInteraction:assistant]; 127 131 }; 128 132 break; … … 136 140 title = WEB_UI_STRING("Add to Photos", "Title for Add to Photos action button"); 137 141 handler = ^(WKActionSheetAssistant *assistant, _WKActivatedElementInfo *actionInfo) { 142 if ([assistant.delegate respondsToSelector:@selector(actionSheetAssistant:willStartInteractionWithElement:)]) 143 [assistant.delegate actionSheetAssistant:assistant willStartInteractionWithElement:actionInfo]; 138 144 [assistant.delegate actionSheetAssistant:assistant performAction:WebKit::SheetAction::SaveImage]; 145 if ([assistant.delegate respondsToSelector:@selector(actionSheetAssistantDidStopInteraction:)]) 146 [assistant.delegate actionSheetAssistantDidStopInteraction:assistant]; 139 147 }; 140 148 break; -
trunk/Source/WebKit/UIProcess/API/Cocoa/_WKElementActionInternal.h
r242339 r247326 37 37 - (void)_runActionWithElementInfo:(_WKActivatedElementInfo *)info forActionSheetAssistant:(WKActionSheetAssistant *)assistant; 38 38 39 - (UIAction *)uiActionForElementInfo:(_WKActivatedElementInfo *)elementInfo; 40 39 41 @end 40 42 -
trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm
r247321 r247326 77 77 #import "_WKActivatedElementInfoInternal.h" 78 78 #import "_WKElementAction.h" 79 #import "_WKElementActionInternal.h" 79 80 #import "_WKFocusedElementInfo.h" 80 81 #import "_WKInputDelegate.h" … … 7862 7863 }; 7863 7864 7865 _page->startInteractionWithElementAtPosition(_positionInformation.request.point); 7866 7864 7867 // FIXME: Should we provide an identifier and ASSERT in delegates if we don't match? 7865 7868 return continueWithContextMenuConfiguration([UIContextMenuConfiguration configurationWithIdentifier:nil previewProvider:contentPreviewProvider actionProvider:actionMenuProvider]); … … 7873 7876 7874 7877 if (configurationFromWKUIDelegate) { 7878 strongSelf->_page->startInteractionWithElementAtPosition(strongSelf->_positionInformation.request.point); 7875 7879 strongSelf->_contextMenuActionProviderDelegateNeedsOverride = YES; 7876 7880 continueWithContextMenuConfiguration(configurationFromWKUIDelegate); … … 7895 7899 UIContextMenuConfiguration *configurationFromDD = [ddContextMenuActionClass contextMenuConfigurationForURL:linkURL identifier:strongSelf->_positionInformation.dataDetectorIdentifier selectedText:[strongSelf selectedText] results:strongSelf->_positionInformation.dataDetectorResults.get() inView:strongSelf.get() context:context menuIdentifier:nil]; 7896 7900 strongSelf->_contextMenuActionProviderDelegateNeedsOverride = YES; 7901 strongSelf->_page->startInteractionWithElementAtPosition(strongSelf->_positionInformation.request.point); 7897 7902 if (strongSelf->_showLinkPreviews) 7898 7903 return continueWithContextMenuConfiguration(configurationFromDD); … … 8121 8126 } 8122 8127 } 8128 8129 _page->stopInteraction(); 8123 8130 8124 8131 _contextMenuLegacyPreviewController = nullptr;
Note: See TracChangeset
for help on using the changeset viewer.