Title: [128780] trunk
Revision
128780
Author
[email protected]
Date
2012-09-17 11:19:57 -0700 (Mon, 17 Sep 2012)

Log Message

Fix LoadImagesAutomatically cache behavior
https://bugs.webkit.org/show_bug.cgi?id=96829

Patch by Bo Liu <[email protected]> on 2012-09-17
Reviewed by Adam Barth.

I broke the caching behavior of LoadImagesAutomatically in
http://trac.webkit.org/changeset/128645

This restores the original behavior that AutoLoadImage does not block
loads from memory cache.

Source/WebCore:

Test: fast/loader/display-image-unset-allows-cached-image-load.html

* loader/cache/CachedResourceLoader.cpp:
(WebCore::CachedResourceLoader::determineRevalidationPolicy):
(WebCore::CachedResourceLoader::clientAllowsImage):
(WebCore::CachedResourceLoader::shouldDeferImageLoad):
* loader/cache/CachedResourceLoader.h:
(CachedResourceLoader):

LayoutTests:

* fast/loader/display-image-unset-allows-cached-image-load-expected.txt: Added.
* fast/loader/display-image-unset-allows-cached-image-load.html: Added.
* fast/loader/resources/image1.html: Added.
* fast/loader/resources/image2.html: Added.
* platform/wk2/Skipped:

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (128779 => 128780)


--- trunk/LayoutTests/ChangeLog	2012-09-17 18:17:10 UTC (rev 128779)
+++ trunk/LayoutTests/ChangeLog	2012-09-17 18:19:57 UTC (rev 128780)
@@ -1,3 +1,22 @@
+2012-09-17  Bo Liu  <[email protected]>
+
+        Fix LoadImagesAutomatically cache behavior
+        https://bugs.webkit.org/show_bug.cgi?id=96829
+
+        Reviewed by Adam Barth.
+
+        I broke the caching behavior of LoadImagesAutomatically in
+        http://trac.webkit.org/changeset/128645
+
+        This restores the original behavior that AutoLoadImage does not block
+        loads from memory cache.
+
+        * fast/loader/display-image-unset-allows-cached-image-load-expected.txt: Added.
+        * fast/loader/display-image-unset-allows-cached-image-load.html: Added.
+        * fast/loader/resources/image1.html: Added.
+        * fast/loader/resources/image2.html: Added.
+        * platform/wk2/Skipped:
+
 2012-09-17  János Badics  <[email protected]>
 
         [Qt]REGRESSION(r128699): It made 2 fast/js/dfg tests assert

Added: trunk/LayoutTests/fast/loader/display-image-unset-allows-cached-image-load-expected.txt (0 => 128780)


--- trunk/LayoutTests/fast/loader/display-image-unset-allows-cached-image-load-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/loader/display-image-unset-allows-cached-image-load-expected.txt	2012-09-17 18:19:57 UTC (rev 128780)
@@ -0,0 +1,2 @@
+Test that WebKitDisplayImagesKey unset does not block image in cache.
+PASS

Added: trunk/LayoutTests/fast/loader/display-image-unset-allows-cached-image-load.html (0 => 128780)


--- trunk/LayoutTests/fast/loader/display-image-unset-allows-cached-image-load.html	                        (rev 0)
+++ trunk/LayoutTests/fast/loader/display-image-unset-allows-cached-image-load.html	2012-09-17 18:19:57 UTC (rev 128780)
@@ -0,0 +1,39 @@
+<html>
+<head>
+<script>
+// Opens two windows containing the same image. First window will populate the cache with
+// image. The second window is opened with WebKitDisplayImagesKey unset, but image should
+// still load since it is in cache.
+function runTest()
+{
+    if (window.testRunner) {
+        testRunner.dumpAsText();
+        testRunner.waitUntilDone();
+        testRunner.setCanOpenWindows();
+        testRunner.overridePreference("WebKitUsesPageCachePreferenceKey", 1);
+
+        document.getElementById('result').innerHTML = 'FAILURE: image1.html not loaded';
+        window.open("resources/image1.html", "_blank");
+    }
+}
+
+function image1Loaded()
+{
+    testRunner.overridePreference('WebKitDisplayImagesKey', 0);
+    document.getElementById('result').innerHTML = 'FAILURE: image2.html not loaded';
+    window.setTimeout(function() {window.open("resources/image2.html", "_blank");}, 0);
+}
+
+function image2Loaded()
+{
+    document.getElementById('result').innerHTML = 'PASS';
+		testRunner.notifyDone();
+}
+</script>
+</head>
+<body _onload_="runTest()">
+Test that WebKitDisplayImagesKey unset does not block image in cache.
+<div id="result">FAILURE: Test script didn't run.</div>
+</body>
+</html>
+

Added: trunk/LayoutTests/fast/loader/resources/image1.html (0 => 128780)


--- trunk/LayoutTests/fast/loader/resources/image1.html	                        (rev 0)
+++ trunk/LayoutTests/fast/loader/resources/image1.html	2012-09-17 18:19:57 UTC (rev 128780)
@@ -0,0 +1,5 @@
+<html>
+<body>
+  <img src="" _onload_="window.opener.image1Loaded();">
+</body>
+</html>

