Title: [175055] trunk/Source
Revision
175055
Author
[email protected]
Date
2014-10-22 10:43:07 -0700 (Wed, 22 Oct 2014)

Log Message

[Mac][WK2] Fix applicationIsSafari() detection
https://bugs.webkit.org/show_bug.cgi?id=137893

Reviewed by Alexey Proskuryakov.

Source/WebCore:

I noticed when profiling Safari on Mac that we were exercising a code
path we shouldn't because it is meant for other applications that
Safari.

The detection relies on the applicationIsSafari() function in
RuntimeApplicationChecks.cpp. This was in some cases returning false on
my machine even though I was running Safari so I investigated a bit and
noticed that the check relies on the main bundle identifier string and
is doing:
isSafari = mainBundleIsEqualTo("com.apple.Safari")
    || mainBundleIsEqualTo("com.apple.WebProcess");

This WebProcess detection is very unreliable because:
- It matches other apps than Safari's WebProcesses
- The bundle name for the WebProcess is sometimes
"com.apple.WebKit.WebContent" or
"com.apple.WebKit.WebContent.Development".

The solution used in this patch is to move the applicationIsSafari()
check to the UIProcess so that the check actually succeeds reliably.
The call site for applicationIsSafari() was in
ResourceRequest::useQuickLookResourceCachingQuirks(). This match
removes that logic from ResourceRequest and move it to
FrameLoaderClient as only the FrameLoader is interested in this
information. The logic to determine if we should use QuickLook
resource caching quirks is moved to a new QuickLook class under
platform/ as the code needs to be shared between WebKit and WebKit2.
On WebKit2, we make use that code on the UIProcess side and pass
the flag as a parameter when constructing the WebProcess. The flag
is then stored on the WebProcess and queried by WebFrameLoaderClient.

Previously, we would spend ~1% of the WebProcess cpu time (when loading
apple.com) trying to detect if we should use QuickLook resource caching
quirks even though that check was supposed to be disabled and return
early when running Safari.

No new tests, not easily testable.

