Source/WebCore: Don't include CachedResources that haven't downloaded when populating...
authortimothy@apple.com <timothy@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 14 Feb 2012 18:44:58 +0000 (18:44 +0000)
committertimothy@apple.com <timothy@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 14 Feb 2012 18:44:58 +0000 (18:44 +0000)
https://webkit.org/b/78447
rdar://problem/10843542

Reviewed by Brian Weinstein.

Test: inspector/protocol/page-agent.html

* inspector/InspectorPageAgent.cpp:
(WebCore::InspectorPageAgent::cachedResourcesForFrame): Skip CachedFonts and CachedImages that
return true for stillNeedsLoad.
* loader/cache/CachedFont.h:
(WebCore::CachedFont::stillNeedsLoad): Added.

LayoutTests: Updated test results to exclude CachedResources that haven't downloaded.

https://webkit.org/b/78447
rdar://problem/10843542

Reviewed by Brian Weinstein.

* inspector/protocol/page-agent-expected.txt: Updated. There is now only one font list
in the resources, when there was incorrectly two being listed. Only the font being used
is the one that downloaded and is listed now.

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

LayoutTests/ChangeLog
LayoutTests/inspector/protocol/page-agent-expected.txt
Source/WebCore/ChangeLog
Source/WebCore/inspector/InspectorPageAgent.cpp
Source/WebCore/loader/cache/CachedFont.h

index 67978ee..6d740d1 100644 (file)
@@ -1,5 +1,18 @@
 2012-02-14  Timothy Hatcher  <timothy@apple.com>
 
+        Updated test results to exclude CachedResources that haven't downloaded.
+
+        https://webkit.org/b/78447
+        rdar://problem/10843542
+
+        Reviewed by Brian Weinstein.
+
+        * inspector/protocol/page-agent-expected.txt: Updated. There is now only one font list
+        in the resources, when there was incorrectly two being listed. Only the font being used
+        is the one that downloaded and is listed now.
+
+2012-02-14  Timothy Hatcher  <timothy@apple.com>
+
         Test for Web Inspector: include failed and canceled in FrameResourceTree.
 
         https://webkit.org/b/78445
index 63bd619..ad9df99 100644 (file)
@@ -77,11 +77,6 @@ response:
                 }
                 {
                     url : <string>
-                    type : "Font"
-                    mimeType : ""
-                }
-                {
-                    url : <string>
                     type : "Script"
                     mimeType : "text/javascript"
                 }
index 3f8f1e7..0fba182 100644 (file)
@@ -1,5 +1,22 @@
 2012-02-12  Timothy Hatcher  <timothy@apple.com>
 
+        Don't include CachedResources that haven't downloaded when populating the Web Inspector on load.
+
+        https://webkit.org/b/78447
+        rdar://problem/10843542
+
+        Reviewed by Brian Weinstein.
+
+        Test: inspector/protocol/page-agent.html
+
+        * inspector/InspectorPageAgent.cpp:
+        (WebCore::InspectorPageAgent::cachedResourcesForFrame): Skip CachedFonts and CachedImages that
+        return true for stillNeedsLoad.
+        * loader/cache/CachedFont.h:
+        (WebCore::CachedFont::stillNeedsLoad): Added.
+
+2012-02-12  Timothy Hatcher  <timothy@apple.com>
+
         Web Inspector: include failed and canceled in FrameResourceTree.
 
         https://webkit.org/b/78445
index 00ad39c..3bf46d2 100644 (file)
@@ -36,6 +36,8 @@
 
 #include "Base64.h"
 #include "CachedCSSStyleSheet.h"
+#include "CachedFont.h"
+#include "CachedImage.h"
 #include "CachedResource.h"
 #include "CachedResourceLoader.h"
 #include "CachedScript.h"
@@ -394,8 +396,27 @@ static Vector<CachedResource*> cachedResourcesForFrame(Frame* frame)
 
     const CachedResourceLoader::DocumentResourceMap& allResources = frame->document()->cachedResourceLoader()->allCachedResources();
     CachedResourceLoader::DocumentResourceMap::const_iterator end = allResources.end();
-    for (CachedResourceLoader::DocumentResourceMap::const_iterator it = allResources.begin(); it != end; ++it)
-        result.append(it->second.get());
+    for (CachedResourceLoader::DocumentResourceMap::const_iterator it = allResources.begin(); it != end; ++it) {
+        CachedResource* cachedResource = it->second.get();
+
+        switch (cachedResource->type()) {
+        case CachedResource::ImageResource:
+            // Skip images that were not auto loaded (images disabled in the user agent).
+            if (static_cast<CachedImage*>(cachedResource)->stillNeedsLoad())
+                continue;
+            break;
+        case CachedResource::FontResource:
+            // Skip fonts that were referenced in CSS but never used/downloaded.
+            if (static_cast<CachedFont*>(cachedResource)->stillNeedsLoad())
+                continue;
+            break;
+        default:
+            // All other CachedResource types download immediately.
+            break;
+        }
+
+        result.append(cachedResource);
+    }
 
     return result;
 }
index f857dad..e0b5b7d 100644 (file)
@@ -60,6 +60,7 @@ public:
     void checkNotify();
 
     void beginLoadIfNeeded(CachedResourceLoader* dl);
+    bool stillNeedsLoad() const { return !m_loadInitiated; }
 
     bool ensureCustomFontData();
     FontPlatformData platformDataFromCustomData(float size, bool bold, bool italic, FontOrientation = Horizontal, TextOrientation = TextOrientationVerticalRight, FontWidthVariant = RegularWidth, FontRenderingMode = NormalRenderingMode);