[iOS] Unable to present the share sheet after saving a PDF to Files.app
authoraestes@apple.com <aestes@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 7 Jun 2018 23:23:55 +0000 (23:23 +0000)
committeraestes@apple.com <aestes@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 7 Jun 2018 23:23:55 +0000 (23:23 +0000)
https://bugs.webkit.org/show_bug.cgi?id=186413
<rdar://problem/39937488>

Reviewed by Tim Horton.

WKApplicationStateTrackingView (WKPDFView's superclass) keeps track of whether
it's in a window so that it can suspend and resume the web process accordingly.
However, in WKPDFView's case, PDFKit's host view is in the window instead of
WKPDFView itself when a PDF is being displayed (WKPDFView is only in a window as a
placeholder while the PDF loads). Since WKApplicationStateTrackingView doesn't
think its in a window, it suspends the web process, preventing messages necessary
to displaying the share sheet from being delivered.

Fix this by teaching WKApplicationStateTrackingView to consider the in-windowness
of the proper content view. For all cases other than WKPDFView, this is |self|.
For WKPDFView, it is the PDFHostViewController's root view if it exists, otherwise
it's |self|.

* UIProcess/ios/WKApplicationStateTrackingView.h:
* UIProcess/ios/WKApplicationStateTrackingView.mm:
(-[WKApplicationStateTrackingView willMoveToWindow:]):
(-[WKApplicationStateTrackingView didMoveToWindow]):
(-[WKApplicationStateTrackingView _contentView]):
* UIProcess/ios/WKPDFView.mm:
(-[WKPDFView _contentView]):
(-[WKPDFView web_contentView]):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@232607 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebKit/ChangeLog
Source/WebKit/UIProcess/ios/WKApplicationStateTrackingView.h
Source/WebKit/UIProcess/ios/WKApplicationStateTrackingView.mm
Source/WebKit/UIProcess/ios/WKPDFView.mm

index 087aa82..b5664c8 100644 (file)
@@ -1,3 +1,33 @@
+2018-06-07  Andy Estes  <aestes@apple.com>
+
+        [iOS] Unable to present the share sheet after saving a PDF to Files.app
+        https://bugs.webkit.org/show_bug.cgi?id=186413
+        <rdar://problem/39937488>
+
+        Reviewed by Tim Horton.
+
+        WKApplicationStateTrackingView (WKPDFView's superclass) keeps track of whether
+        it's in a window so that it can suspend and resume the web process accordingly.
+        However, in WKPDFView's case, PDFKit's host view is in the window instead of
+        WKPDFView itself when a PDF is being displayed (WKPDFView is only in a window as a
+        placeholder while the PDF loads). Since WKApplicationStateTrackingView doesn't
+        think its in a window, it suspends the web process, preventing messages necessary
+        to displaying the share sheet from being delivered.
+
+        Fix this by teaching WKApplicationStateTrackingView to consider the in-windowness
+        of the proper content view. For all cases other than WKPDFView, this is |self|.
+        For WKPDFView, it is the PDFHostViewController's root view if it exists, otherwise
+        it's |self|.
+
+        * UIProcess/ios/WKApplicationStateTrackingView.h:
+        * UIProcess/ios/WKApplicationStateTrackingView.mm:
+        (-[WKApplicationStateTrackingView willMoveToWindow:]):
+        (-[WKApplicationStateTrackingView didMoveToWindow]):
+        (-[WKApplicationStateTrackingView _contentView]):
+        * UIProcess/ios/WKPDFView.mm:
+        (-[WKPDFView _contentView]):
+        (-[WKPDFView web_contentView]):
+
 2018-06-07  Dean Jackson  <dino@apple.com>
 
         Match HI spec for thumbnail view sizing and location
index 864118b..fd7e78a 100644 (file)
@@ -35,6 +35,7 @@
 - (void)_applicationDidCreateWindowContext;
 - (void)_applicationWillEnterForeground;
 @property (nonatomic, readonly) BOOL isBackground;
+@property (nonatomic, readonly) UIView *_contentView;
 
 @end
 
index 793a2cd..037fdd3 100644 (file)
@@ -50,7 +50,7 @@
 
 - (void)willMoveToWindow:(UIWindow *)newWindow
 {
-    if (!self.window || newWindow)
+    if (!self._contentView.window || newWindow)
         return;
 
     ASSERT(_applicationStateTracker);
@@ -59,7 +59,7 @@
 
 - (void)didMoveToWindow
 {
-    if (!self.window)
+    if (!self._contentView.window)
         return;
 
     ASSERT(!_applicationStateTracker);
     return _applicationStateTracker ? _applicationStateTracker->isInBackground() : YES;
 }
 
+- (UIView *)_contentView
+{
+    return self;
+}
+
 @end
 
 #endif // PLATFORM(IOS)
index a90613e..452d7ac 100644 (file)
     return [_hostViewController gestureRecognizerShouldBegin:gestureRecognizer];
 }
 
+
+#pragma mark WKApplicationStateTrackingView
+
+- (UIView *)_contentView
+{
+    return _hostViewController ? [_hostViewController view] : self;
+}
+
+
 #pragma mark WKWebViewContentProvider
 
 - (instancetype)web_initWithFrame:(CGRect)frame webView:(WKWebView *)webView mimeType:(NSString *)mimeType
@@ -321,7 +330,7 @@ static NSStringCompareOptions stringCompareOptions(_WKFindOptions findOptions)
 
 - (UIView *)web_contentView
 {
-    return _hostViewController ? [_hostViewController view] : self;
+    return self._contentView;
 }
 
 - (void)web_scrollViewDidScroll:(UIScrollView *)scrollView
@@ -369,6 +378,7 @@ static NSStringCompareOptions stringCompareOptions(_WKFindOptions findOptions)
     return self.isBackground;
 }
 
+
 #pragma mark PDFHostViewControllerDelegate
 
 - (void)pdfHostViewController:(PDFHostViewController *)controller updatePageCount:(NSInteger)pageCount
@@ -445,6 +455,7 @@ static NSStringCompareOptions stringCompareOptions(_WKFindOptions findOptions)
     [self _showActionSheetForURL:[self _URLWithPageIndex:pageIndex] atLocation:location withAnnotationRect:annotationRect];
 }
 
+
 #pragma mark WKActionSheetAssistantDelegate
 
 - (std::optional<WebKit::InteractionInformationAtPosition>)positionInformationForActionSheetAssistant:(WKActionSheetAssistant *)assistant
@@ -498,6 +509,7 @@ static NSStringCompareOptions stringCompareOptions(_WKFindOptions findOptions)
 
 @end
 
+
 #pragma mark _WKWebViewPrintProvider
 
 #if !ENABLE(MINIMAL_SIMULATOR)