* WebCore.exp.in:
* WebCore.xcodeproj/project.pbxproj:
* loader/EmptyClients.h:
* loader/FrameLoader.cpp:
(WebCore::FrameLoader::subresourceCachePolicy):
* loader/FrameLoaderClient.h:
* platform/RuntimeApplicationChecks.cpp:
(WebCore::applicationIsSafari):
Remove "com.apple.WebProcess" bundle name matching as this causes false
positives (matches other applications than Safari's WebProcesses) and
it is no longer needed now that applicationIsSafari() is always called
from the UIProcess.

* platform/mac/QuickLookMac.h: Added.
* platform/mac/QuickLookMac.mm: Copied from Source/WebCore/platform/network/mac/ResourceRequestMac.mm.
(WebCore::QuickLookMac::computeNeedsQuickLookResourceCachingQuirks):
* platform/network/cf/ResourceRequest.h:
* platform/network/ios/ResourceRequestIOS.mm:
(WebCore::ResourceRequest::useQuickLookResourceCachingQuirks): Deleted.
* platform/network/mac/ResourceRequestMac.mm:
(WebCore::initQuickLookResourceCachingQuirks): Deleted.
(WebCore::ResourceRequest::useQuickLookResourceCachingQuirks): Deleted.

Source/WebKit/mac:

Provide an implementation for FrameLoaderClient's new
needsQuickLookResourceCachingQuirks() that returns
a static flag initialized using
QuickLookMac::computeNeedsQuickLookResourceCachingQuirks().

* WebCoreSupport/WebFrameLoaderClient.h:
* WebCoreSupport/WebFrameLoaderClient.mm:

Source/WebKit2:

Provide an implementation for FrameLoaderClient's new
needsQuickLookResourceCachingQuirks(), which accesses the flag stored
on the WebProcess, which is initialized upon WebProcess creation.

QuickLookMac::computeNeedsQuickLookResourceCachingQuirks() is called
on UIProcess side so that it works reliably and the flag is passed as
parameter when constructing the WebProcess.

* Shared/WebProcessCreationParameters.cpp:
(WebKit::WebProcessCreationParameters::encode):
(WebKit::WebProcessCreationParameters::decode):
* Shared/WebProcessCreationParameters.h:
* UIProcess/mac/WebContextMac.mm:
(WebKit::WebContext::platformInitializeWebProcess):
* WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
(WebKit::WebFrameLoaderClient::needsQuickLookResourceCachingQuirks):
* WebProcess/WebCoreSupport/WebFrameLoaderClient.h:
* WebProcess/WebProcess.cpp:
(WebKit::WebProcess::WebProcess):
* WebProcess/WebProcess.h:
(WebKit::WebProcess::needsQuickLookResourceCachingQuirks):
* WebProcess/cocoa/WebProcessCocoa.mm:
(WebKit::WebProcess::platformInitializeWebProcess):

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (175054 => 175055)


--- trunk/Source/WebCore/ChangeLog	2014-10-22 17:41:57 UTC (rev 175054)
+++ trunk/Source/WebCore/ChangeLog	2014-10-22 17:43:07 UTC (rev 175055)
@@ -1,3 +1,71 @@
+2014-10-22  Chris Dumez  <[email protected]>
+
+        [Mac][WK2] Fix applicationIsSafari() detection
+        https://bugs.webkit.org/show_bug.cgi?id=137893
+
+        Reviewed by Alexey Proskuryakov.
+
+        I noticed when profiling Safari on Mac that we were exercising a code
+        path we shouldn't because it is meant for other applications that
+        Safari.
+
+        The detection relies on the applicationIsSafari() function in
+        RuntimeApplicationChecks.cpp. This was in some cases returning false on
+        my machine even though I was running Safari so I investigated a bit and
+        noticed that the check relies on the main bundle identifier string and
+        is doing:
+        isSafari = mainBundleIsEqualTo("com.apple.Safari")
+            || mainBundleIsEqualTo("com.apple.WebProcess");
+
+        This WebProcess detection is very unreliable because:
+        - It matches other apps than Safari's WebProcesses
+        - The bundle name for the WebProcess is sometimes
+        "com.apple.WebKit.WebContent" or
+        "com.apple.WebKit.WebContent.Development".
+
+        The solution used in this patch is to move the applicationIsSafari()
+        check to the UIProcess so that the check actually succeeds reliably.
+        The call site for applicationIsSafari() was in
+        ResourceRequest::useQuickLookResourceCachingQuirks(). This match
+        removes that logic from ResourceRequest and move it to
+        FrameLoaderClient as only the FrameLoader is interested in this
+        information. The logic to determine if we should use QuickLook
+        resource caching quirks is moved to a new QuickLook class under
+        platform/ as the code needs to be shared between WebKit and WebKit2.
+        On WebKit2, we make use that code on the UIProcess side and pass
+        the flag as a parameter when constructing the WebProcess. The flag
+        is then stored on the WebProcess and queried by WebFrameLoaderClient.
+
+        Previously, we would spend ~1% of the WebProcess cpu time (when loading
+        apple.com) trying to detect if we should use QuickLook resource caching
+        quirks even though that check was supposed to be disabled and return
+        early when running Safari.
+
+        No new tests, not easily testable.
+
+        * WebCore.exp.in:
+        * WebCore.xcodeproj/project.pbxproj:
+        * loader/EmptyClients.h:
+        * loader/FrameLoader.cpp:
+        (WebCore::FrameLoader::subresourceCachePolicy):
+        * loader/FrameLoaderClient.h:
+        * platform/RuntimeApplicationChecks.cpp:
+        (WebCore::applicationIsSafari):
+        Remove "com.apple.WebProcess" bundle name matching as this causes false
+        positives (matches other applications than Safari's WebProcesses) and
+        it is no longer needed now that applicationIsSafari() is always called
+        from the UIProcess.
+
+        * platform/mac/QuickLookMac.h: Added.
+        * platform/mac/QuickLookMac.mm: Copied from Source/WebCore/platform/network/mac/ResourceRequestMac.mm.
+        (WebCore::QuickLookMac::computeNeedsQuickLookResourceCachingQuirks):
+        * platform/network/cf/ResourceRequest.h:
+        * platform/network/ios/ResourceRequestIOS.mm:
+        (WebCore::ResourceRequest::useQuickLookResourceCachingQuirks): Deleted.
+        * platform/network/mac/ResourceRequestMac.mm:
+        (WebCore::initQuickLookResourceCachingQuirks): Deleted.
+        (WebCore::ResourceRequest::useQuickLookResourceCachingQuirks): Deleted.
+
 2014-10-22  Shivakumar JM  <[email protected]>
 
         XMLHttpRequest should support attribute responseURL as per latest XHR spec.

Modified: trunk/Source/WebCore/WebCore.exp.in (175054 => 175055)


--- trunk/Source/WebCore/WebCore.exp.in	2014-10-22 17:41:57 UTC (rev 175054)
+++ trunk/Source/WebCore/WebCore.exp.in	2014-10-22 17:43:07 UTC (rev 175055)
@@ -240,6 +240,7 @@
 __ZN7WebCore12PrintContext9spoolRectERNS_15GraphicsContextERKNS_7IntRectE
 __ZN7WebCore12PrintContextC1EPNS_5FrameE
 __ZN7WebCore12PrintContextD1Ev
+__ZN7WebCore12QuickLookMac42computeNeedsQuickLookResourceCachingQuirksEv
 __ZN7WebCore12RenderObject16paintingRootRectERNS_10LayoutRectE
 __ZN7WebCore12RenderObject19scrollRectToVisibleERKNS_10LayoutRectERKNS_15ScrollAlignmentES6_
 __ZN7WebCore12RenderWidget9setWidgetEN3WTF10PassRefPtrINS_6WidgetEEE

Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (175054 => 175055)


--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2014-10-22 17:41:57 UTC (rev 175054)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2014-10-22 17:43:07 UTC (rev 175055)
@@ -1582,6 +1582,8 @@
 		45BAC2B01360BBAB005DA258 /* IconURL.h in Headers */ = {isa = PBXBuildFile; fileRef = 45BAC2AF1360BBAB005DA258 /* IconURL.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		45FEA5CF156DDE8C00654101 /* Decimal.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 45FEA5CD156DDE8C00654101 /* Decimal.cpp */; };
 		45FEA5D0156DDE8C00654101 /* Decimal.h in Headers */ = {isa = PBXBuildFile; fileRef = 45FEA5CE156DDE8C00654101 /* Decimal.h */; settings = {ATTRIBUTES = (Private, ); }; };
+		4643783119F720EF001E38B3 /* QuickLookMac.h in Headers */ = {isa = PBXBuildFile; fileRef = 4643782F19F720EF001E38B3 /* QuickLookMac.h */; settings = {ATTRIBUTES = (Private, ); }; };
+		4643783219F720EF001E38B3 /* QuickLookMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 4643783019F720EF001E38B3 /* QuickLookMac.mm */; };
 		4689F1AF1267BAE100E8D380 /* FileMetadata.h in Headers */ = {isa = PBXBuildFile; fileRef = 4689F1AE1267BAE100E8D380 /* FileMetadata.h */; };
 		46BD16E30B279473001F0839 /* noneCursor.png in Resources */ = {isa = PBXBuildFile; fileRef = 46BD16E20B279473001F0839 /* noneCursor.png */; };
 		46D4F2490AF97E810035385A /* cellCursor.png in Resources */ = {isa = PBXBuildFile; fileRef = 46D4F2460AF97E810035385A /* cellCursor.png */; };
@@ -8642,6 +8644,8 @@
 		45BAC2AF1360BBAB005DA258 /* IconURL.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IconURL.h; sourceTree = "<group>"; };
 		45FEA5CD156DDE8C00654101 /* Decimal.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Decimal.cpp; sourceTree = "<group>"; };
 		45FEA5CE156DDE8C00654101 /* Decimal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Decimal.h; sourceTree = "<group>"; };
+		4643782F19F720EF001E38B3 /* QuickLookMac.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = QuickLookMac.h; sourceTree = "<group>"; };
+		4643783019F720EF001E38B3 /* QuickLookMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = QuickLookMac.mm; sourceTree = "<group>"; };
 		4689F1AE1267BAE100E8D380 /* FileMetadata.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = FileMetadata.h; path = platform/FileMetadata.h; sourceTree = "<group>"; };
 		46BD16E20B279473001F0839 /* noneCursor.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = noneCursor.png; sourceTree = "<group>"; };
 		46D4F2460AF97E810035385A /* cellCursor.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = cellCursor.png; sourceTree = "<group>"; };
@@ -16428,6 +16432,8 @@
 				BC94D1070C274F88006BC617 /* PlatformScreenMac.mm */,
 				29E4D8E016B0959800C84704 /* PlatformSpeechSynthesizerMac.mm */,
 				0081FEFE16B0A2B6008AAA7A /* PublicSuffixMac.mm */,
+				4643782F19F720EF001E38B3 /* QuickLookMac.h */,
+				4643783019F720EF001E38B3 /* QuickLookMac.mm */,
 				BCAE1FA512939DB7004CB026 /* ScrollAnimatorMac.h */,
 				BC51156D12B1749C00C96754 /* ScrollAnimatorMac.mm */,
 				BC8B853C0E7C7F1100AB6984 /* ScrollbarThemeMac.h */,
@@ -26496,6 +26502,7 @@
 				26F9A83918A046AC00AEB88A /* ViewportConfiguration.h in Headers */,
 				3FFFF9AE159D9B060020BBD5 /* ViewportStyleResolver.h in Headers */,
 				8678D0BB1878E891003ABDE6 /* ViewState.h in Headers */,
+				4643783119F720EF001E38B3 /* QuickLookMac.h in Headers */,
 				93309E20099E64920056E581 /* VisiblePosition.h in Headers */,
 				07AB996918DA3C010018771E /* RTCConfiguration.h in Headers */,
 				A883DF280F3D045D00F19BF6 /* VisibleSelection.h in Headers */,
@@ -29736,6 +29743,7 @@
 				E424A3A01330DF1E00CF6DC9 /* LegacyTileGridTile.mm in Sources */,
 				E4B65A5E132FADB60070E7BE /* LegacyTileLayer.mm in Sources */,
 				E4E39AFD1330EFC6003AB274 /* LegacyTileLayerPool.mm in Sources */,
+				4643783219F720EF001E38B3 /* QuickLookMac.mm in Sources */,
 				498770F21242C535002226BA /* TilingData.cpp in Sources */,
 				F55B3DDB1251F12D003EF269 /* TimeInputType.cpp in Sources */,
 				7553CFE9108F473F00EA281E /* TimelineRecordFactory.cpp in Sources */,

Modified: trunk/Source/WebCore/loader/EmptyClients.h (175054 => 175055)


--- trunk/Source/WebCore/loader/EmptyClients.h	2014-10-22 17:41:57 UTC (rev 175054)
+++ trunk/Source/WebCore/loader/EmptyClients.h	2014-10-22 17:43:07 UTC (rev 175055)
@@ -401,6 +401,10 @@
     virtual void didRequestAutocomplete(PassRefPtr<FormState>) override { }
 #endif
 
+#if PLATFORM(MAC)
+    virtual bool needsQuickLookResourceCachingQuirks() const override { return false; }
+#endif
+
     virtual bool isEmptyFrameLoaderClient() override { return true; }
 };
 

Modified: trunk/Source/WebCore/loader/FrameLoader.cpp (175054 => 175055)


--- trunk/Source/WebCore/loader/FrameLoader.cpp	2014-10-22 17:41:57 UTC (rev 175054)
+++ trunk/Source/WebCore/loader/FrameLoader.cpp	2014-10-22 17:43:07 UTC (rev 175055)
@@ -2152,8 +2152,8 @@
         return CachePolicyRevalidate;
 
     const ResourceRequest& request(documentLoader()->request());
-#if PLATFORM(COCOA)
-    if (request.cachePolicy() == ReloadIgnoringCacheData && !equalIgnoringCase(request.httpMethod(), "post") && ResourceRequest::useQuickLookResourceCachingQuirks())
+#if PLATFORM(MAC)
+    if (request.cachePolicy() == ReloadIgnoringCacheData && !equalIgnoringCase(request.httpMethod(), "post") && m_client.needsQuickLookResourceCachingQuirks())
         return CachePolicyRevalidate;
 #endif
 

Modified: trunk/Source/WebCore/loader/FrameLoaderClient.h (175054 => 175055)


--- trunk/Source/WebCore/loader/FrameLoaderClient.h	2014-10-22 17:41:57 UTC (rev 175054)
+++ trunk/Source/WebCore/loader/FrameLoaderClient.h	2014-10-22 17:43:07 UTC (rev 175055)
@@ -285,6 +285,10 @@
 
         virtual void registerForIconNotification(bool listen = true) = 0;
 
