Title: [290173] trunk/Source/WebKit
Revision
290173
Author
[email protected]
Date
2022-02-18 14:40:32 -0800 (Fri, 18 Feb 2022)

Log Message

Use async NSSharingServicePicker menu if available
https://bugs.webkit.org/show_bug.cgi?id=236823
<rdar://problem/88858606>

Reviewed by Dean Jackson.

* UIProcess/Cocoa/WKShareSheet.h:
* UIProcess/Cocoa/WKShareSheet.mm:
(-[WKShareSheet presentWithShareDataArray:inRect:]):
(-[WKShareSheet canShowPickerAsync:]):
(-[WKShareSheet showPickerAsync:completionHandler:]):

Modified Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (290172 => 290173)


--- trunk/Source/WebKit/ChangeLog	2022-02-18 22:37:33 UTC (rev 290172)
+++ trunk/Source/WebKit/ChangeLog	2022-02-18 22:40:32 UTC (rev 290173)
@@ -1,3 +1,17 @@
+2022-02-18  Kate Cheney  <[email protected]>
+
+        Use async NSSharingServicePicker menu if available
+        https://bugs.webkit.org/show_bug.cgi?id=236823
+        <rdar://problem/88858606>
+
+        Reviewed by Dean Jackson.
+
+        * UIProcess/Cocoa/WKShareSheet.h:
+        * UIProcess/Cocoa/WKShareSheet.mm:
+        (-[WKShareSheet presentWithShareDataArray:inRect:]):
+        (-[WKShareSheet canShowPickerAsync:]):
+        (-[WKShareSheet showPickerAsync:completionHandler:]):
+
 2022-02-18  J Pascoe  <[email protected]>
 
         [WebAuthn] Add credentialID to _WKWebAuthenticationAssertionResponse and userHandle in getAllLocalAuthenticatorCredentials

Modified: trunk/Source/WebKit/UIProcess/Cocoa/WKShareSheet.h (290172 => 290173)


--- trunk/Source/WebKit/UIProcess/Cocoa/WKShareSheet.h	2022-02-18 22:37:33 UTC (rev 290172)
+++ trunk/Source/WebKit/UIProcess/Cocoa/WKShareSheet.h	2022-02-18 22:40:32 UTC (rev 290173)
@@ -41,6 +41,11 @@
 - (void)presentWithParameters:(const WebCore::ShareDataWithParsedURL&)data inRect:(std::optional<WebCore::FloatRect>)rect completionHandler:(WTF::CompletionHandler<void(bool)>&&)completionHandler;
 - (void)dismiss;
 
+#if PLATFORM(MAC)
+- (BOOL)canShowPickerAsync:(NSSharingServicePicker *)picker;
+- (void)showPickerAsync:(NSSharingServicePicker *)picker showRelativeToRect:(NSRect)presentationRect ofView:(WKWebView *)webView completion:(void (^)(void))completionHandler;
+#endif
+
 @property (nonatomic, weak) id <WKShareSheetDelegate> delegate;
 @end
 

Modified: trunk/Source/WebKit/UIProcess/Cocoa/WKShareSheet.mm (290172 => 290173)


--- trunk/Source/WebKit/UIProcess/Cocoa/WKShareSheet.mm	2022-02-18 22:37:33 UTC (rev 290172)
+++ trunk/Source/WebKit/UIProcess/Cocoa/WKShareSheet.mm	2022-02-18 22:40:32 UTC (rev 290173)
@@ -46,6 +46,10 @@
 #import <pal/spi/mac/NSSharingServicePickerSPI.h>
 #endif
 
+#if USE(APPLE_INTERNAL_SDK) && PLATFORM(MAC)
+#import <WebKitAdditions/WKShareSheetAdditionsBefore.mm>
+#endif
+
 #if PLATFORM(MAC)
 @interface WKShareSheet () <NSSharingServiceDelegate, NSSharingServicePickerDelegate>
 @end
@@ -178,7 +182,11 @@
         NSRect mouseLocationInWindow = [webView.window convertRectFromScreen:mouseLocationRect];
         presentationRect = [webView convertRect:mouseLocationInWindow fromView:nil];
     }
-    [_sharingServicePicker showRelativeToRect:presentationRect ofView:webView preferredEdge:NSMinYEdge];
+
+    if ([self canShowPickerAsync:_sharingServicePicker.get()])
+        [self showPickerAsync:_sharingServicePicker.get() showRelativeToRect:presentationRect ofView:webView completion:^{ }];
+    else
+        [_sharingServicePicker showRelativeToRect:presentationRect ofView:webView preferredEdge:NSMinYEdge];
 #else
     _shareSheetViewController = adoptNS([[UIActivityViewController alloc] initWithActivityItems:sharingItems applicationActivities:nil]);
 
@@ -362,6 +370,21 @@
     return fileURL;
 }
 
+#if PLATFORM(MAC)
+#if USE(APPLE_INTERNAL_SDK)
+#import <WebKitAdditions/WKShareSheetAdditions.mm>
+#else
+- (BOOL)canShowPickerAsync:(NSSharingServicePicker *)picker
+{
+    return false;
+}
+- (void)showPickerAsync:(NSSharingServicePicker *)picker showRelativeToRect:(NSRect)presentationRect ofView:(WKWebView *)webView completion:(void (^)(void))completionHandler
+{
+
+}
+#endif
+#endif
+
 @end
 
 #endif // PLATFORM(COCOA) && !PLATFORM(WATCHOS) && !PLATFORM(APPLETV)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to