Changeset 231825 in webkit


Ignore:
Timestamp:
May 15, 2018 5:39:10 PM (6 years ago)
Author:
dino@apple.com
Message:

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).

Location:
trunk/Source/WebKit
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r231824 r231825  
     12018-05-15  Dean Jackson  <dino@apple.com>
     2
     3        Launch System Preview as the download starts, rather than waiting for a response
     4        https://bugs.webkit.org/show_bug.cgi?id=185669
     5        <rdar://problem/40278181>
     6
     7        Reviewed by Tim Horton.
     8
     9        We were waiting for the RequestResponse to get a MIME-type before
     10        launching the system preview. This causes an annoying delay.
     11
     12        Instead, assume that the system preview is one of the handled
     13        mime types and launch the viewer immediately. If it gets something it
     14        didn't expect, it will show an error.
     15
     16        * UIProcess/Cocoa/DownloadClient.mm:
     17        (WebKit::DownloadClient::didStart):
     18        (WebKit::DownloadClient::didReceiveResponse):
     19        * UIProcess/Cocoa/SystemPreviewControllerCocoa.mm:
     20        (-[_WKPreviewControllerDataSource previewController:previewItemAtIndex:]):
     21        (WebKit::SystemPreviewController::start): Small cleanup to ensure we
     22        don't try to present twice (this shouldn't happen).
     23
    1242018-05-15  Dean Jackson  <dino@apple.com>
    225
  • trunk/Source/WebKit/UIProcess/Cocoa/DownloadClient.mm

    r231824 r231825  
    7777#if USE(SYSTEM_PREVIEW)
    7878    if (downloadProxy.isSystemPreviewDownload()) {
     79        if (auto* webPage = downloadProxy.originatingPage()) {
     80            // FIXME: Update the MIME-type once it is known in the ResourceResponse.
     81            webPage->systemPreviewController()->start(ASCIILiteral { "application/octet-stream" });
     82        }
    7983        takeActivityToken(downloadProxy);
    8084        return;
     
    9296        downloadProxy.setExpectedContentLength(response.expectedContentLength());
    9397        downloadProxy.setBytesLoaded(0);
    94         if (auto* webPage = downloadProxy.originatingPage()) {
    95             webPage->systemPreviewController()->start(response.mimeType());
     98        if (auto* webPage = downloadProxy.originatingPage())
    9699            webPage->systemPreviewController()->updateProgress(0);
    97         }
    98100        return;
    99101    }
  • trunk/Source/WebKit/UIProcess/Cocoa/SystemPreviewControllerCocoa.mm

    r231824 r231825  
    8181    NSString *contentType = @"public.content";
    8282#if USE(APPLE_INTERNAL_SDK)
    83     contentType = WebKit::getUTIForMIMEType(self.mimeType);
     83    // FIXME: We are launching the preview controller before getting a response from the resource, which
     84    // means we don't actually know the real MIME type yet. Assume it is one of those that we registered.
     85    contentType = WebKit::getUTIForMIMEType(*WebKit::getSystemPreviewMIMETypes().begin());
    8486#endif
    8587    _item = adoptNS([allocQLItemInstance() initWithPreviewItemProvider:_itemProvider.get() contentType:contentType previewTitle:@"Preview" fileSize:@(0)]);
     
    159161void SystemPreviewController::start(const String& mimeType)
    160162{
    161     // FIXME: Make sure you can't show a preview if we're already previewing.
     163    ASSERT(!m_qlPreviewController);
     164    if (m_qlPreviewController)
     165        return;
    162166
    163167    UIViewController *presentingViewController = m_webPageProxy.uiClient().presentingViewController();
     
    166170        return;
    167171
    168     if (!m_qlPreviewController) {
    169         m_qlPreviewController = adoptNS([allocQLPreviewControllerInstance() init]);
    170 
    171         m_qlPreviewControllerDelegate = adoptNS([[_WKPreviewControllerDelegate alloc] initWithSystemPreviewController:this]);
    172         [m_qlPreviewController setDelegate:m_qlPreviewControllerDelegate.get()];
    173 
    174         m_qlPreviewControllerDataSource = adoptNS([[_WKPreviewControllerDataSource alloc] initWithMIMEType:mimeType]);
    175         [m_qlPreviewController setDataSource:m_qlPreviewControllerDataSource.get()];
    176 
    177     }
     172    m_qlPreviewController = adoptNS([allocQLPreviewControllerInstance() init]);
     173
     174    m_qlPreviewControllerDelegate = adoptNS([[_WKPreviewControllerDelegate alloc] initWithSystemPreviewController:this]);
     175    [m_qlPreviewController setDelegate:m_qlPreviewControllerDelegate.get()];
     176
     177    m_qlPreviewControllerDataSource = adoptNS([[_WKPreviewControllerDataSource alloc] initWithMIMEType:mimeType]);
     178    [m_qlPreviewController setDataSource:m_qlPreviewControllerDataSource.get()];
    178179
    179180    [presentingViewController presentViewController:m_qlPreviewController.get() animated:YES completion:nullptr];
Note: See TracChangeset for help on using the changeset viewer.