Title: [172035] trunk/Source
- Revision
- 172035
- Author
- aes...@apple.com
- Date
- 2014-08-05 10:49:44 -0700 (Tue, 05 Aug 2014)
Log Message
[iOS] The raw bytes of an iWork document's PDF preview are displayed rather than the PDF itself
https://bugs.webkit.org/show_bug.cgi?id=135596
Reviewed by David Kilzer.
Source/WebCore:
Some iWork documents contain pre-rendered PDF previews. When WebKit asks QuickLook to convert such a document,
QuickLook will return this PDF as the converted response. However, until WebKit has sent the document's data to
QuickLook, -[QLPreviewConverter previewResponse] will misleadingly tell WebKit that the converted resource will
be of type 'text/html'. This leads WebKit to render the PDF preview as HTML.
Instead of querying QLPreviewConverter for the previewResponse before we've sent it any data, postpone calling
ResourceLoader::didReceiveResponse until we've begun to receive data via the QLPreviewConverter delegate. At
that point -[QLPreviewConverter previewResponse] will have the correct MIME type and we can call didReceiveResponse.
No new tests. QuickLook is not testable from WebKit.
* platform/network/ios/QuickLook.mm:
(-[WebResourceLoaderQuickLookDelegate connection:didReceiveDataArray:]): If didReceiveResponse has yet to be
called, call it now with QuickLookHandle::nsResponse().
(-[WebResourceLoaderQuickLookDelegate connection:didReceiveData:lengthReceived:]): Ditto.
(-[WebResourceLoaderQuickLookDelegate connection:didFailWithError:]): Ditto.
(-[WebResourceLoaderQuickLookDelegate connectionDidFinishLoading:]): Assert that didReceiveResponse has been called.
(-[WebResourceLoaderQuickLookDelegate clearHandle]): Cleared the raw pointer to QuickLookHandle.
(WebCore::QuickLookHandle::create): Pointed WebResourceLoaderQuickLookDelegate's quickLookHandle property to
the newly created QuickLookHandle.
Source/WebKit2:
* WebProcess/Network/WebResourceLoader.cpp:
(WebKit::WebResourceLoader::didReceiveResponseWithCertificateInfo): If the response will be handled by
QuickLook, do not call ResourceLoader::didReceiveResponse. It will be called later by
WebResourceLoaderQuickLookDelegate once converted data is received.
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (172034 => 172035)
--- trunk/Source/WebCore/ChangeLog 2014-08-05 17:03:25 UTC (rev 172034)
+++ trunk/Source/WebCore/ChangeLog 2014-08-05 17:49:44 UTC (rev 172035)
@@ -1,3 +1,31 @@
+2014-08-04 Andy Estes <aes...@apple.com>
+
+ [iOS] The raw bytes of an iWork document's PDF preview are displayed rather than the PDF itself
+ https://bugs.webkit.org/show_bug.cgi?id=135596
+
+ Reviewed by David Kilzer.
+
+ Some iWork documents contain pre-rendered PDF previews. When WebKit asks QuickLook to convert such a document,
+ QuickLook will return this PDF as the converted response. However, until WebKit has sent the document's data to
+ QuickLook, -[QLPreviewConverter previewResponse] will misleadingly tell WebKit that the converted resource will
+ be of type 'text/html'. This leads WebKit to render the PDF preview as HTML.
+
+ Instead of querying QLPreviewConverter for the previewResponse before we've sent it any data, postpone calling
+ ResourceLoader::didReceiveResponse until we've begun to receive data via the QLPreviewConverter delegate. At
+ that point -[QLPreviewConverter previewResponse] will have the correct MIME type and we can call didReceiveResponse.
+
+ No new tests. QuickLook is not testable from WebKit.
+
+ * platform/network/ios/QuickLook.mm:
+ (-[WebResourceLoaderQuickLookDelegate connection:didReceiveDataArray:]): If didReceiveResponse has yet to be
+ called, call it now with QuickLookHandle::nsResponse().
+ (-[WebResourceLoaderQuickLookDelegate connection:didReceiveData:lengthReceived:]): Ditto.
+ (-[WebResourceLoaderQuickLookDelegate connection:didFailWithError:]): Ditto.
+ (-[WebResourceLoaderQuickLookDelegate connectionDidFinishLoading:]): Assert that didReceiveResponse has been called.
+ (-[WebResourceLoaderQuickLookDelegate clearHandle]): Cleared the raw pointer to QuickLookHandle.
+ (WebCore::QuickLookHandle::create): Pointed WebResourceLoaderQuickLookDelegate's quickLookHandle property to
+ the newly created QuickLookHandle.
+
2014-08-05 Renata Hodovan <rhodovan.u-sze...@partner.samsung.com>
Fixing calc() parameter parsing in cubic-bezier functions
Modified: trunk/Source/WebCore/platform/network/ios/QuickLook.mm (172034 => 172035)
--- trunk/Source/WebCore/platform/network/ios/QuickLook.mm 2014-08-05 17:03:25 UTC (rev 172034)
+++ trunk/Source/WebCore/platform/network/ios/QuickLook.mm 2014-08-05 17:49:44 UTC (rev 172035)
@@ -323,7 +323,9 @@
@interface WebResourceLoaderQuickLookDelegate : NSObject <NSURLConnectionDelegate> {
RefPtr<ResourceLoader> _resourceLoader;
+ BOOL _hasSentDidReceiveResponse;
}
+@property (nonatomic) QuickLookHandle* quickLookHandle;
@end
@implementation WebResourceLoaderQuickLookDelegate
@@ -344,6 +346,12 @@
UNUSED_PARAM(connection);
if (!_resourceLoader)
return;
+
+ if (!_hasSentDidReceiveResponse && _quickLookHandle) {
+ _hasSentDidReceiveResponse = YES;
+ _resourceLoader->didReceiveResponse(_quickLookHandle->nsResponse());
+ }
+
_resourceLoader->didReceiveDataArray(reinterpret_cast<CFArrayRef>(dataArray));
}
#endif
@@ -353,7 +361,12 @@
UNUSED_PARAM(connection);
if (!_resourceLoader)
return;
-
+
+ if (!_hasSentDidReceiveResponse && _quickLookHandle) {
+ _hasSentDidReceiveResponse = YES;
+ _resourceLoader->didReceiveResponse(_quickLookHandle->nsResponse());
+ }
+
// QuickLook code sends us a nil data at times. The check below is the same as the one in
// ResourceHandleMac.cpp added for a different bug.
if (![data length])
@@ -366,20 +379,27 @@
UNUSED_PARAM(connection);
if (!_resourceLoader)
return;
-
+
+ ASSERT(_hasSentDidReceiveResponse);
_resourceLoader->didFinishLoading(0);
}
- (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error
{
UNUSED_PARAM(connection);
-
+
+ if (!_hasSentDidReceiveResponse && _quickLookHandle) {
+ _hasSentDidReceiveResponse = YES;
+ _resourceLoader->didReceiveResponse(_quickLookHandle->nsResponse());
+ }
+
_resourceLoader->didFail(ResourceError(error));
}
- (void)clearHandle
{
_resourceLoader = nullptr;
+ _quickLookHandle = nullptr;
}
@end
@@ -465,6 +485,7 @@
RetainPtr<WebResourceLoaderQuickLookDelegate> delegate = adoptNS([[WebResourceLoaderQuickLookDelegate alloc] initWithResourceLoader:loader]);
std::unique_ptr<QuickLookHandle> quickLookHandle(new QuickLookHandle([loader->originalRequest().nsURLRequest(DoNotUpdateHTTPBody) URL], nil, response, delegate.get()));
+ [delegate setQuickLookHandle:quickLookHandle.get()];
loader->didCreateQuickLookHandle(*quickLookHandle);
return WTF::move(quickLookHandle);
}
Modified: trunk/Source/WebKit2/ChangeLog (172034 => 172035)
--- trunk/Source/WebKit2/ChangeLog 2014-08-05 17:03:25 UTC (rev 172034)
+++ trunk/Source/WebKit2/ChangeLog 2014-08-05 17:49:44 UTC (rev 172035)
@@ -1,3 +1,15 @@
+2014-08-04 Andy Estes <aes...@apple.com>
+
+ [iOS] The raw bytes of an iWork document's PDF preview are displayed rather than the PDF itself
+ https://bugs.webkit.org/show_bug.cgi?id=135596
+
+ Reviewed by David Kilzer.
+
+ * WebProcess/Network/WebResourceLoader.cpp:
+ (WebKit::WebResourceLoader::didReceiveResponseWithCertificateInfo): If the response will be handled by
+ QuickLook, do not call ResourceLoader::didReceiveResponse. It will be called later by
+ WebResourceLoaderQuickLookDelegate once converted data is received.
+
2014-08-05 Alexey Proskuryakov <a...@apple.com>
Build fix.
Modified: trunk/Source/WebKit2/WebProcess/Network/WebResourceLoader.cpp (172034 => 172035)
--- trunk/Source/WebKit2/WebProcess/Network/WebResourceLoader.cpp 2014-08-05 17:03:25 UTC (rev 172034)
+++ trunk/Source/WebKit2/WebProcess/Network/WebResourceLoader.cpp 2014-08-05 17:49:44 UTC (rev 172035)
@@ -110,12 +110,6 @@
ResourceResponse responseCopy(response);
-#if USE(QUICK_LOOK)
- m_quickLookHandle = QuickLookHandle::create(resourceLoader(), response.nsURLResponse());
- if (m_quickLookHandle)
- responseCopy = ResourceResponse(m_quickLookHandle->nsResponse());
-#endif
-
// FIXME: This should use CertificateInfo to avoid the platform ifdefs. See https://bugs.webkit.org/show_bug.cgi?id=124724.
#if PLATFORM(COCOA)
responseCopy.setCertificateChain(certificateInfo.certificateChain());
@@ -123,10 +117,19 @@
responseCopy.setSoupMessageCertificate(certificateInfo.certificate());
responseCopy.setSoupMessageTLSErrors(certificateInfo.tlsErrors());
#endif
+
if (m_coreLoader->documentLoader()->applicationCacheHost()->maybeLoadFallbackForResponse(m_coreLoader.get(), responseCopy))
return;
- m_coreLoader->didReceiveResponse(responseCopy);
+#if USE(QUICK_LOOK)
+ // Refrain from calling didReceiveResponse if QuickLook will convert this response, since the MIME type of the
+ // converted resource isn't yet known. WebResourceLoaderQuickLookDelegate will later call didReceiveResponse upon
+ // receiving the converted data.
+ m_quickLookHandle = QuickLookHandle::create(resourceLoader(), responseCopy.nsURLResponse());
+ if (!m_quickLookHandle)
+#endif
+ m_coreLoader->didReceiveResponse(responseCopy);
+
// If m_coreLoader becomes null as a result of the didReceiveResponse callback, we can't use the send function().
if (!m_coreLoader)
return;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes