Title: [250801] trunk/Source/WebKit
- Revision
- 250801
- Author
- megan_gard...@apple.com
- Date
- 2019-10-07 15:53:26 -0700 (Mon, 07 Oct 2019)
Log Message
Switch to WKShareSheet for WKPDFView
https://bugs.webkit.org/show_bug.cgi?id=202338
Reviewed by Tim Horton.
Switch to WKShareSheet from the share sheet in UIWKSelectionAssistant, since this is the only instance
of UIWKSelectionAssistant any more. This will keep all our share sheet code together, and allow
us to eliminate this class that will be completely unused with this change.
* Platform/spi/ios/UIKitSPI.h:
* UIProcess/ios/WKPDFView.h:
* UIProcess/ios/WKPDFView.mm:
(-[WKPDFView dealloc]):
(-[WKPDFView actionSheetAssistant:shareElementWithURL:rect:]):
(-[WKPDFView shareSheetDidDismiss:]):
Modified Paths
Diff
Modified: trunk/Source/WebKit/ChangeLog (250800 => 250801)
--- trunk/Source/WebKit/ChangeLog 2019-10-07 22:36:47 UTC (rev 250800)
+++ trunk/Source/WebKit/ChangeLog 2019-10-07 22:53:26 UTC (rev 250801)
@@ -1,3 +1,21 @@
+2019-10-07 Megan Gardner <megan_gard...@apple.com>
+
+ Switch to WKShareSheet for WKPDFView
+ https://bugs.webkit.org/show_bug.cgi?id=202338
+
+ Reviewed by Tim Horton.
+
+ Switch to WKShareSheet from the share sheet in UIWKSelectionAssistant, since this is the only instance
+ of UIWKSelectionAssistant any more. This will keep all our share sheet code together, and allow
+ us to eliminate this class that will be completely unused with this change.
+
+ * Platform/spi/ios/UIKitSPI.h:
+ * UIProcess/ios/WKPDFView.h:
+ * UIProcess/ios/WKPDFView.mm:
+ (-[WKPDFView dealloc]):
+ (-[WKPDFView actionSheetAssistant:shareElementWithURL:rect:]):
+ (-[WKPDFView shareSheetDidDismiss:]):
+
2019-10-07 Per Arne Vollan <pvol...@apple.com>
[macOS] Layering violation in AuxiliaryProcessProxy::didFinishLaunching
Modified: trunk/Source/WebKit/Platform/spi/ios/UIKitSPI.h (250800 => 250801)
--- trunk/Source/WebKit/Platform/spi/ios/UIKitSPI.h 2019-10-07 22:36:47 UTC (rev 250800)
+++ trunk/Source/WebKit/Platform/spi/ios/UIKitSPI.h 2019-10-07 22:53:26 UTC (rev 250801)
@@ -69,7 +69,6 @@
#import <UIKit/UIViewController_ViewService.h>
#import <UIKit/UIView_Private.h>
#import <UIKit/UIVisualEffect_Private.h>
-#import <UIKit/UIWKSelectionAssistant.h>
#import <UIKit/UIWKTextInteractionAssistant.h>
#import <UIKit/UIWebBrowserView.h>
#import <UIKit/UIWebDocumentView.h>
@@ -591,14 +590,6 @@
@interface UIWebSelectionAssistant : NSObject
@end
-@interface UIWKSelectionAssistant : UIWebSelectionAssistant
-@end
-
-@interface UIWKSelectionAssistant ()
-- (id)initWithView:(UIView *)view;
-- (void)showShareSheetFor:(NSString *)selectedTerm fromRect:(CGRect)presentationRect;
-@end
-
@interface UIWKAutocorrectionRects : NSObject
@end
Modified: trunk/Source/WebKit/UIProcess/ios/WKPDFView.h (250800 => 250801)
--- trunk/Source/WebKit/UIProcess/ios/WKPDFView.h 2019-10-07 22:36:47 UTC (rev 250800)
+++ trunk/Source/WebKit/UIProcess/ios/WKPDFView.h 2019-10-07 22:53:26 UTC (rev 250801)
@@ -26,9 +26,10 @@
#if ENABLE(WKPDFVIEW)
#import "WKApplicationStateTrackingView.h"
+#import "WKShareSheet.h"
#import "WKWebViewContentProvider.h"
-@interface WKPDFView : WKApplicationStateTrackingView <WKWebViewContentProvider>
+@interface WKPDFView : WKApplicationStateTrackingView <WKShareSheetDelegate, WKWebViewContentProvider>
@end
Modified: trunk/Source/WebKit/UIProcess/ios/WKPDFView.mm (250800 => 250801)
--- trunk/Source/WebKit/UIProcess/ios/WKPDFView.mm 2019-10-07 22:36:47 UTC (rev 250800)
+++ trunk/Source/WebKit/UIProcess/ios/WKPDFView.mm 2019-10-07 22:53:26 UTC (rev 250801)
@@ -41,6 +41,7 @@
#import "_WKWebViewPrintFormatterInternal.h"
#import <MobileCoreServices/MobileCoreServices.h>
#import <WebCore/DataDetection.h>
+#import <WebCore/ShareData.h>
#import <wtf/BlockPtr.h>
#import <wtf/MainThread.h>
#import <wtf/RetainPtr.h>
@@ -70,10 +71,16 @@
RetainPtr<NSString> _suggestedFilename;
WeakObjCPtr<WKWebView> _webView;
RetainPtr<WKKeyboardScrollViewAnimator> _keyboardScrollingAnimator;
+ RetainPtr<WKShareSheet> _shareSheet;
}
- (void)dealloc
{
+ if (_shareSheet) {
+ [_shareSheet setDelegate:nil];
+ [_shareSheet dismiss];
+ _shareSheet = nil;
+ }
[_actionSheetAssistant cleanupSheet];
[[_hostViewController view] removeFromSuperview];
[_pageNumberIndicator removeFromSuperview];
@@ -543,11 +550,28 @@
- (void)actionSheetAssistant:(WKActionSheetAssistant *)assistant shareElementWithURL:(NSURL *)url rect:(CGRect)boundingRect
{
- // FIXME: We should use WKShareSheet instead of UIWKSelectionAssistant for this.
- auto selectionAssistant = adoptNS([[UIWKSelectionAssistant alloc] initWithView:[_hostViewController view]]);
- [selectionAssistant showShareSheetFor:WTF::userVisibleString(url) fromRect:boundingRect];
+ WKWebView *webView = _webView.getAutoreleased();
+ if (!webView)
+ return;
+
+ WebCore::ShareDataWithParsedURL shareData;
+ shareData.url = { url };
+
+ [_shareSheet dismiss];
+
+ _shareSheet = adoptNS([[WKShareSheet alloc] initWithView:webView]);
+ [_shareSheet setDelegate:self];
+ [_shareSheet presentWithParameters:shareData inRect: { [[_hostViewController view] convertRect:boundingRect toView:webView] } completionHandler:[] (bool success) { }];
}
+- (void)shareSheetDidDismiss:(WKShareSheet *)shareSheet
+{
+ ASSERT(_shareSheet == shareSheet);
+
+ [_shareSheet setDelegate:nil];
+ _shareSheet = nil;
+}
+
#if HAVE(APP_LINKS)
- (BOOL)actionSheetAssistant:(WKActionSheetAssistant *)assistant shouldIncludeAppLinkActionsForElement:(_WKActivatedElementInfo *)element
{
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes