Title: [170984] trunk/Source
Revision
170984
Author
aes...@apple.com
Date
2014-07-10 17:02:51 -0700 (Thu, 10 Jul 2014)

Log Message

[iOS] Some QuickLook documents are not displayed as previews
https://bugs.webkit.org/show_bug.cgi?id=134788

Reviewed by Pratik Solanki.

ResourceRequest::isMainResourceRequest() is not reliable (e.g. ResourceRequests reconstituted from an
NSURLRequest have no way to set this bit properly) and should probably be removed. Instead of using
isMainResourceRequest() to check if a QuickLookHandle should be created when the Network Process is in use,
just check if the current ResourceLoader is the same as the DocumentLoader's ResourceLoader.

No new tests. QuickLook is not testable from WebKit.

* platform/network/ios/QuickLook.mm:
(WebCore::QuickLookHandle::create):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (170983 => 170984)


--- trunk/Source/WebCore/ChangeLog	2014-07-10 23:57:50 UTC (rev 170983)
+++ trunk/Source/WebCore/ChangeLog	2014-07-11 00:02:51 UTC (rev 170984)
@@ -1,3 +1,20 @@
+2014-07-09  Andy Estes  <aes...@apple.com>
+
+        [iOS] Some QuickLook documents are not displayed as previews
+        https://bugs.webkit.org/show_bug.cgi?id=134788
+
+        Reviewed by Pratik Solanki.
+        
+        ResourceRequest::isMainResourceRequest() is not reliable (e.g. ResourceRequests reconstituted from an
+        NSURLRequest have no way to set this bit properly) and should probably be removed. Instead of using
+        isMainResourceRequest() to check if a QuickLookHandle should be created when the Network Process is in use,
+        just check if the current ResourceLoader is the same as the DocumentLoader's ResourceLoader.
+
+        No new tests. QuickLook is not testable from WebKit.
+
+        * platform/network/ios/QuickLook.mm:
+        (WebCore::QuickLookHandle::create):
+
 2014-07-10  Andreas Kling  <akl...@apple.com>
 
         [iOS WebKit2] Don't uninstall the memory pressure listener after first signal.

Modified: trunk/Source/WebCore/loader/DocumentLoader.cpp (170983 => 170984)


--- trunk/Source/WebCore/loader/DocumentLoader.cpp	2014-07-10 23:57:50 UTC (rev 170983)
+++ trunk/Source/WebCore/loader/DocumentLoader.cpp	2014-07-11 00:02:51 UTC (rev 170984)
@@ -958,7 +958,7 @@
 
 #if PLATFORM(IOS)
     // FIXME: Remove PLATFORM(IOS)-guard once we upstream the iOS changes to ResourceRequest.h.
-    m_request.setMainResourceRequest(false);
+    m_request.deprecatedSetMainResourceRequest(false);
 #endif
 
     if (this == frameLoader()->activeDocumentLoader())
@@ -1433,7 +1433,7 @@
 
 #if PLATFORM(IOS)
     // FIXME: Remove PLATFORM(IOS)-guard once we upstream the iOS changes to ResourceRequest.h.
-    m_request.setMainResourceRequest(true);
+    m_request.deprecatedSetMainResourceRequest(true);
 #endif
 
     ResourceRequest request(m_request);

Modified: trunk/Source/WebCore/platform/network/cf/ResourceRequest.h (170983 => 170984)


--- trunk/Source/WebCore/platform/network/cf/ResourceRequest.h	2014-07-10 23:57:50 UTC (rev 170983)
+++ trunk/Source/WebCore/platform/network/cf/ResourceRequest.h	2014-07-11 00:02:51 UTC (rev 170984)
@@ -117,8 +117,11 @@
 #endif
 
 #if PLATFORM(IOS)
-        void setMainResourceRequest(bool isMainResourceRequest) const { m_mainResourceRequest = isMainResourceRequest; }
-        bool isMainResourceRequest() const { return m_mainResourceRequest; }
+        // FIXME: deprecatedIsMainResourceRequest() does not return the correct value if the ResourceRequest has been
+        // deserialized from an IPC message. As a result this function can only be relied on when networking is not in a
+        // separate process.
+        void deprecatedSetMainResourceRequest(bool isMainResourceRequest) const { m_mainResourceRequest = isMainResourceRequest; }
+        bool deprecatedIsMainResourceRequest() const { return m_mainResourceRequest; }
 
     private:
         mutable bool m_mainResourceRequest = false;

Modified: trunk/Source/WebCore/platform/network/ios/QuickLook.mm (170983 => 170984)


