RESOLVED FIXED 189443
Implement the Web Share API for mac
https://bugs.webkit.org/show_bug.cgi?id=189443
Summary Implement the Web Share API for mac
Olivia Barnett
Reported 2018-09-07 17:12:52 PDT
Implement the Web Share API for mac
Attachments
Patch (22.84 KB, patch)
2018-09-07 17:17 PDT, Olivia Barnett
no flags
Archive of layout-test-results from ews107 for mac-sierra-wk2 (2.80 MB, application/zip)
2018-09-07 18:33 PDT, EWS Watchlist
no flags
Patch (40.21 KB, patch)
2018-09-10 12:47 PDT, Olivia Barnett
no flags
Archive of layout-test-results from ews104 for mac-sierra-wk2 (2.86 MB, application/zip)
2018-09-10 14:03 PDT, EWS Watchlist
no flags
Patch (37.68 KB, patch)
2018-09-10 14:28 PDT, Olivia Barnett
no flags
Archive of layout-test-results from ews106 for mac-sierra-wk2 (2.80 MB, application/zip)
2018-09-10 15:45 PDT, EWS Watchlist
no flags
Patch (38.11 KB, patch)
2018-09-10 16:01 PDT, Olivia Barnett
no flags
Archive of layout-test-results from ews107 for mac-sierra-wk2 (3.24 MB, application/zip)
2018-09-10 18:01 PDT, EWS Watchlist
no flags
Patch (37.29 KB, patch)
2018-09-11 11:17 PDT, Olivia Barnett
no flags
Patch (37.38 KB, patch)
2018-09-11 14:16 PDT, Olivia Barnett
no flags
Patch (37.44 KB, patch)
2018-09-11 15:08 PDT, Olivia Barnett
no flags
Olivia Barnett
Comment 1 2018-09-07 17:17:06 PDT
Tim Horton
Comment 2 2018-09-07 18:01:35 PDT
Comment on attachment 349217 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=349217&action=review > Source/WebKit/Shared/WebPreferencesDefaultValues.h:175 > -#if PLATFORM(IOS) && !PLATFORM(WATCHOS) && !PLATFORM(APPLETV) > +#if !PLATFORM(WATCHOS) && !PLATFORM(APPLETV) You can't do this, because there are platforms other than ours. You can instead change it to: #if PLATFORM(COCOA) && !PLATFORM(WATCHOS) && !PLATFORM(APPLETV) which will be Mac and iOS but not watch/GTK/etc. > Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm:206 > +@interface WKWebView () <NSFilePromiseProviderDelegate, NSDraggingSource, WKShareSheetDelegate> This isn't about ENABLE(DRAG_SUPPORT), so it doesn't go here. Stick it up above with WebViewImplDelegate. ACTUALLY you don't need this here at all because it's in WKWebViewInternal.h, right? > Source/WebKit/UIProcess/Cocoa/WebViewImpl.h:617 > + RetainPtr<WKShareSheet> _shareSheet; This is a member variable, it doesn't belong amongst functions. Move it down further. > Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm:2721 > + > + _shareSheet = adoptNS([[WKShareSheet alloc] initWithView:(NSView<WKShareSheetDelegate> *)view]); You should assert that the view conforms to WKShareSheetDelegate before this nasty cast. Also, you only need the cast when setting the delegate; initWithView doesn't care about protocol conformance. > Source/WebKit/UIProcess/ios/forms/WKShareSheet.h:26 > -#if PLATFORM(IOS) && !PLATFORM(WATCHOS) && !PLATFORM(APPLETV) > +#if !PLATFORM(WATCHOS) && !PLATFORM(APPLETV) Ditto the thing I said before about PLATFORM(COCOA) > Source/WebKit/UIProcess/ios/forms/WKShareSheet.h:43 > +@interface WKShareSheet : NSObject<NSSharingServicePickerDelegate> We usually put spaces before the protocol conformance list (NSObject <NSSharingServicePickerDelegate>) > Source/WebKit/UIProcess/ios/forms/WKShareSheet.mm:-29 > -#if PLATFORM(IOS) && !PLATFORM(WATCHOS) && !PLATFORM(APPLETV) PLATFORM(COCOA) thing > Source/WebKit/UIProcess/ios/forms/WKShareSheet.mm:32 > +#if PLATFORM(IOS) > #import "UIKitSPI.h" > +#endif Usually platform-specific includes go in a section separated by newlines below the others > Source/WebKit/UIProcess/ios/forms/WKShareSheet.mm:94 > + _sharingServicePickerForMenu = [[NSSharingServicePicker alloc] initWithItems:shareDataArray.get()]; You're missing an adoptNS here (this is initialized with a +1 reference count, and you're sticking it in a RetainPtr, which immediately retains it (to +2); it will never make it back to zero, so it will leak). > Source/WebKit/UIProcess/ios/forms/WKShareSheet.mm:98 > + NSRect mouseLocationRect = {[NSEvent mouseLocation], CGSizeMake(1.0, 1.0)}; Let's use NSMakeRect instead of weird curly braces. > Source/WebKit/UIProcess/ios/forms/WKShareSheet.mm:100 > + NSRect mouseLocationInView = [_view.getAutoreleased() convertRect:mouseLocationInWindow fromView:nil]; No need for the .getAutoreleased() > Source/WebKit/UIProcess/ios/forms/WKShareSheet.mm:118 > +/* Invoked when the user has selected a service and before it is executed. Service will be nil if the picker was dismissed. > + */ No need for this comment. > Source/WebKit/UIProcess/ios/forms/WKShareSheet.mm:170 > - (void)invokeShareSheetWithResolution:(BOOL)resolved How does your test work without this implemented? (I see below that it perhaps does not)
EWS Watchlist
Comment 3 2018-09-07 18:33:35 PDT
Comment on attachment 349217 [details] Patch Attachment 349217 [details] did not pass mac-wk2-ews (mac-wk2): Output: https://webkit-queues.webkit.org/results/9135262 New failing tests: fast/dom/navigator-detached-no-crash.html
EWS Watchlist
Comment 4 2018-09-07 18:33:36 PDT
Created attachment 349226 [details] Archive of layout-test-results from ews107 for mac-sierra-wk2 The attached test failures were seen while running run-webkit-tests on the mac-wk2-ews. Bot: ews107 Port: mac-sierra-wk2 Platform: Mac OS X 10.12.6
Wenson Hsieh
Comment 5 2018-09-07 23:14:09 PDT
Comment on attachment 349217 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=349217&action=review > Source/WebKit/UIProcess/ios/forms/WKShareSheet.mm:26 > #import "config.h" This file is currently in Source/WebKit/UIProcess/ios; perhaps it should go in the Cocoa folder instead? > Source/WebKit/UIProcess/ios/forms/WKShareSheet.mm:69 > _shouldDismissWithAnimation = YES; Hm...I'd think this should be useful on macOS as well, once we get the test working.
Olivia Barnett
Comment 6 2018-09-10 10:12:00 PDT
> > Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm:206 > > +@interface WKWebView () <NSFilePromiseProviderDelegate, NSDraggingSource, WKShareSheetDelegate> > > This isn't about ENABLE(DRAG_SUPPORT), so it doesn't go here. Stick it up > above with WebViewImplDelegate. > > ACTUALLY you don't need this here at all because it's in > WKWebViewInternal.h, right? Hmm, I don't see any reference to dragging in WKWebViewInternal.h actually
Tim Horton
Comment 7 2018-09-10 10:21:00 PDT
(In reply to Olivia Barnett from comment #6) > > > Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm:206 > > > +@interface WKWebView () <NSFilePromiseProviderDelegate, NSDraggingSource, WKShareSheetDelegate> > > > > This isn't about ENABLE(DRAG_SUPPORT), so it doesn't go here. Stick it up > > above with WebViewImplDelegate. > > > > ACTUALLY you don't need this here at all because it's in > > WKWebViewInternal.h, right? > > Hmm, I don't see any reference to dragging in WKWebViewInternal.h actually I meant your thing, not the DRAG_SUPPORT thing.
Tim Horton
Comment 8 2018-09-10 10:21:19 PDT
Comment on attachment 349217 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=349217&action=review > Source/WebKit/UIProcess/API/Cocoa/WKWebViewInternal.h:51 > +#if PLATFORM(MAC) This one!
Olivia Barnett
Comment 9 2018-09-10 12:47:14 PDT
Tim Horton
Comment 10 2018-09-10 13:49:27 PDT
Comment on attachment 349322 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=349322&action=review > Source/WebKit/UIProcess/mac/PageClientImplMac.h:106 > + bool showShareSheet(const ShareDataWithParsedURL&, WTF::CompletionHandler<void(bool)>&&) override; /Volumes/Data/EWS/WebKit/Source/WebKit/UIProcess/mac/PageClientImplMac.h:106:31: error: unknown type name 'ShareDataWithParsedURL'; did you mean 'WebCore::ShareDataWithParsedURL'? bool showShareSheet(const ShareDataWithParsedURL&, WTF::CompletionHandler<void(bool)>&&) override; ^~~~~~~~~~~~~~~~~~~~~~ WebCore::ShareDataWithParsedURL
Tim Horton
Comment 11 2018-09-10 13:55:38 PDT
Comment on attachment 349322 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=349322&action=review > Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm:-204 > -#if PLATFORM(MAC) && ENABLE(DRAG_SUPPORT) I don't think you meant to remove this existing code. > Source/WebKit/UIProcess/Cocoa/WKShareSheet.h:31 > +#if PLATFORM(IOS) > +#import <UIKit/UIKit.h> > +#endif > + Should go below the other headers. > Source/WebKit/UIProcess/Cocoa/WKShareSheet.mm:43 > +#if PLATFORM(MAC) the #if here could go just around the members, not around the @implementation or curly braces > Source/WebKit/UIProcess/ios/WKContentViewInteraction.h:30 > +#if PLATFORM(COCOA) && !PLATFORM(WATCHOS) && !PLATFORM(APPLETV) Not needed here, this file is already PLATFORM(IOS) only. (you still need the existing checks, but don't need to add a cocoa check). > Source/WebKit/UIProcess/ios/WKContentViewInteraction.h:194 > +#if PLATFORM(COCOA) && !PLATFORM(WATCHOS) && !PLATFORM(APPLETV) Not needed here, this file is already PLATFORM(IOS) only. (you still need the existing checks, but don't need to add a cocoa check). > Source/WebKit/UIProcess/ios/WKContentViewInteraction.h:286 > +#if PLATFORM(COCOA) && !PLATFORM(WATCHOS) && !PLATFORM(APPLETV) Not needed here, this file is already PLATFORM(IOS) only. (you still need the existing checks, but don't need to add a cocoa check). > Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm:793 > +#if PLATFORM(COCOA) && !PLATFORM(WATCHOS) && !PLATFORM(APPLETV) Not needed here, this file is already PLATFORM(IOS) only. (you still need the existing checks, but don't need to add a cocoa check). > Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm:4739 > +#if PLATFORM(COCOA) && !PLATFORM(WATCHOS) && !PLATFORM(APPLETV) Not needed here, this file is already PLATFORM(IOS) only. (you still need the existing checks, but don't need to add a cocoa check). > Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm:4751 > +#if PLATFORM(COCOA) && !PLATFORM(WATCHOS) && !PLATFORM(APPLETV) Not needed here, this file is already PLATFORM(IOS) only. (you still need the existing checks, but don't need to add a cocoa check). > Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm:5920 > +#if PLATFORM(COCOA) && !PLATFORM(WATCHOS) && !PLATFORM(APPLETV) Not needed here, this file is already PLATFORM(IOS) only. (you still need the existing checks, but don't need to add a cocoa check).
EWS Watchlist
Comment 12 2018-09-10 14:03:56 PDT
Comment on attachment 349322 [details] Patch Attachment 349322 [details] did not pass mac-wk2-ews (mac-wk2): Output: https://webkit-queues.webkit.org/results/9163655 New failing tests: fast/dom/navigator-detached-no-crash.html
EWS Watchlist
Comment 13 2018-09-10 14:03:58 PDT
Created attachment 349326 [details] Archive of layout-test-results from ews104 for mac-sierra-wk2 The attached test failures were seen while running run-webkit-tests on the mac-wk2-ews. Bot: ews104 Port: mac-sierra-wk2 Platform: Mac OS X 10.12.6
Tim Horton
Comment 14 2018-09-10 14:09:36 PDT
(In reply to Build Bot from comment #13) > Created attachment 349326 [details] > Archive of layout-test-results from ews104 for mac-sierra-wk2 > > The attached test failures were seen while running run-webkit-tests on the > mac-wk2-ews. > Bot: ews104 Port: mac-sierra-wk2 Platform: Mac OS X 10.12.6 This is happening because of the existence of navigator-detached-no-crash-expected.txt in platform/mac-highsierra/fast/dom, which overrides your mac-wk2 result on High Sierra and earlier. I would just go into that file and add the share() lines in the right places :)
Olivia Barnett
Comment 15 2018-09-10 14:28:35 PDT
Tim Horton
Comment 16 2018-09-10 14:44:28 PDT
Comment on attachment 349329 [details] Patch Let's wait and see what EWS says about the tests before landing
EWS Watchlist
Comment 17 2018-09-10 15:45:31 PDT
Comment on attachment 349329 [details] Patch Attachment 349329 [details] did not pass mac-wk2-ews (mac-wk2): Output: https://webkit-queues.webkit.org/results/9164850 New failing tests: fast/dom/navigator-detached-no-crash.html
EWS Watchlist
Comment 18 2018-09-10 15:45:33 PDT
Created attachment 349341 [details] Archive of layout-test-results from ews106 for mac-sierra-wk2 The attached test failures were seen while running run-webkit-tests on the mac-wk2-ews. Bot: ews106 Port: mac-sierra-wk2 Platform: Mac OS X 10.12.6
Olivia Barnett
Comment 19 2018-09-10 16:01:17 PDT
EWS Watchlist
Comment 20 2018-09-10 18:01:09 PDT
Comment on attachment 349348 [details] Patch Attachment 349348 [details] did not pass mac-wk2-ews (mac-wk2): Output: https://webkit-queues.webkit.org/results/9166851 New failing tests: fast/dom/navigator-detached-no-crash.html
EWS Watchlist
Comment 21 2018-09-10 18:01:11 PDT
Created attachment 349367 [details] Archive of layout-test-results from ews107 for mac-sierra-wk2 The attached test failures were seen while running run-webkit-tests on the mac-wk2-ews. Bot: ews107 Port: mac-sierra-wk2 Platform: Mac OS X 10.12.6
Tim Horton
Comment 22 2018-09-10 21:32:57 PDT
Comment on attachment 349348 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=349348&action=review ALSO it looks like you missed a trailing space in the new expected test result :P (or your editor deleted it on you!) > Source/WebKit/ChangeLog:2 > + To fix the 32-bit build, let's just make this feature modern-API only (the other option is to make it legacy-runtime-compatible by moving the ivar definitions to the header, but that is ugly and less forward-looking), by doing the following: > Source/WebKit/UIProcess/API/mac/WKView.mm:1334 > +- (void)shareSheetDidDismiss:(WKShareSheet *)shareSheet Get rid of this. > Source/WebKit/UIProcess/Cocoa/WKShareSheet.h:26 > +#if PLATFORM(COCOA) && !PLATFORM(WATCHOS) && !PLATFORM(APPLETV) Add a && WK_API_ENABLED here, so it only builds in places where WKWebView exists > Source/WebKit/UIProcess/Cocoa/WKShareSheet.h:44 > +- (instancetype)initWithView:(NSView *)view; Make this take a WKWebView instead. > Source/WebKit/UIProcess/Cocoa/WKShareSheet.mm:29 > +#if PLATFORM(COCOA) && !PLATFORM(WATCHOS) && !PLATFORM(APPLETV) WK_API_ENABLED > Source/WebKit/UIProcess/Cocoa/WKShareSheet.mm:45 > + WeakObjCPtr<NSView> _view; WKWebView (and in various other places here). > Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm:2730 > +void WebViewImpl::showShareSheet(const WebCore::ShareDataWithParsedURL& data, WTF::CompletionHandler<void(bool)>&& completionHandler, NSView *view) WKWebView. > Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm:2738 > + [_shareSheet setDelegate:(NSView<WKShareSheetDelegate> *)view]; No more need for this ugly cast! > Source/WebKit/UIProcess/mac/PageClientImplMac.mm:546 > + m_impl->showShareSheet(shareData, WTFMove(completionHandler), m_view); Pass m_webView instead
Olivia Barnett
Comment 23 2018-09-11 11:17:19 PDT
Tim Horton
Comment 24 2018-09-11 11:19:41 PDT
Comment on attachment 349416 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=349416&action=review > Source/WebKit/UIProcess/Cocoa/WebViewImpl.h:657 > + RetainPtr<WKShareSheet> _shareSheet; Probably need some WK_API_ENABLED in this file > Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm:2730 > +void WebViewImpl::showShareSheet(const WebCore::ShareDataWithParsedURL& data, WTF::CompletionHandler<void(bool)>&& completionHandler, WKWebView *view) And here.
Olivia Barnett
Comment 25 2018-09-11 14:16:22 PDT
Olivia Barnett
Comment 26 2018-09-11 15:08:18 PDT
WebKit Commit Bot
Comment 27 2018-09-11 17:58:06 PDT
Comment on attachment 349469 [details] Patch Clearing flags on attachment: 349469 Committed r235925: <https://trac.webkit.org/changeset/235925>
WebKit Commit Bot
Comment 28 2018-09-11 17:58:08 PDT
All reviewed patches have been landed. Closing bug.
Radar WebKit Bug Importer
Comment 29 2018-09-11 17:59:35 PDT
Truitt Savell
Comment 30 2018-09-13 09:19:18 PDT
Looks like after https://trac.webkit.org/changeset/235925/webkit imported/w3c/web-platform-tests/web-share/idlharness.https.html has started failing constantly. History: https://webkit-test-results.webkit.org/dashboards/flakiness_dashboard.html#showAllRuns=true&tests=imported%2Fw3c%2Fweb-platform-tests%2Fweb-share%2Fidlharness.https.html Diff: --- /Volumes/Data/slave/highsierra-release-tests-wk2/build/layout-test-results/imported/w3c/web-platform-tests/web-share/idlharness.https-expected.txt +++ /Volumes/Data/slave/highsierra-release-tests-wk2/build/layout-test-results/imported/w3c/web-platform-tests/web-share/idlharness.https-actual.txt @@ -1,7 +1,7 @@ PASS Test driver +PASS Partial interface Navigator: original interface defined PASS Navigator interface: operation share(ShareData) -PASS Unscopable handled correctly for share(ShareData) on Navigator PASS Navigator interface: navigator must inherit property "share(ShareData)" with the proper type PASS Navigator interface: calling share(ShareData) on navigator with too few arguments must throw TypeError Is this possibly just a rebaseline?
Ryan Haddad
Comment 31 2018-09-13 11:08:03 PDT
(In reply to Truitt Savell from comment #30) > Is this possibly just a rebaseline? I went ahead and rebaselined it in https://trac.webkit.org/changeset/235980/webkit
Note You need to log in before you can comment on or make changes to this bug.