Forward original fragment identifier into System Preview
authordino@apple.com <dino@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 1 Nov 2018 01:03:09 +0000 (01:03 +0000)
committerdino@apple.com <dino@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 1 Nov 2018 01:03:09 +0000 (01:03 +0000)
https://bugs.webkit.org/show_bug.cgi?id=191141
<rdar://problem/45717542>

Reviewed by Wenson Hsieh.

If the URL used by the page includes a fragment identifier, use
it when telling QuickLook to open a local file.

* UIProcess/Cocoa/DownloadClient.mm:
(WebKit::DownloadClient::didFinish): Append original fragment identifier
to the destination URL.

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

Source/WebKit/ChangeLog
Source/WebKit/UIProcess/Cocoa/DownloadClient.mm

index 76e5dd8..4b95cc9 100644 (file)
@@ -1,3 +1,18 @@
+2018-10-31  Dean Jackson  <dino@apple.com>
+
+        Forward original fragment identifier into System Preview
+        https://bugs.webkit.org/show_bug.cgi?id=191141
+        <rdar://problem/45717542>
+
+        Reviewed by Wenson Hsieh.
+
+        If the URL used by the page includes a fragment identifier, use
+        it when telling QuickLook to open a local file.
+
+        * UIProcess/Cocoa/DownloadClient.mm:
+        (WebKit::DownloadClient::didFinish): Append original fragment identifier
+        to the destination URL.
+
 2018-10-31  Zalan Bujtas  <zalan@apple.com>
 
         [iOS] Do not paint tap highlight unless it is above a certain threshold
index 0084f56..c5a5d6b 100644 (file)
@@ -212,8 +212,10 @@ void DownloadClient::didFinish(WebProcessPool&, DownloadProxy& downloadProxy)
 #if USE(SYSTEM_PREVIEW)
     if (downloadProxy.isSystemPreviewDownload()) {
         if (auto* webPage = downloadProxy.originatingPage()) {
-            NSURL *destinationURL = [NSURL fileURLWithPath:(NSString *)downloadProxy.destinationFilename()];
-            webPage->systemPreviewController()->finish(WebCore::URL(destinationURL));
+            WebCore::URL destinationURL = WebCore::URL::fileURLWithFileSystemPath(downloadProxy.destinationFilename());
+            if (!destinationURL.fragmentIdentifier().length())
+                destinationURL.setFragmentIdentifier(downloadProxy.request().url().fragmentIdentifier());
+            webPage->systemPreviewController()->finish(destinationURL);
         }
         releaseActivityTokenIfNecessary(downloadProxy);
         return;