--- trunk/Source/WebCore/platform/network/ios/QuickLook.mm	2014-07-10 23:57:50 UTC (rev 170983)
+++ trunk/Source/WebCore/platform/network/ios/QuickLook.mm	2014-07-11 00:02:51 UTC (rev 170984)
@@ -28,6 +28,7 @@
 
 #if USE(QUICK_LOOK)
 
+#import "DocumentLoader.h"
 #import "FileSystemIOS.h"
 #import "Logging.h"
 #import "ResourceError.h"
@@ -423,7 +424,7 @@
 std::unique_ptr<QuickLookHandle> QuickLookHandle::create(ResourceHandle* handle, NSURLConnection *connection, NSURLResponse *nsResponse, id delegate)
 {
     ASSERT_ARG(handle, handle);
-    if (!handle->firstRequest().isMainResourceRequest() || ![WebCore::QLPreviewGetSupportedMIMETypesSet() containsObject:[nsResponse MIMEType]])
+    if (!handle->firstRequest().deprecatedIsMainResourceRequest() || ![WebCore::QLPreviewGetSupportedMIMETypesSet() containsObject:[nsResponse MIMEType]])
         return nullptr;
 
     std::unique_ptr<QuickLookHandle> quickLookHandle(new QuickLookHandle([handle->firstRequest().nsURLRequest(DoNotUpdateHTTPBody) URL], connection, nsResponse, delegate));
@@ -435,7 +436,7 @@
 std::unique_ptr<QuickLookHandle> QuickLookHandle::create(ResourceHandle* handle, SynchronousResourceHandleCFURLConnectionDelegate* connectionDelegate, CFURLResponseRef cfResponse)
 {
     ASSERT_ARG(handle, handle);
-    if (!handle->firstRequest().isMainResourceRequest() || ![WebCore::QLPreviewGetSupportedMIMETypesSet() containsObject:(NSString *)CFURLResponseGetMIMEType(cfResponse)])
+    if (!handle->firstRequest().deprecatedIsMainResourceRequest() || ![WebCore::QLPreviewGetSupportedMIMETypesSet() containsObject:(NSString *)CFURLResponseGetMIMEType(cfResponse)])
         return nullptr;
 
     NSURLResponse *nsResponse = [NSURLResponse _responseWithCFURLResponse:cfResponse];
@@ -451,10 +452,15 @@
 }
 #endif
 
+static inline bool isMainResourceLoader(ResourceLoader* loader)
+{
+    return loader->documentLoader()->mainResourceLoader() == loader;
+}
+
 std::unique_ptr<QuickLookHandle> QuickLookHandle::create(ResourceLoader* loader, NSURLResponse *response)
 {
     ASSERT_ARG(loader, loader);
-    if (!loader->request().isMainResourceRequest() || ![WebCore::QLPreviewGetSupportedMIMETypesSet() containsObject:[response MIMEType]])
+    if (!isMainResourceLoader(loader) || ![WebCore::QLPreviewGetSupportedMIMETypesSet() containsObject:[response MIMEType]])
         return nullptr;
 
     RetainPtr<WebResourceLoaderQuickLookDelegate> delegate = adoptNS([[WebResourceLoaderQuickLookDelegate alloc] initWithResourceLoader:loader]);

Modified: trunk/Source/WebKit/mac/WebCoreSupport/WebFrameLoaderClient.mm (170983 => 170984)


--- trunk/Source/WebKit/mac/WebCoreSupport/WebFrameLoaderClient.mm	2014-07-10 23:57:50 UTC (rev 170983)
+++ trunk/Source/WebKit/mac/WebCoreSupport/WebFrameLoaderClient.mm	2014-07-11 00:02:51 UTC (rev 170984)
@@ -349,7 +349,7 @@
     bool isHiddenFromInspector = request.hiddenFromInspector();
 #endif
 #if PLATFORM(IOS)
-    bool isMainResourceRequest = request.isMainResourceRequest();
+    bool isMainResourceRequest = request.deprecatedIsMainResourceRequest();
     if (implementations->webThreadWillSendRequestFunc) {
         newURLRequest = (NSURLRequest *)CallResourceLoadDelegateInWebThread(implementations->webThreadWillSendRequestFunc, webView, @selector(webThreadWebView:resource:willSendRequest:redirectResponse:fromDataSource:), [webView _objectForIdentifier:identifier], currentURLRequest, redirectResponse.nsURLResponse(), dataSource(loader));
     } else
@@ -363,7 +363,7 @@
     request.setHiddenFromInspector(isHiddenFromInspector);
 #endif
 #if PLATFORM(IOS)
-    request.setMainResourceRequest(isMainResourceRequest);
+    request.deprecatedSetMainResourceRequest(isMainResourceRequest);
 #endif
 }
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to