Title: [231858] branches/safari-606.1.17-branch/Source/WebKit
- Revision
- 231858
- Author
- bshaf...@apple.com
- Date
- 2018-05-16 11:47:31 -0700 (Wed, 16 May 2018)
Log Message
Cherry-pick r231825. rdar://problem/40278181
Launch System Preview as the download starts, rather than waiting for a response
https://bugs.webkit.org/show_bug.cgi?id=185669
<rdar://problem/40278181>
Reviewed by Tim Horton.
We were waiting for the RequestResponse to get a MIME-type before
launching the system preview. This causes an annoying delay.
Instead, assume that the system preview is one of the handled
mime types and launch the viewer immediately. If it gets something it
didn't expect, it will show an error.
* UIProcess/Cocoa/DownloadClient.mm:
(WebKit::DownloadClient::didStart):
(WebKit::DownloadClient::didReceiveResponse):
* UIProcess/Cocoa/SystemPreviewControllerCocoa.mm:
(-[_WKPreviewControllerDataSource previewController:previewItemAtIndex:]):
(WebKit::SystemPreviewController::start): Small cleanup to ensure we
don't try to present twice (this shouldn't happen).
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@231825 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Modified Paths
Diff
Modified: branches/safari-606.1.17-branch/Source/WebKit/ChangeLog (231857 => 231858)
--- branches/safari-606.1.17-branch/Source/WebKit/ChangeLog 2018-05-16 18:47:28 UTC (rev 231857)
+++ branches/safari-606.1.17-branch/Source/WebKit/ChangeLog 2018-05-16 18:47:31 UTC (rev 231858)
@@ -1,5 +1,55 @@
2018-05-16 Babak Shafiei <bshaf...@apple.com>
+ Cherry-pick r231825. rdar://problem/40278181
+
+ Launch System Preview as the download starts, rather than waiting for a response
+ https://bugs.webkit.org/show_bug.cgi?id=185669
+ <rdar://problem/40278181>
+
+ Reviewed by Tim Horton.
+
+ We were waiting for the RequestResponse to get a MIME-type before
+ launching the system preview. This causes an annoying delay.
+
+ Instead, assume that the system preview is one of the handled
+ mime types and launch the viewer immediately. If it gets something it
+ didn't expect, it will show an error.
+
+ * UIProcess/Cocoa/DownloadClient.mm:
+ (WebKit::DownloadClient::didStart):
+ (WebKit::DownloadClient::didReceiveResponse):
+ * UIProcess/Cocoa/SystemPreviewControllerCocoa.mm:
+ (-[_WKPreviewControllerDataSource previewController:previewItemAtIndex:]):
+ (WebKit::SystemPreviewController::start): Small cleanup to ensure we
+ don't try to present twice (this shouldn't happen).
+
+ git-svn-id: https://svn.webkit.org/repository/webkit/trunk@231825 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+ 2018-05-15 Dean Jackson <d...@apple.com>
+
+ Launch System Preview as the download starts, rather than waiting for a response
+ https://bugs.webkit.org/show_bug.cgi?id=185669
+ <rdar://problem/40278181>
+
+ Reviewed by Tim Horton.
+
+ We were waiting for the RequestResponse to get a MIME-type before
+ launching the system preview. This causes an annoying delay.
+
+ Instead, assume that the system preview is one of the handled
+ mime types and launch the viewer immediately. If it gets something it
+ didn't expect, it will show an error.
+
+ * UIProcess/Cocoa/DownloadClient.mm:
+ (WebKit::DownloadClient::didStart):
+ (WebKit::DownloadClient::didReceiveResponse):
+ * UIProcess/Cocoa/SystemPreviewControllerCocoa.mm:
+ (-[_WKPreviewControllerDataSource previewController:previewItemAtIndex:]):
+ (WebKit::SystemPreviewController::start): Small cleanup to ensure we
+ don't try to present twice (this shouldn't happen).
+
+2018-05-16 Babak Shafiei <bshaf...@apple.com>
+
Cherry-pick r231824. rdar://problem/40278181
Post-review cleanup for 185459
Modified: branches/safari-606.1.17-branch/Source/WebKit/UIProcess/Cocoa/DownloadClient.mm (231857 => 231858)
--- branches/safari-606.1.17-branch/Source/WebKit/UIProcess/Cocoa/DownloadClient.mm 2018-05-16 18:47:28 UTC (rev 231857)
+++ branches/safari-606.1.17-branch/Source/WebKit/UIProcess/Cocoa/DownloadClient.mm 2018-05-16 18:47:31 UTC (rev 231858)
@@ -76,6 +76,10 @@
{
#if USE(SYSTEM_PREVIEW)
if (downloadProxy.isSystemPreviewDownload()) {
+ if (auto* webPage = downloadProxy.originatingPage()) {
+ // FIXME: Update the MIME-type once it is known in the ResourceResponse.
+ webPage->systemPreviewController()->start(ASCIILiteral { "application/octet-stream" });
+ }
takeActivityToken(downloadProxy);
return;
}
@@ -91,10 +95,8 @@
if (downloadProxy.isSystemPreviewDownload()) {
downloadProxy.setExpectedContentLength(response.expectedContentLength());
downloadProxy.setBytesLoaded(0);
- if (auto* webPage = downloadProxy.originatingPage()) {
- webPage->systemPreviewController()->start(response.mimeType());
+ if (auto* webPage = downloadProxy.originatingPage())
webPage->systemPreviewController()->updateProgress(0);
- }
return;
}
#endif
Modified: branches/safari-606.1.17-branch/Source/WebKit/UIProcess/Cocoa/SystemPreviewControllerCocoa.mm (231857 => 231858)
--- branches/safari-606.1.17-branch/Source/WebKit/UIProcess/Cocoa/SystemPreviewControllerCocoa.mm 2018-05-16 18:47:28 UTC (rev 231857)
+++ branches/safari-606.1.17-branch/Source/WebKit/UIProcess/Cocoa/SystemPreviewControllerCocoa.mm 2018-05-16 18:47:31 UTC (rev 231858)
@@ -80,7 +80,9 @@
_itemProvider = adoptNS([[NSItemProvider alloc] init]);
NSString *contentType = @"public.content";
#if USE(APPLE_INTERNAL_SDK)
- contentType = WebKit::getUTIForMIMEType(self.mimeType);
+ // FIXME: We are launching the preview controller before getting a response from the resource, which
+ // means we don't actually know the real MIME type yet. Assume it is one of those that we registered.
+ contentType = WebKit::getUTIForMIMEType(*WebKit::getSystemPreviewMIMETypes().begin());
#endif
_item = adoptNS([allocQLItemInstance() initWithPreviewItemProvider:_itemProvider.get() contentType:contentType previewTitle:@"Preview" fileSize:@(0)]);
[_item setUseLoadingTimeout:NO];
@@ -158,7 +160,9 @@
void SystemPreviewController::start(const String& mimeType)
{
- // FIXME: Make sure you can't show a preview if we're already previewing.
+ ASSERT(!m_qlPreviewController);
+ if (m_qlPreviewController)
+ return;
UIViewController *presentingViewController = m_webPageProxy.uiClient().presentingViewController();
@@ -165,17 +169,14 @@
if (!presentingViewController)
return;
- if (!m_qlPreviewController) {
- m_qlPreviewController = adoptNS([allocQLPreviewControllerInstance() init]);
+ m_qlPreviewController = adoptNS([allocQLPreviewControllerInstance() init]);
- m_qlPreviewControllerDelegate = adoptNS([[_WKPreviewControllerDelegate alloc] initWithSystemPreviewController:this]);
- [m_qlPreviewController setDelegate:m_qlPreviewControllerDelegate.get()];
+ m_qlPreviewControllerDelegate = adoptNS([[_WKPreviewControllerDelegate alloc] initWithSystemPreviewController:this]);
+ [m_qlPreviewController setDelegate:m_qlPreviewControllerDelegate.get()];
- m_qlPreviewControllerDataSource = adoptNS([[_WKPreviewControllerDataSource alloc] initWithMIMEType:mimeType]);
- [m_qlPreviewController setDataSource:m_qlPreviewControllerDataSource.get()];
+ m_qlPreviewControllerDataSource = adoptNS([[_WKPreviewControllerDataSource alloc] initWithMIMEType:mimeType]);
+ [m_qlPreviewController setDataSource:m_qlPreviewControllerDataSource.get()];
- }
-
[presentingViewController presentViewController:m_qlPreviewController.get() animated:YES completion:nullptr];
}
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes