Title: [232607] trunk/Source/WebKit
Revision
232607
Author
[email protected]
Date
2018-06-07 16:23:55 -0700 (Thu, 07 Jun 2018)

Log Message

[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]):

Modified Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (232606 => 232607)


--- trunk/Source/WebKit/ChangeLog	2018-06-07 23:20:28 UTC (rev 232606)
+++ trunk/Source/WebKit/ChangeLog	2018-06-07 23:23:55 UTC (rev 232607)
@@ -1,3 +1,33 @@
+2018-06-07  Andy Estes  <[email protected]>
+
+        [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  <[email protected]>
 
         Match HI spec for thumbnail view sizing and location

Modified: trunk/Source/WebKit/UIProcess/ios/WKApplicationStateTrackingView.h (232606 => 232607)


--- trunk/Source/WebKit/UIProcess/ios/WKApplicationStateTrackingView.h	2018-06-07 23:20:28 UTC (rev 232606)
+++ trunk/Source/WebKit/UIProcess/ios/WKApplicationStateTrackingView.h	2018-06-07 23:23:55 UTC (rev 232607)
@@ -35,6 +35,7 @@
 - (void)_applicationDidCreateWindowContext;
 - (void)_applicationWillEnterForeground;
 @property (nonatomic, readonly) BOOL isBackground;
+@property (nonatomic, readonly) UIView *_contentView;
 
 @end
 

Modified: trunk/Source/WebKit/UIProcess/ios/WKApplicationStateTrackingView.mm (232606 => 232607)


--- trunk/Source/WebKit/UIProcess/ios/WKApplicationStateTrackingView.mm	2018-06-07 23:20:28 UTC (rev 232606)
+++ trunk/Source/WebKit/UIProcess/ios/WKApplicationStateTrackingView.mm	2018-06-07 23:23:55 UTC (rev 232607)
@@ -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);
@@ -101,6 +101,11 @@
     return _applicationStateTracker ? _applicationStateTracker->isInBackground() : YES;
 }
 
+- (UIView *)_contentView
+{
+    return self;
+}
+
 @end
 
 #endif // PLATFORM(IOS)

Modified: trunk/Source/WebKit/UIProcess/ios/WKPDFView.mm (232606 => 232607)


--- trunk/Source/WebKit/UIProcess/ios/WKPDFView.mm	2018-06-07 23:20:28 UTC (rev 232606)
+++ trunk/Source/WebKit/UIProcess/ios/WKPDFView.mm	2018-06-07 23:23:55 UTC (rev 232607)
@@ -77,6 +77,15 @@
     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 @@
 
 - (UIView *)web_contentView
 {
-    return _hostViewController ? [_hostViewController view] : self;
+    return self._contentView;
 }
 
 - (void)web_scrollViewDidScroll:(UIScrollView *)scrollView
@@ -369,6 +378,7 @@
     return self.isBackground;
 }
 
+
 #pragma mark PDFHostViewControllerDelegate
 
 - (void)pdfHostViewController:(PDFHostViewController *)controller updatePageCount:(NSInteger)pageCount
@@ -445,6 +455,7 @@
     [self _showActionSheetForURL:[self _URLWithPageIndex:pageIndex] atLocation:location withAnnotationRect:annotationRect];
 }
 
+
 #pragma mark WKActionSheetAssistantDelegate
 
 - (std::optional<WebKit::InteractionInformationAtPosition>)positionInformationForActionSheetAssistant:(WKActionSheetAssistant *)assistant
@@ -498,6 +509,7 @@
 
 @end
 
+
 #pragma mark _WKWebViewPrintProvider
 
 #if !ENABLE(MINIMAL_SIMULATOR)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to