Changeset 244553 in webkit
- Timestamp:
- Apr 23, 2019 11:15:39 AM (5 years ago)
- Location:
- trunk/Source/WebKit
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit/ChangeLog
r244546 r244553 1 2019-04-23 Tim Horton <timothy_horton@apple.com> 2 3 Action sheet shares a stringified URL instead of a URL object 4 https://bugs.webkit.org/show_bug.cgi?id=197185 5 <rdar://problem/49962249> 6 7 Reviewed by Darin Adler. 8 9 * UIProcess/Cocoa/WKShareSheet.h: 10 * UIProcess/Cocoa/WKShareSheet.mm: 11 (-[WKShareSheet presentWithParameters:inRect:completionHandler:]): 12 (-[WKShareSheet presentWithParameters:completionHandler:]): Deleted. 13 * UIProcess/Cocoa/WebViewImpl.mm: 14 (WebKit::WebViewImpl::showShareSheet): 15 * UIProcess/ios/PageClientImplIOS.mm: 16 (WebKit::PageClientImpl::showShareSheet): 17 Make it possible to optionally provide WKShareSheet with 18 a rect to present relative to. 19 20 * UIProcess/ios/WKContentViewInteraction.h: 21 * UIProcess/ios/WKContentViewInteraction.mm: 22 (-[WKContentView _showShareSheet:inRect:completionHandler:]): 23 (-[WKContentView actionSheetAssistant:shareElementWithURL:rect:]): 24 (-[WKContentView _showShareSheet:completionHandler:]): Deleted. 25 Instead of stringifying the URL and using the text selection assistant's 26 share method, hand WKShareSheet a proper URL. 27 1 28 2019-04-23 Ryosuke Niwa <rniwa@webkit.org> 2 29 -
trunk/Source/WebKit/UIProcess/Cocoa/WKShareSheet.h
r242339 r244553 39 39 - (instancetype)initWithView:(WKWebView *)view; 40 40 41 - (void)presentWithParameters:(const WebCore::ShareDataWithParsedURL&)data completionHandler:(WTF::CompletionHandler<void(bool)>&&)completionHandler;41 - (void)presentWithParameters:(const WebCore::ShareDataWithParsedURL&)data inRect:(WTF::Optional<WebCore::FloatRect>)rect completionHandler:(WTF::CompletionHandler<void(bool)>&&)completionHandler; 42 42 - (void)dismiss; 43 43 -
trunk/Source/WebKit/UIProcess/Cocoa/WKShareSheet.mm
r242339 r244553 69 69 } 70 70 71 - (void)presentWithParameters:(const WebCore::ShareDataWithParsedURL &)data completionHandler:(WTF::CompletionHandler<void(bool)>&&)completionHandler71 - (void)presentWithParameters:(const WebCore::ShareDataWithParsedURL &)data inRect:(WTF::Optional<WebCore::FloatRect>)rect completionHandler:(WTF::CompletionHandler<void(bool)>&&)completionHandler 72 72 { 73 73 auto shareDataArray = adoptNS([[NSMutableArray alloc] init]); … … 104 104 // WKShareSheet can be released under NSSharingServicePicker delegate callbacks. 105 105 RetainPtr<WKShareSheet> protector(self); 106 107 NSPoint location = [NSEvent mouseLocation]; 108 NSRect mouseLocationRect = NSMakeRect(location.x, location.y, 1.0, 1.0); 109 NSRect mouseLocationInWindow = [webView.window convertRectFromScreen:mouseLocationRect]; 110 NSRect mouseLocationInView = [webView convertRect:mouseLocationInWindow fromView:nil]; 111 [_sharingServicePicker showRelativeToRect:mouseLocationInView ofView:webView preferredEdge:NSMinYEdge]; 106 NSRect presentationRect; 107 108 if (rect) 109 presentationRect = *rect; 110 else { 111 NSPoint location = [NSEvent mouseLocation]; 112 NSRect mouseLocationRect = NSMakeRect(location.x, location.y, 1.0, 1.0); 113 NSRect mouseLocationInWindow = [webView.window convertRectFromScreen:mouseLocationRect]; 114 presentationRect = [webView convertRect:mouseLocationInWindow fromView:nil]; 115 } 116 [_sharingServicePicker showRelativeToRect:presentationRect ofView:webView preferredEdge:NSMinYEdge]; 112 117 #else 113 118 _shareSheetViewController = adoptNS([[UIActivityViewController alloc] initWithActivityItems:shareDataArray.get() applicationActivities:nil]); … … 118 123 119 124 UIPopoverPresentationController *popoverController = [_shareSheetViewController popoverPresentationController]; 120 popoverController._centersPopoverIfSourceViewNotSet = YES; 125 if (rect) { 126 popoverController.sourceView = webView; 127 popoverController.sourceRect = *rect; 128 } else 129 popoverController._centersPopoverIfSourceViewNotSet = YES; 121 130 122 131 _presentationViewController = [UIViewController _viewControllerForFullScreenPresentationFromView:webView]; -
trunk/Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm
r244545 r244553 2783 2783 [_shareSheet setDelegate:view]; 2784 2784 2785 [_shareSheet presentWithParameters:data completionHandler:WTFMove(completionHandler)];2785 [_shareSheet presentWithParameters:data inRect:WTF::nullopt completionHandler:WTFMove(completionHandler)]; 2786 2786 } 2787 2787 -
trunk/Source/WebKit/UIProcess/ios/PageClientImplIOS.mm
r244085 r244553 587 587 bool PageClientImpl::showShareSheet(const ShareDataWithParsedURL& shareData, WTF::CompletionHandler<void(bool)>&& completionHandler) 588 588 { 589 [m_contentView _showShareSheet:shareData completionHandler:WTFMove(completionHandler)];589 [m_contentView _showShareSheet:shareData inRect:WTF::nullopt completionHandler:WTFMove(completionHandler)]; 590 590 return true; 591 591 } -
trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.h
r244370 r244553 430 430 - (void)_showPlaybackTargetPicker:(BOOL)hasVideo fromRect:(const WebCore::IntRect&)elementRect routeSharingPolicy:(WebCore::RouteSharingPolicy)policy routingContextUID:(NSString *)contextUID; 431 431 - (void)_showRunOpenPanel:(API::OpenPanelParameters*)parameters resultListener:(WebKit::WebOpenPanelResultListenerProxy*)listener; 432 - (void)_showShareSheet:(const WebCore::ShareDataWithParsedURL&)shareData completionHandler:(WTF::CompletionHandler<void(bool)>&&)completionHandler;432 - (void)_showShareSheet:(const WebCore::ShareDataWithParsedURL&)shareData inRect:(WTF::Optional<WebCore::FloatRect>)rect completionHandler:(WTF::CompletionHandler<void(bool)>&&)completionHandler; 433 433 - (void)dismissFilePicker; 434 434 - (void)_didHandleKeyEvent:(::WebEvent *)event eventWasHandled:(BOOL)eventWasHandled; -
trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm
r244474 r244553 5794 5794 } 5795 5795 5796 - (void)_showShareSheet:(const WebCore::ShareDataWithParsedURL&)data completionHandler:(CompletionHandler<void(bool)>&&)completionHandler5796 - (void)_showShareSheet:(const WebCore::ShareDataWithParsedURL&)data inRect:(WTF::Optional<WebCore::FloatRect>)rect completionHandler:(CompletionHandler<void(bool)>&&)completionHandler 5797 5797 { 5798 5798 #if !PLATFORM(WATCHOS) && !PLATFORM(APPLETV) … … 5803 5803 [_shareSheet setDelegate:self]; 5804 5804 5805 [_shareSheet presentWithParameters:data completionHandler:WTFMove(completionHandler)];5805 [_shareSheet presentWithParameters:data inRect:rect completionHandler:WTFMove(completionHandler)]; 5806 5806 #endif 5807 5807 } … … 5904 5904 - (void)actionSheetAssistant:(WKActionSheetAssistant *)assistant shareElementWithURL:(NSURL *)url rect:(CGRect)boundingRect 5905 5905 { 5906 if (_textSelectionAssistant) 5907 [_textSelectionAssistant showShareSheetFor:WTF::userVisibleString(url) fromRect:boundingRect]; 5906 WebCore::ShareDataWithParsedURL shareData; 5907 shareData.url = { url }; 5908 [self _showShareSheet:shareData inRect: { [self convertRect:boundingRect toView:_webView] } completionHandler:[] (bool success) { }]; 5908 5909 } 5909 5910
Note: See TracChangeset
for help on using the changeset viewer.