Added: trunk/LayoutTests/fast/loader/resources/image2.html (0 => 128780)


--- trunk/LayoutTests/fast/loader/resources/image2.html	                        (rev 0)
+++ trunk/LayoutTests/fast/loader/resources/image2.html	2012-09-17 18:19:57 UTC (rev 128780)
@@ -0,0 +1,5 @@
+<html>
+<body>
+  <img src="" _onload_="window.opener.image2Loaded();">
+</body>
+</html>

Modified: trunk/LayoutTests/platform/wk2/Skipped (128779 => 128780)


--- trunk/LayoutTests/platform/wk2/Skipped	2012-09-17 18:17:10 UTC (rev 128779)
+++ trunk/LayoutTests/platform/wk2/Skipped	2012-09-17 18:19:57 UTC (rev 128780)
@@ -201,6 +201,7 @@
 fast/canvas/webgl/webgl-specific.html
 fast/harness/override-preferences-2.html
 fast/images/animated-gif-restored-from-bfcache.html
+fast/loader/display-image-unset-allows-cached-image-load.html
 fast/text/zero-font-size.html
 
 # WebKitTestRunner needs to support layoutTestController.dumpDOMAsWebArchive

Modified: trunk/Source/WebCore/ChangeLog (128779 => 128780)


--- trunk/Source/WebCore/ChangeLog	2012-09-17 18:17:10 UTC (rev 128779)
+++ trunk/Source/WebCore/ChangeLog	2012-09-17 18:19:57 UTC (rev 128780)
@@ -1,3 +1,25 @@
+2012-09-17  Bo Liu  <[email protected]>
+
+        Fix LoadImagesAutomatically cache behavior
+        https://bugs.webkit.org/show_bug.cgi?id=96829
+
+        Reviewed by Adam Barth.
+
+        I broke the caching behavior of LoadImagesAutomatically in
+        http://trac.webkit.org/changeset/128645
+
+        This restores the original behavior that AutoLoadImage does not block
+        loads from memory cache.
+
+        Test: fast/loader/display-image-unset-allows-cached-image-load.html
+
+        * loader/cache/CachedResourceLoader.cpp:
+        (WebCore::CachedResourceLoader::determineRevalidationPolicy):
+        (WebCore::CachedResourceLoader::clientAllowsImage):
+        (WebCore::CachedResourceLoader::shouldDeferImageLoad):
+        * loader/cache/CachedResourceLoader.h:
+        (CachedResourceLoader):
+
 2012-09-17  Andrei Poenaru  <[email protected]>
 
         Web Inspector: Display Named Flows in the Tabbed Pane of the "CSS Named Flows" Drawer

Modified: trunk/Source/WebCore/loader/cache/CachedResourceLoader.cpp (128779 => 128780)


--- trunk/Source/WebCore/loader/cache/CachedResourceLoader.cpp	2012-09-17 18:17:10 UTC (rev 128779)
+++ trunk/Source/WebCore/loader/cache/CachedResourceLoader.cpp	2012-09-17 18:19:57 UTC (rev 128780)
@@ -532,7 +532,7 @@
 
     // Do not load from cache if images are not enabled. The load for this image will be blocked
     // in requestImage.
-    if (existingResource->type() == CachedResource::ImageResource && shouldDeferImageLoad(existingResource->url()))
+    if (existingResource->type() == CachedResource::ImageResource && !clientAllowsImage(existingResource->url()))
         return Reload;
     
     // Don't reload resources while pasting.
@@ -646,12 +646,14 @@
     reloadImagesIfNotDeferred();
 }
 
+bool CachedResourceLoader::clientAllowsImage(const KURL& url) const
+{
+    return !frame() || frame()->loader()->client()->allowImage(m_imagesEnabled, url);
+}
+
 bool CachedResourceLoader::shouldDeferImageLoad(const KURL& url) const
 {
-    if (frame() && !frame()->loader()->client()->allowImage(m_imagesEnabled, url))
-        return true;
-
-    return !m_autoLoadImages;
+    return !clientAllowsImage(url) || !m_autoLoadImages;
 }
 
 void CachedResourceLoader::reloadImagesIfNotDeferred()

Modified: trunk/Source/WebCore/loader/cache/CachedResourceLoader.h (128779 => 128780)


--- trunk/Source/WebCore/loader/cache/CachedResourceLoader.h	2012-09-17 18:17:10 UTC (rev 128779)
+++ trunk/Source/WebCore/loader/cache/CachedResourceLoader.h	2012-09-17 18:19:57 UTC (rev 128780)
@@ -98,7 +98,6 @@
     bool autoLoadImages() const { return m_autoLoadImages; }
     void setAutoLoadImages(bool);
 
-    bool imagesEnabled() const { return m_imagesEnabled; }
     void setImagesEnabled(bool);
 
     bool shouldDeferImageLoad(const KURL&) const;
@@ -141,6 +140,7 @@
     void garbageCollectDocumentResourcesTimerFired(Timer<CachedResourceLoader>*);
     void performPostLoadActions();
 
+    bool clientAllowsImage(const KURL&) const;
     void reloadImagesIfNotDeferred();
     
     HashSet<String> m_validatedURLs;
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to