+#if PLATFORM(MAC)
+        virtual bool needsQuickLookResourceCachingQuirks() const = 0;
+#endif
+
 #if PLATFORM(COCOA)
         // Allow an accessibility object to retrieve a Frame parent if there's no PlatformWidget.
         virtual RemoteAXObjectRef accessibilityRemoteObject() = 0;

Modified: trunk/Source/WebCore/platform/RuntimeApplicationChecks.cpp (175054 => 175055)


--- trunk/Source/WebCore/platform/RuntimeApplicationChecks.cpp	2014-10-22 17:41:57 UTC (rev 175054)
+++ trunk/Source/WebCore/platform/RuntimeApplicationChecks.cpp	2014-10-22 17:43:07 UTC (rev 175055)
@@ -57,8 +57,7 @@
 
 bool applicationIsSafari()
 {
-    // FIXME: For the WebProcess case, ensure that this is Safari's WebProcess.
-    static bool isSafari = mainBundleIsEqualTo("com.apple.Safari") || mainBundleIsEqualTo("com.apple.WebProcess");
+    static bool isSafari = mainBundleIsEqualTo("com.apple.Safari");
     return isSafari;
 }
 

Added: trunk/Source/WebCore/platform/mac/QuickLookMac.h (0 => 175055)


--- trunk/Source/WebCore/platform/mac/QuickLookMac.h	                        (rev 0)
+++ trunk/Source/WebCore/platform/mac/QuickLookMac.h	2014-10-22 17:43:07 UTC (rev 175055)
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2014 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef QuickLookMac_h
+#define QuickLookMac_h
+
+namespace WebCore {
+
+class QuickLookMac {
+public:
+    WEBCORE_EXPORT static bool computeNeedsQuickLookResourceCachingQuirks();
+};
+
+} // namespace WebCore
+
+#endif // QuickLookMac_h

