Changeset 235925 in webkit
- Timestamp:
- Sep 11, 2018 5:57:58 PM (6 years ago)
- Location:
- trunk
- Files:
-
- 6 added
- 11 edited
- 1 copied
- 2 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r235924 r235925 1 2018-09-11 Olivia Barnett <obarnett@apple.com> 2 3 Implement the Web Share API for mac 4 https://bugs.webkit.org/show_bug.cgi?id=189443 5 6 Reviewed by Tim Horton. 7 8 * platform/mac-wk2/fast/dom/navigator-detached-no-crash-expected.txt: Added. 9 * platform/mac-wk2/imported/w3c/web-platform-tests/web-share/idlharness.https-expected.txt: Added. 10 * platform/mac-wk2/imported/w3c/web-platform-tests/web-share/share-empty.https-expected.txt: Added. 11 * platform/mac-wk2/imported/w3c/web-platform-tests/web-share/share-securecontext.http-expected.txt: Added. 12 * platform/mac-wk2/imported/w3c/web-platform-tests/web-share/share-url-invalid.https-expected.txt: Added. 13 * platform/mac-wk2/imported/w3c/web-platform-tests/web-share/share-without-user-gesture.https-expected.txt: Added. 14 Updated test expectations. 15 1 16 2018-09-11 Myles C. Maxfield <mmaxfield@apple.com> 2 17 -
trunk/LayoutTests/platform/mac-highsierra/fast/dom/navigator-detached-no-crash-expected.txt
r233831 r235925 1 CONSOLE MESSAGE: Unhandled Promise Rejection: TypeError: Type error 1 2 This tests that the navigator object of a deleted frame is disconnected properly. Accessing fields or methods shouldn't crash the browser. 2 3 Check Navigator … … 19 20 navigator.sendBeacon() threw err TypeError: Not enough arguments 20 21 navigator.serviceWorker is OK 22 navigator.share() is OK 21 23 navigator.userAgent is OK 22 24 navigator.vendor is OK … … 41 43 navigator.sendBeacon() threw err TypeError: Not enough arguments 42 44 navigator.serviceWorker is OK 45 navigator.share() is OK 43 46 navigator.userAgent is OK 44 47 navigator.vendor is OK -
trunk/LayoutTests/platform/mac-wk2/fast/dom/navigator-detached-no-crash-expected.txt
r235924 r235925 1 CONSOLE MESSAGE: Unhandled Promise Rejection: TypeError: Not enough arguments 2 CONSOLE MESSAGE: Unhandled Promise Rejection: TypeError: Type error 1 3 This tests that the navigator object of a deleted frame is disconnected properly. Accessing fields or methods shouldn't crash the browser. 2 4 Check Navigator … … 17 19 navigator.product is OK 18 20 navigator.productSub is OK 21 navigator.requestMediaKeySystemAccess() is OK 19 22 navigator.sendBeacon() threw err TypeError: Not enough arguments 20 23 navigator.serviceWorker is OK 24 navigator.share() is OK 21 25 navigator.userAgent is OK 22 26 navigator.vendor is OK … … 39 43 navigator.product is OK 40 44 navigator.productSub is OK 45 navigator.requestMediaKeySystemAccess() is OK 41 46 navigator.sendBeacon() threw err TypeError: Not enough arguments 42 47 navigator.serviceWorker is OK 48 navigator.share() is OK 43 49 navigator.userAgent is OK 44 50 navigator.vendor is OK -
trunk/Source/WebKit/ChangeLog
r235921 r235925 1 2018-09-11 Olivia Barnett <obarnett@apple.com> 2 3 Implement the Web Share API for mac 4 https://bugs.webkit.org/show_bug.cgi?id=189443 5 6 Reviewed by Tim Horton. 7 8 * Shared/WebPreferencesDefaultValues.h: 9 * UIProcess/API/Cocoa/WKWebView.mm: 10 (-[WKWebView shareSheetDidDismiss:]): 11 * UIProcess/API/Cocoa/WKWebViewInternal.h: 12 * UIProcess/API/mac/WKView.mm: 13 (-[WKView shareSheetDidDismiss:]): 14 * UIProcess/Cocoa/WebViewImpl.h: 15 * UIProcess/Cocoa/WebViewImpl.mm: 16 (WebKit::WebViewImpl::showShareSheet): 17 (WebKit::WebViewImpl::shareSheetDidDismiss): 18 Implemented function for WKShareSheetDelegate. 19 20 * UIProcess/Cocoa/WKShareSheet.h: 21 * UIProcess/Cocoa/WKShareSheet.mm: 22 (-[WKShareSheet initWithView:initWithView:]): 23 (-[WKShareSheet presentWithParameters:completionHandler:]): 24 (-[WKShareSheet sharingServicePicker:didChooseSharingService:]): 25 (-[WKShareSheet _cancel]): 26 (-[WKShareSheet dismiss]): 27 (-[WKShareSheet _dismissDisplayAnimated:]): 28 (-[WKShareSheet invokeShareSheetWithResolution:]): 29 (-[WKShareSheet initWithView:]): Deleted. 30 Added mac platform checks and share sheet functionality. 31 32 * UIProcess/mac/PageClientImplMac.h: 33 * UIProcess/mac/PageClientImplMac.mm: 34 (WebKit::PageClientImpl::showShareSheet): 35 Allows macos to invoke the system share sheet. 36 1 37 2018-09-07 Dean Jackson <dino@apple.com> 2 38 -
trunk/Source/WebKit/Shared/WebPreferencesDefaultValues.h
r235772 r235925 85 85 #define DEFAULT_JAVASCRIPT_CAN_OPEN_WINDOWS_AUTOMATICALLY true 86 86 #define DEFAULT_SHOULD_RESPECT_IMAGE_ORIENTATION false 87 #define DEFAULT_WEB_SHARE_ENABLED false88 87 #define DEFAULT_PASSWORD_ECHO_ENABLED false 89 88 #define DEFAULT_ALLOWS_INLINE_MEDIA_PLAYBACK true … … 174 173 #endif 175 174 176 #if PLATFORM( IOS) && !PLATFORM(WATCHOS) && !PLATFORM(APPLETV)175 #if PLATFORM(COCOA) && !PLATFORM(WATCHOS) && !PLATFORM(APPLETV) 177 176 #define DEFAULT_WEB_SHARE_ENABLED true 178 177 #else -
trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm
r235914 r235925 5681 5681 } 5682 5682 5683 - (void)shareSheetDidDismiss:(WKShareSheet *)shareSheet 5684 { 5685 _impl->shareSheetDidDismiss(shareSheet); 5686 } 5687 5683 5688 - (void)_setOverrideDeviceScaleFactor:(CGFloat)deviceScaleFactor 5684 5689 { -
trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewInternal.h
r235878 r235925 29 29 30 30 #import "SameDocumentNavigationType.h" 31 #import "WKShareSheet.h" 31 32 #import "WKWebViewConfiguration.h" 32 33 #import "_WKAttachmentInternal.h" … … 46 47 #if PLATFORM(IOS) 47 48 #define WK_WEB_VIEW_PROTOCOLS <UIScrollViewDelegate> 49 #endif 50 51 #if PLATFORM(MAC) 52 #define WK_WEB_VIEW_PROTOCOLS <WKShareSheetDelegate> 48 53 #endif 49 54 -
trunk/Source/WebKit/UIProcess/Cocoa/WKShareSheet.h
r235924 r235925 24 24 */ 25 25 26 #i f PLATFORM(IOS) && !PLATFORM(WATCHOS) && !PLATFORM(APPLETV)26 #import "WKAPICast.h" 27 27 28 #import <UIKit/UIKit.h> 28 #if PLATFORM(COCOA) && !PLATFORM(WATCHOS) && !PLATFORM(APPLETV) && WK_API_ENABLED 29 29 30 #import <WebCore/ShareData.h> 30 31 #import <wtf/BlockPtr.h> … … 34 35 #import <wtf/text/WTFString.h> 35 36 37 #if PLATFORM(IOS) 38 #import <UIKit/UIKit.h> 39 #else 40 #import "WKWebView.h" 41 #endif 42 36 43 @class WKContentView; 37 44 @protocol WKShareSheetDelegate; 38 45 39 @interface WKShareSheet : UIViewController 46 #if PLATFORM(MAC) 47 @interface WKShareSheet : NSObject <NSSharingServicePickerDelegate> 48 - (instancetype)initWithView:(WKWebView *)view; 49 #else 50 @interface WKShareSheet : NSObject 40 51 - (instancetype)initWithView:(WKContentView *)view; 52 #endif 41 53 42 54 - (void)presentWithParameters:(const WebCore::ShareDataWithParsedURL&)data completionHandler:(WTF::CompletionHandler<void(bool)>&&)completionHandler; … … 52 64 @end 53 65 54 #endif // PLATFORM(IOS) &&!PLATFORM(WATCHOS) && !PLATFORM(APPLETV)66 #endif // !PLATFORM(WATCHOS) && !PLATFORM(APPLETV) -
trunk/Source/WebKit/UIProcess/Cocoa/WKShareSheet.mm
r235924 r235925 27 27 #import "WKShareSheet.h" 28 28 29 #if PLATFORM( IOS) && !PLATFORM(WATCHOS) && !PLATFORM(APPLETV)30 #import "UIKitSPI.h" 29 #if PLATFORM(COCOA) && !PLATFORM(WATCHOS) && !PLATFORM(APPLETV) && WK_API_ENABLED 30 31 31 #import "WKContentViewInteraction.h" 32 32 #import "WebPageProxy.h" … … 35 35 #import <wtf/WeakObjCPtr.h> 36 36 37 #if PLATFORM(IOS) 38 #import "UIKitSPI.h" 39 #else 40 #import "WKWebView.h" 41 #endif 42 37 43 using namespace WebKit; 38 44 39 45 @implementation WKShareSheet { 46 #if PLATFORM(MAC) 47 WeakObjCPtr<WKWebView> _view; 48 49 BOOL _isShowingSharingServicePicker; 50 RetainPtr<NSSharingServicePicker> _sharingServicePickerForMenu; 51 WTF::CompletionHandler<void(bool)> _completionHandler; 52 #else 40 53 WeakObjCPtr<WKContentView> _view; 41 54 42 55 RetainPtr<UIActivityViewController> _shareSheetViewController; 43 56 RetainPtr<UIViewController> _presentationViewController; 44 57 BOOL _shouldDismissWithAnimation; 58 #endif 45 59 } 46 60 61 #if PLATFORM(MAC) 62 - (instancetype)initWithView:(WKWebView *)view 63 #else 47 64 - (instancetype)initWithView:(WKContentView *)view 65 #endif 48 66 { 49 67 if (!(self = [super init])) 50 68 return nil; 51 69 _view = view; 70 #if PLATFORM(IOS) 52 71 _shouldDismissWithAnimation = YES; 72 #endif 53 73 return self; 54 74 } … … 63 83 if (!data.url.isNull()) { 64 84 NSURL *url = (NSURL *)data.url; 85 #if PLATFORM(IOS) 65 86 if (!data.shareData.title.isEmpty()) 66 87 url._title = data.shareData.title; 88 #endif 67 89 [shareDataArray addObject:url]; 68 90 } … … 71 93 [shareDataArray addObject:(NSString *)data.shareData.title]; 72 94 95 #if PLATFORM(MAC) 96 _sharingServicePickerForMenu = adoptNS([[NSSharingServicePicker alloc] initWithItems:shareDataArray.get()]); 97 _sharingServicePickerForMenu.get().delegate = self; 98 _completionHandler = WTFMove(completionHandler); 99 100 NSPoint location = [NSEvent mouseLocation]; 101 NSRect mouseLocationRect = NSMakeRect(location.x, location.y, 1.0, 1.0); 102 NSRect mouseLocationInWindow = [[_view window] convertRectFromScreen:mouseLocationRect]; 103 NSRect mouseLocationInView = [_view convertRect:mouseLocationInWindow fromView:nil]; 104 [_sharingServicePickerForMenu showRelativeToRect:mouseLocationInView ofView:_view.getAutoreleased() preferredEdge:NSMinYEdge]; 105 #else 73 106 auto shareSheetController = adoptNS([[UIActivityViewController alloc] initWithActivityItems:shareDataArray.get() applicationActivities:nil]); 74 107 … … 81 114 _shareSheetViewController = WTFMove(shareSheetController); 82 115 [self _presentFullscreenViewController:_shareSheetViewController.get() animated:YES]; 116 #endif 83 117 } 84 118 119 #if PLATFORM(MAC) 120 - (void)sharingServicePicker:(NSSharingServicePicker *)sharingServicePicker didChooseSharingService:(nullable NSSharingService *)service 121 { 122 self->_completionHandler(!service); 123 [self _dispatchDidDismiss]; 124 } 125 126 #endif 85 127 - (void)_dispatchDidDismiss 86 128 { … … 91 133 - (void)_cancel 92 134 { 135 #if PLATFORM(IOS) 93 136 [self _dispatchDidDismiss]; 137 #endif 94 138 } 95 139 96 140 - (void)dismiss 97 141 { 142 #if PLATFORM(IOS) 98 143 [[UIViewController _viewControllerForFullScreenPresentationFromView:_view.getAutoreleased()] dismissViewControllerAnimated:_shouldDismissWithAnimation completion:nil]; 99 144 _presentationViewController = nil; 100 145 101 146 [self _cancel]; 147 #endif 102 148 } 149 150 #if PLATFORM(IOS) 103 151 104 152 - (void)_dismissDisplayAnimated:(BOOL)animated … … 106 154 if (_presentationViewController) { 107 155 UIViewController *currentPresentedViewController = [_presentationViewController presentedViewController]; 108 if (currentPresentedViewController == self) {156 if (currentPresentedViewController == _shareSheetViewController) { 109 157 [currentPresentedViewController dismissViewControllerAnimated:animated completion:^{ 110 158 _presentationViewController = nil; … … 119 167 [_presentationViewController presentViewController:viewController animated:animated completion:nil]; 120 168 } 169 #endif 121 170 122 171 - (void)invokeShareSheetWithResolution:(BOOL)resolved 123 172 { 173 #if PLATFORM(IOS) 124 174 _shouldDismissWithAnimation = NO; 125 175 _shareSheetViewController.get().completionWithItemsHandler(nil, resolved, nil, nil); 176 #else 177 _completionHandler(resolved); 178 #endif 126 179 } 127 180 128 181 @end 129 #endif // PLATFORM(IOS) &&!PLATFORM(WATCHOS) && !PLATFORM(APPLETV)182 #endif // !PLATFORM(WATCHOS) && !PLATFORM(APPLETV) -
trunk/Source/WebKit/UIProcess/Cocoa/WebViewImpl.h
r235914 r235925 60 60 OBJC_CLASS _WKThumbnailView; 61 61 62 #if WK_API_ENABLED 63 OBJC_CLASS WKShareSheet; 64 #endif 65 62 66 #if HAVE(TOUCH_BAR) 63 67 OBJC_CLASS NSCandidateListTouchBarItem; … … 74 78 class Object; 75 79 class PageConfiguration; 80 } 81 82 namespace WebCore { 83 struct ShareDataWithParsedURL; 76 84 } 77 85 … … 314 322 void centerSelectionInVisibleArea(); 315 323 void selectionDidChange(); 324 316 325 void didBecomeEditable(); 317 326 void updateFontPanelIfNeeded(); … … 413 422 void setInspectorAttachmentView(NSView *); 414 423 NSView *inspectorAttachmentView(); 424 425 void showShareSheet(const WebCore::ShareDataWithParsedURL&, WTF::CompletionHandler<void(bool)>&&, WKWebView *); 426 void shareSheetDidDismiss(WKShareSheet *); 415 427 416 428 _WKRemoteObjectRegistry *remoteObjectRegistry(); … … 688 700 RetainPtr<WKFullScreenWindowController> m_fullScreenWindowController; 689 701 #endif 702 703 #if WK_API_ENABLED 704 RetainPtr<WKShareSheet> _shareSheet; 705 #endif 690 706 691 707 RetainPtr<WKWindowVisibilityObserver> m_windowVisibilityObserver; -
trunk/Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm
r235914 r235925 2727 2727 } 2728 2728 2729 #if WK_API_ENABLED 2730 void WebViewImpl::showShareSheet(const WebCore::ShareDataWithParsedURL& data, WTF::CompletionHandler<void(bool)>&& completionHandler, WKWebView *view) 2731 { 2732 ASSERT(!_shareSheet); 2733 if (_shareSheet) 2734 return; 2735 2736 ASSERT([view respondsToSelector:@selector(shareSheetDidDismiss:)]); 2737 _shareSheet = adoptNS([[WKShareSheet alloc] initWithView:view]); 2738 [_shareSheet setDelegate:view]; 2739 2740 [_shareSheet presentWithParameters:data completionHandler:WTFMove(completionHandler)]; 2741 } 2742 2743 void WebViewImpl::shareSheetDidDismiss(WKShareSheet *shareSheet) 2744 { 2745 ASSERT(_shareSheet == shareSheet); 2746 2747 [_shareSheet setDelegate:nil]; 2748 _shareSheet = nil; 2749 } 2750 #endif 2751 2729 2752 void WebViewImpl::didBecomeEditable() 2730 2753 { -
trunk/Source/WebKit/UIProcess/mac/PageClientImplMac.h
r235365 r235925 104 104 void notifyInputContextAboutDiscardedComposition() override; 105 105 void selectionDidChange() override; 106 106 107 #if WK_API_ENABLED 108 bool showShareSheet(const WebCore::ShareDataWithParsedURL&, WTF::CompletionHandler<void(bool)>&&) override; 109 #endif 110 107 111 WebCore::FloatRect convertToDeviceSpace(const WebCore::FloatRect&) override; 108 112 WebCore::FloatRect convertToUserSpace(const WebCore::FloatRect&) override; -
trunk/Source/WebKit/UIProcess/mac/PageClientImplMac.mm
r235365 r235925 541 541 m_impl->selectionDidChange(); 542 542 } 543 #if WK_API_ENABLED 544 bool PageClientImpl::showShareSheet(const ShareDataWithParsedURL& shareData, WTF::CompletionHandler<void(bool)>&& completionHandler) 545 { 546 m_impl->showShareSheet(shareData, WTFMove(completionHandler), m_webView); 547 return true; 548 } 549 #endif 543 550 544 551 void PageClientImpl::wheelEventWasNotHandledByWebCore(const NativeWebWheelEvent& event) -
trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj
r235921 r235925 2421 2421 1CC417C912C00CCA002BE67B /* TextCheckerCompletion.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TextCheckerCompletion.h; sourceTree = "<group>"; }; 2422 2422 1D67B338212E1F6100FAA786 /* ShareSheetCallbackID.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ShareSheetCallbackID.h; sourceTree = "<group>"; }; 2423 1DBBB061211CC3CB00502ECC /* WKShareSheet.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = WKShareSheet.mm; path = ios/forms/WKShareSheet.mm; sourceTree = "<group>"; };2424 1DE0D095211CC21300439B5F /* WKShareSheet.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WKShareSheet.h; path = ios/forms/WKShareSheet.h; sourceTree = "<group>"; };2423 1DBBB061211CC3CB00502ECC /* WKShareSheet.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WKShareSheet.mm; sourceTree = "<group>"; }; 2424 1DE0D095211CC21300439B5F /* WKShareSheet.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKShareSheet.h; sourceTree = "<group>"; }; 2425 2425 1F0181691858DC1500F92884 /* WKWebProcessPlugInFrame.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKWebProcessPlugInFrame.h; sourceTree = "<group>"; }; 2426 2426 1F01816A1858DC1500F92884 /* WKWebProcessPlugInFrame.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WKWebProcessPlugInFrame.mm; sourceTree = "<group>"; }; … … 5295 5295 1AD01BCB1905D54900C9C45F /* WKReloadFrameErrorRecoveryAttempter.h */, 5296 5296 1AD01BCA1905D54900C9C45F /* WKReloadFrameErrorRecoveryAttempter.mm */, 5297 1DE0D095211CC21300439B5F /* WKShareSheet.h */, 5298 1DBBB061211CC3CB00502ECC /* WKShareSheet.mm */, 5297 5299 2D7AAFD218C8640600A7ACD4 /* WKWebViewContentProvider.h */, 5298 5300 2DC6D9C118C44A610043BAD4 /* WKWebViewContentProviderRegistry.h */, … … 8508 8510 F4F59AD42065A5CA006CAA46 /* WKSelectMenuListViewController.h */, 8509 8511 F4F59AD32065A5C9006CAA46 /* WKSelectMenuListViewController.mm */, 8510 1DE0D095211CC21300439B5F /* WKShareSheet.h */,8511 1DBBB061211CC3CB00502ECC /* WKShareSheet.mm */,8512 8512 F4D5F519206087A00038BBA8 /* WKTextInputListViewController.h */, 8513 8513 F4D5F51A206087A10038BBA8 /* WKTextInputListViewController.mm */,
Note: See TracChangeset
for help on using the changeset viewer.