Copied: trunk/Source/WebCore/platform/mac/QuickLookMac.mm (from rev 175054, trunk/Source/WebCore/platform/network/mac/ResourceRequestMac.mm) (0 => 175055)


--- trunk/Source/WebCore/platform/mac/QuickLookMac.mm	                        (rev 0)
+++ trunk/Source/WebCore/platform/mac/QuickLookMac.mm	2014-10-22 17:43:07 UTC (rev 175055)
@@ -0,0 +1,51 @@
+/*
+ * Copyright (C) 2006, 2007, 2008, 2014 Apple, Inc.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import "config.h"
+#import "QuickLookMac.h"
+
+#import "RuntimeApplicationChecks.h"
+
+namespace WebCore {
+
+bool QuickLookMac::computeNeedsQuickLookResourceCachingQuirks()
+{
+    if (applicationIsSafari())
+        return false;
+
+    NSArray *frameworks = [NSBundle allFrameworks];
+
+    if (!frameworks)
+        return false;
+
+    for (NSBundle *bundle in frameworks) {
+        const char* bundleID = [[bundle bundleIdentifier] UTF8String];
+        if (bundleID && !strcasecmp(bundleID, "com.apple.QuickLookUIFramework"))
+            return true;
+    }
+    return false;
+}
+
+} // namespace WebCore

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


--- trunk/Source/WebCore/platform/network/cf/ResourceRequest.h	2014-10-22 17:41:57 UTC (rev 175054)
+++ trunk/Source/WebCore/platform/network/cf/ResourceRequest.h	2014-10-22 17:43:07 UTC (rev 175055)
@@ -117,10 +117,6 @@
 
         static bool resourcePrioritiesEnabled();
 
-#if PLATFORM(COCOA)
-        static bool useQuickLookResourceCachingQuirks();
-#endif
-
 #if PLATFORM(IOS)
         // 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

Modified: trunk/Source/WebCore/platform/network/ios/ResourceRequestIOS.mm (175054 => 175055)


--- trunk/Source/WebCore/platform/network/ios/ResourceRequestIOS.mm	2014-10-22 17:41:57 UTC (rev 175054)
+++ trunk/Source/WebCore/platform/network/ios/ResourceRequestIOS.mm	2014-10-22 17:43:07 UTC (rev 175055)
@@ -35,11 +35,6 @@
 
 namespace WebCore {
 
-bool ResourceRequest::useQuickLookResourceCachingQuirks()
-{
-    return false;
-}
-
 #if USE(CFNETWORK)
 
 ResourceRequest::ResourceRequest(NSURLRequest *nsRequest)

Modified: trunk/Source/WebCore/platform/network/mac/ResourceRequestMac.mm (175054 => 175055)


--- trunk/Source/WebCore/platform/network/mac/ResourceRequestMac.mm	2014-10-22 17:41:57 UTC (rev 175054)
+++ trunk/Source/WebCore/platform/network/mac/ResourceRequestMac.mm	2014-10-22 17:43:07 UTC (rev 175055)
@@ -28,8 +28,6 @@
 
 #if PLATFORM(MAC)
 
-#import "RuntimeApplicationChecks.h"
-
 #import <Foundation/Foundation.h>
 
 @interface NSURLRequest (WebNSURLRequestDetails)
@@ -39,31 +37,6 @@
 
 namespace WebCore {
 
-static bool initQuickLookResourceCachingQuirks()
-{
-    if (applicationIsSafari())
-        return false;
-    
-    NSArray* frameworks = [NSBundle allFrameworks];
-    
-    if (!frameworks)
-        return false;
-    
-    for (unsigned int i = 0; i < [frameworks count]; i++) {
-        NSBundle* bundle = [frameworks objectAtIndex: i];
-        const char* bundleID = [[bundle bundleIdentifier] UTF8String];
-        if (bundleID && !strcasecmp(bundleID, "com.apple.QuickLookUIFramework"))
-            return true;
-    }
-    return false;
-}
-
-bool ResourceRequest::useQuickLookResourceCachingQuirks()
-{
-    static bool flag = initQuickLookResourceCachingQuirks();
-    return flag;
-}
-
 #if USE(CFNETWORK)
 
 ResourceRequest::ResourceRequest(NSURLRequest *nsRequest)

Modified: trunk/Source/WebKit/mac/ChangeLog (175054 => 175055)


--- trunk/Source/WebKit/mac/ChangeLog	2014-10-22 17:41:57 UTC (rev 175054)
+++ trunk/Source/WebKit/mac/ChangeLog	2014-10-22 17:43:07 UTC (rev 175055)
@@ -1,3 +1,18 @@
+2014-10-22  Chris Dumez  <[email protected]>
+
+        [Mac][WK2] Fix applicationIsSafari() detection
+        https://bugs.webkit.org/show_bug.cgi?id=137893
+
+        Reviewed by Alexey Proskuryakov.
+
+        Provide an implementation for FrameLoaderClient's new
+        needsQuickLookResourceCachingQuirks() that returns
+        a static flag initialized using
+        QuickLookMac::computeNeedsQuickLookResourceCachingQuirks().
+
+        * WebCoreSupport/WebFrameLoaderClient.h:
+        * WebCoreSupport/WebFrameLoaderClient.mm:
+
 2014-10-20  Chris Dumez  <[email protected]>
 
         ResourceRequest deserialization unnecessarily calls partitionName() on encoded cache partition

Modified: trunk/Source/WebKit/mac/WebCoreSupport/WebFrameLoaderClient.h (175054 => 175055)


--- trunk/Source/WebKit/mac/WebCoreSupport/WebFrameLoaderClient.h	2014-10-22 17:41:57 UTC (rev 175054)
+++ trunk/Source/WebKit/mac/WebCoreSupport/WebFrameLoaderClient.h	2014-10-22 17:43:07 UTC (rev 175055)
@@ -239,6 +239,10 @@
     virtual void didCreateQuickLookHandle(WebCore::QuickLookHandle&) override;
 #endif
 
+#if PLATFORM(MAC)
+    virtual bool needsQuickLookResourceCachingQuirks() const override;
+#endif
+
     virtual void contentFilterDidBlockLoad(std::unique_ptr<WebCore::ContentFilter>) override;
 
     RetainPtr<WebFrame> m_webFrame;

Modified: trunk/Source/WebKit/mac/WebCoreSupport/WebFrameLoaderClient.mm (175054 => 175055)


--- trunk/Source/WebKit/mac/WebCoreSupport/WebFrameLoaderClient.mm	2014-10-22 17:41:57 UTC (rev 175054)
+++ trunk/Source/WebKit/mac/WebCoreSupport/WebFrameLoaderClient.mm	2014-10-22 17:43:07 UTC (rev 175055)
@@ -146,6 +146,8 @@
 #import "WebKitVersionChecks.h"
 #import "WebMailDelegate.h"
 #import "WebUIKitDelegate.h"
+#else
+#import <WebCore/QuickLookMac.h>
 #endif
 
 #if USE(QUICK_LOOK)
@@ -2247,6 +2249,14 @@
 }
 #endif
 
+#if PLATFORM(MAC)
+bool WebFrameLoaderClient::needsQuickLookResourceCachingQuirks() const
+{
+    static const bool shouldUseQuickLookResourceCachingQuirks = QuickLookMac::computeNeedsQuickLookResourceCachingQuirks();
+    return shouldUseQuickLookResourceCachingQuirks;
+}
+#endif
+
 void WebFrameLoaderClient::contentFilterDidBlockLoad(std::unique_ptr<WebCore::ContentFilter> contentFilter)
 {
     m_webFrame->_private->contentFilterForBlockedLoad = WTF::move(contentFilter);

Modified: trunk/Source/WebKit2/ChangeLog (175054 => 175055)


--- trunk/Source/WebKit2/ChangeLog	2014-10-22 17:41:57 UTC (rev 175054)
+++ trunk/Source/WebKit2/ChangeLog	2014-10-22 17:43:07 UTC (rev 175055)
@@ -1,3 +1,34 @@
+2014-10-22  Chris Dumez  <[email protected]>
+
+        [Mac][WK2] Fix applicationIsSafari() detection
+        https://bugs.webkit.org/show_bug.cgi?id=137893
+
+        Reviewed by Alexey Proskuryakov.
+
+        Provide an implementation for FrameLoaderClient's new
+        needsQuickLookResourceCachingQuirks(), which accesses the flag stored
+        on the WebProcess, which is initialized upon WebProcess creation.
+
+        QuickLookMac::computeNeedsQuickLookResourceCachingQuirks() is called
+        on UIProcess side so that it works reliably and the flag is passed as
+        parameter when constructing the WebProcess.
+
+        * Shared/WebProcessCreationParameters.cpp:
+        (WebKit::WebProcessCreationParameters::encode):
+        (WebKit::WebProcessCreationParameters::decode):
+        * Shared/WebProcessCreationParameters.h:
+        * UIProcess/mac/WebContextMac.mm:
+        (WebKit::WebContext::platformInitializeWebProcess):
+        * WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
+        (WebKit::WebFrameLoaderClient::needsQuickLookResourceCachingQuirks):
+        * WebProcess/WebCoreSupport/WebFrameLoaderClient.h:
+        * WebProcess/WebProcess.cpp:
+        (WebKit::WebProcess::WebProcess):
+        * WebProcess/WebProcess.h:
+        (WebKit::WebProcess::needsQuickLookResourceCachingQuirks):
+        * WebProcess/cocoa/WebProcessCocoa.mm:
+        (WebKit::WebProcess::platformInitializeWebProcess):
+
 2014-10-22  Carlos Garcia Campos  <[email protected]>
 
         Unreviewed. Fix GTK+ debug build after r175046.

Modified: trunk/Source/WebKit2/Shared/WebProcessCreationParameters.cpp (175054 => 175055)


--- trunk/Source/WebKit2/Shared/WebProcessCreationParameters.cpp	2014-10-22 17:41:57 UTC (rev 175054)
+++ trunk/Source/WebKit2/Shared/WebProcessCreationParameters.cpp	2014-10-22 17:43:07 UTC (rev 175055)
@@ -106,6 +106,7 @@
 #if PLATFORM(COCOA)
     encoder << presenterApplicationPid;
     encoder << accessibilityEnhancedUserInterfaceEnabled;
+    encoder << needsQuickLookResourceCachingQuirks;
     encoder << nsURLCacheMemoryCapacity;
     encoder << nsURLCacheDiskCapacity;
     encoder << acceleratedCompositingPort;
@@ -230,6 +231,8 @@
         return false;
     if (!decoder.decode(parameters.accessibilityEnhancedUserInterfaceEnabled))
         return false;
+    if (!decoder.decode(parameters.needsQuickLookResourceCachingQuirks))
+        return false;
     if (!decoder.decode(parameters.nsURLCacheMemoryCapacity))
         return false;
     if (!decoder.decode(parameters.nsURLCacheDiskCapacity))

Modified: trunk/Source/WebKit2/Shared/WebProcessCreationParameters.h (175054 => 175055)


--- trunk/Source/WebKit2/Shared/WebProcessCreationParameters.h	2014-10-22 17:41:57 UTC (rev 175054)
+++ trunk/Source/WebKit2/Shared/WebProcessCreationParameters.h	2014-10-22 17:43:07 UTC (rev 175055)
@@ -124,6 +124,7 @@
     pid_t presenterApplicationPid;
 
     bool accessibilityEnhancedUserInterfaceEnabled;
+    bool needsQuickLookResourceCachingQuirks;
 
     uint64_t nsURLCacheMemoryCapacity;
     uint64_t nsURLCacheDiskCapacity;

Modified: trunk/Source/WebKit2/UIProcess/mac/WebContextMac.mm (175054 => 175055)


--- trunk/Source/WebKit2/UIProcess/mac/WebContextMac.mm	2014-10-22 17:41:57 UTC (rev 175054)
+++ trunk/Source/WebKit2/UIProcess/mac/WebContextMac.mm	2014-10-22 17:43:07 UTC (rev 175055)
@@ -54,6 +54,7 @@
 #import <WebCore/RuntimeApplicationChecksIOS.h>
 #else
 #import <QuartzCore/CARemoteLayerServer.h>
+#import <WebCore/QuickLookMac.h>
 #endif
 
 #if PLATFORM(IOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
@@ -175,8 +176,11 @@
 
 #if PLATFORM(MAC)
     parameters.accessibilityEnhancedUserInterfaceEnabled = [[NSApp accessibilityAttributeValue:@"AXEnhancedUserInterface"] boolValue];
+    static const bool shouldUseQuickLookResourceCachingQuirks = QuickLookMac::computeNeedsQuickLookResourceCachingQuirks();
+    parameters.needsQuickLookResourceCachingQuirks = shouldUseQuickLookResourceCachingQuirks;
 #else
     parameters.accessibilityEnhancedUserInterfaceEnabled = false;
+    parameters.needsQuickLookResourceCachingQuirks = false;
 #endif
 
     NSURLCache *urlCache = [NSURLCache sharedURLCache];

Modified: trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp (175054 => 175055)


--- trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp	2014-10-22 17:41:57 UTC (rev 175054)
+++ trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp	2014-10-22 17:43:07 UTC (rev 175055)
@@ -1656,4 +1656,11 @@
 }
 #endif
 
+#if PLATFORM(MAC)
+bool WebFrameLoaderClient::needsQuickLookResourceCachingQuirks() const
+{
+    return WebProcess::shared().needsQuickLookResourceCachingQuirks();
+}
+#endif
+
 } // namespace WebKit

Modified: trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.h (175054 => 175055)


--- trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.h	2014-10-22 17:41:57 UTC (rev 175054)
+++ trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.h	2014-10-22 17:43:07 UTC (rev 175055)
@@ -232,6 +232,10 @@
     virtual void didCreateQuickLookHandle(WebCore::QuickLookHandle&) override;
 #endif
 
+#if PLATFORM(MAC)
+    virtual bool needsQuickLookResourceCachingQuirks() const override;
+#endif
+
 #if ENABLE(CONTENT_FILTERING)
     virtual void contentFilterDidBlockLoad(std::unique_ptr<WebCore::ContentFilter>) override;
 #endif

Modified: trunk/Source/WebKit2/WebProcess/WebProcess.cpp (175054 => 175055)


--- trunk/Source/WebKit2/WebProcess/WebProcess.cpp	2014-10-22 17:41:57 UTC (rev 175054)
+++ trunk/Source/WebKit2/WebProcess/WebProcess.cpp	2014-10-22 17:43:07 UTC (rev 175055)
@@ -155,6 +155,9 @@
     , m_compositingRenderServerPort(MACH_PORT_NULL)
     , m_clearResourceCachesDispatchGroup(0)
 #endif
+#if PLATFORM(MAC)
+    , m_needsQuickLookResourceCachingQuirks(false)
+#endif
     , m_fullKeyboardAccessEnabled(false)
     , m_textCheckerState()
     , m_iconDatabaseProxy(new WebIconDatabaseProxy(this))

Modified: trunk/Source/WebKit2/WebProcess/WebProcess.h (175054 => 175055)


--- trunk/Source/WebKit2/WebProcess/WebProcess.h	2014-10-22 17:41:57 UTC (rev 175054)
+++ trunk/Source/WebKit2/WebProcess/WebProcess.h	2014-10-22 17:43:07 UTC (rev 175055)
@@ -116,6 +116,10 @@
     mach_port_t compositingRenderServerPort() const { return m_compositingRenderServerPort; }
 #endif
 
+#if PLATFORM(MAC)
+    bool needsQuickLookResourceCachingQuirks() const { return m_needsQuickLookResourceCachingQuirks; }
+#endif
+
     bool shouldPlugInAutoStartFromOrigin(const WebPage*, const String& pageOrigin, const String& pluginOrigin, const String& mimeType);
     void plugInDidStartFromOrigin(const String& pageOrigin, const String& pluginOrigin, const String& mimeType, WebCore::SessionID);
     void plugInDidReceiveUserInteraction(const String& pageOrigin, const String& pluginOrigin, const String& mimeType, WebCore::SessionID);
@@ -310,6 +314,9 @@
     dispatch_group_t m_clearResourceCachesDispatchGroup;
     bool m_shouldForceScreenFontSubstitution;
 #endif
+#if PLATFORM(MAC)
+    bool m_needsQuickLookResourceCachingQuirks;
+#endif
 
     bool m_fullKeyboardAccessEnabled;
 

Modified: trunk/Source/WebKit2/WebProcess/cocoa/WebProcessCocoa.mm (175054 => 175055)


--- trunk/Source/WebKit2/WebProcess/cocoa/WebProcessCocoa.mm	2014-10-22 17:41:57 UTC (rev 175054)
+++ trunk/Source/WebKit2/WebProcess/cocoa/WebProcessCocoa.mm	2014-10-22 17:43:07 UTC (rev 175055)
@@ -191,6 +191,9 @@
     MemoryPressureHandler::ReliefLogger::setLoggingEnabled(parameters.shouldEnableMemoryPressureReliefLogging);
 
     setEnhancedAccessibility(parameters.accessibilityEnhancedUserInterfaceEnabled);
+#if PLATFORM(MAC)
+    m_needsQuickLookResourceCachingQuirks = parameters.needsQuickLookResourceCachingQuirks;
+#endif
 
 #if USE(APPKIT)
     [[NSUserDefaults standardUserDefaults] registerDefaults:@{ @"NSApplicationCrashOnExceptions" : @YES }];
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to