2010-10-21 Pavel Feldman <pfeldman@chromium.org>
authorpfeldman@chromium.org <pfeldman@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 21 Oct 2010 16:31:35 +0000 (16:31 +0000)
committerpfeldman@chromium.org <pfeldman@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 21 Oct 2010 16:31:35 +0000 (16:31 +0000)
        Reviewed by Yury Semikhatsky.

        Web Inspector: provide resource tree in the Storage panel (behind the flag).
        https://bugs.webkit.org/show_bug.cgi?id=48069

        * WebCore.gypi:
        * inspector/Inspector.idl:
        * inspector/InspectorController.cpp:
        (WebCore::InspectorController::frameDetachedFromParent):
        * inspector/InspectorResourceAgent.cpp:
        (WebCore::buildObjectForDocumentLoader):
        (WebCore::buildObjectForFrameResource):
        (WebCore::buildObjectForCachedResource):
        (WebCore::populateObjectWithFrameResources):
        (WebCore::InspectorResourceAgent::identifierForInitialRequest):
        (WebCore::InspectorResourceAgent::didLoadResourceFromMemoryCache):
        (WebCore::buildObjectForFrameTree):
        (WebCore::InspectorResourceAgent::didCommitLoad):
        (WebCore::InspectorResourceAgent::frameDetachedFromParent):
        (WebCore::InspectorResourceAgent::cachedResources):
        (WebCore::InspectorResourceAgent::resourceContent):
        * inspector/InspectorResourceAgent.h:
        * inspector/front-end/Images/frame.png: Added.
        * inspector/front-end/NetworkPanel.js:
        (WebInspector.NetworkPanel.prototype.refreshResource):
        (WebInspector.NetworkPanel.prototype._showResource):
        * inspector/front-end/Resource.js:
        (WebInspector.Resource.Type.toString):
        (WebInspector.Resource.prototype.getContents):
        * inspector/front-end/ResourceManager.js:
        (WebInspector.ResourceManager):
        (WebInspector.ResourceManager.prototype.identifierForInitialRequest):
        (WebInspector.ResourceManager.prototype._createResource):
        (WebInspector.ResourceManager.prototype.willSendRequest):
        (WebInspector.ResourceManager.prototype._appendRedirect):
        (WebInspector.ResourceManager.prototype.markResourceAsCached):
        (WebInspector.ResourceManager.prototype.didReceiveResponse):
        (WebInspector.ResourceManager.prototype._updateResourceWithResponse):
        (WebInspector.ResourceManager.prototype.didReceiveContentLength):
        (WebInspector.ResourceManager.prototype.didFinishLoading):
        (WebInspector.ResourceManager.prototype.didFailLoading):
        (WebInspector.ResourceManager.prototype.didLoadResourceFromMemoryCache):
        (WebInspector.ResourceManager.prototype._updateResourceWithCachedResource):
        (WebInspector.ResourceManager.prototype.setOverrideContent):
        (WebInspector.ResourceManager.prototype.didCommitLoadForFrame):
        (WebInspector.ResourceManager.prototype.frameDetachedFromParent):
        (WebInspector.ResourceManager.prototype._clearResources):
        (WebInspector.ResourceManager.prototype.didCreateWebSocket):
        (WebInspector.ResourceManager.prototype.willSendWebSocketHandshakeRequest):
        (WebInspector.ResourceManager.prototype.didReceiveWebSocketHandshakeResponse):
        (WebInspector.ResourceManager.prototype.didCloseWebSocket):
        (WebInspector.ResourceManager.prototype._processCachedResources):
        (WebInspector.ResourceManager.prototype._appendFramesRecursively.comparator):
        (WebInspector.ResourceManager.prototype._appendFramesRecursively):
        (WebInspector.ResourceManager.createResourceView):
        (WebInspector.ResourceManager.resourceViewTypeMatchesResource):
        (WebInspector.ResourceManager.resourceViewForResource):
        (WebInspector.ResourceManager.getContents):
        * inspector/front-end/ResourcesPanel.js:
        (WebInspector.ResourcesPanel.prototype.get searchableViews):
        (WebInspector.ResourcesPanel.prototype.addMessageToResource):
        (WebInspector.ResourcesPanel.prototype._recreateViewForResourceIfNeeded):
        (WebInspector.ResourcesPanel.prototype.showResource):
        (WebInspector.ResourcesPanel.prototype.sourceFrameForResource):
        * inspector/front-end/ScriptsPanel.js:
        (WebInspector.ScriptsPanel.prototype._showScriptOrResource):
        * inspector/front-end/StoragePanel.js:
        (WebInspector.StoragePanel):
        (WebInspector.StoragePanel.prototype.addFrame):
        (WebInspector.StoragePanel.prototype.removeFrame):
        (WebInspector.StoragePanel.prototype.addFrameResource):
        (WebInspector.StoragePanel.prototype.removeFrameResources):
        (WebInspector.StoragePanel.prototype.showResource):
        (WebInspector.BaseStorageTreeElement.prototype.onattach):
        (WebInspector.BaseStorageTreeElement.prototype.onreveal):
        (WebInspector.FrameTreeElement):
        (WebInspector.FrameTreeElement.prototype.onselect):
        (WebInspector.FrameResourceTreeElement):
        (WebInspector.FrameResourceTreeElement.prototype.onselect):
        (WebInspector.FrameResourceTreeElement.prototype.onattach):
        * inspector/front-end/WebKit.qrc:
        * inspector/front-end/inspector.css:
        (.frame-storage-tree-item .icon):
        (.storage.panel .sidebar.outline-disclosure > ol):
        (.resources-category-images .image-resource-icon-preview):
        (.children.small .resources-category-images .image-resource-icon-preview):
        * inspector/front-end/inspector.js:

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

16 files changed:
WebCore/ChangeLog
WebCore/WebCore.gypi
WebCore/inspector/Inspector.idl
WebCore/inspector/InspectorController.cpp
WebCore/inspector/InspectorResourceAgent.cpp
WebCore/inspector/InspectorResourceAgent.h
WebCore/inspector/front-end/Images/frame.png [new file with mode: 0644]
WebCore/inspector/front-end/NetworkPanel.js
WebCore/inspector/front-end/Resource.js
WebCore/inspector/front-end/ResourceManager.js
WebCore/inspector/front-end/ResourcesPanel.js
WebCore/inspector/front-end/ScriptsPanel.js
WebCore/inspector/front-end/StoragePanel.js
WebCore/inspector/front-end/WebKit.qrc
WebCore/inspector/front-end/inspector.css
WebCore/inspector/front-end/inspector.js

index 3bcb9d9..198bc7e 100644 (file)
@@ -1,3 +1,93 @@
+2010-10-21  Pavel Feldman  <pfeldman@chromium.org>
+
+        Reviewed by Yury Semikhatsky.
+
+        Web Inspector: provide resource tree in the Storage panel (behind the flag).
+        https://bugs.webkit.org/show_bug.cgi?id=48069
+
+        * WebCore.gypi:
+        * inspector/Inspector.idl:
+        * inspector/InspectorController.cpp:
+        (WebCore::InspectorController::frameDetachedFromParent):
+        * inspector/InspectorResourceAgent.cpp:
+        (WebCore::buildObjectForDocumentLoader):
+        (WebCore::buildObjectForFrameResource):
+        (WebCore::buildObjectForCachedResource):
+        (WebCore::populateObjectWithFrameResources):
+        (WebCore::InspectorResourceAgent::identifierForInitialRequest):
+        (WebCore::InspectorResourceAgent::didLoadResourceFromMemoryCache):
+        (WebCore::buildObjectForFrameTree):
+        (WebCore::InspectorResourceAgent::didCommitLoad):
+        (WebCore::InspectorResourceAgent::frameDetachedFromParent):
+        (WebCore::InspectorResourceAgent::cachedResources):
+        (WebCore::InspectorResourceAgent::resourceContent):
+        * inspector/InspectorResourceAgent.h:
+        * inspector/front-end/Images/frame.png: Added.
+        * inspector/front-end/NetworkPanel.js:
+        (WebInspector.NetworkPanel.prototype.refreshResource):
+        (WebInspector.NetworkPanel.prototype._showResource):
+        * inspector/front-end/Resource.js:
+        (WebInspector.Resource.Type.toString):
+        (WebInspector.Resource.prototype.getContents):
+        * inspector/front-end/ResourceManager.js:
+        (WebInspector.ResourceManager):
+        (WebInspector.ResourceManager.prototype.identifierForInitialRequest):
+        (WebInspector.ResourceManager.prototype._createResource):
+        (WebInspector.ResourceManager.prototype.willSendRequest):
+        (WebInspector.ResourceManager.prototype._appendRedirect):
+        (WebInspector.ResourceManager.prototype.markResourceAsCached):
+        (WebInspector.ResourceManager.prototype.didReceiveResponse):
+        (WebInspector.ResourceManager.prototype._updateResourceWithResponse):
+        (WebInspector.ResourceManager.prototype.didReceiveContentLength):
+        (WebInspector.ResourceManager.prototype.didFinishLoading):
+        (WebInspector.ResourceManager.prototype.didFailLoading):
+        (WebInspector.ResourceManager.prototype.didLoadResourceFromMemoryCache):
+        (WebInspector.ResourceManager.prototype._updateResourceWithCachedResource):
+        (WebInspector.ResourceManager.prototype.setOverrideContent):
+        (WebInspector.ResourceManager.prototype.didCommitLoadForFrame):
+        (WebInspector.ResourceManager.prototype.frameDetachedFromParent):
+        (WebInspector.ResourceManager.prototype._clearResources):
+        (WebInspector.ResourceManager.prototype.didCreateWebSocket):
+        (WebInspector.ResourceManager.prototype.willSendWebSocketHandshakeRequest):
+        (WebInspector.ResourceManager.prototype.didReceiveWebSocketHandshakeResponse):
+        (WebInspector.ResourceManager.prototype.didCloseWebSocket):
+        (WebInspector.ResourceManager.prototype._processCachedResources):
+        (WebInspector.ResourceManager.prototype._appendFramesRecursively.comparator):
+        (WebInspector.ResourceManager.prototype._appendFramesRecursively):
+        (WebInspector.ResourceManager.createResourceView):
+        (WebInspector.ResourceManager.resourceViewTypeMatchesResource):
+        (WebInspector.ResourceManager.resourceViewForResource):
+        (WebInspector.ResourceManager.getContents):
+        * inspector/front-end/ResourcesPanel.js:
+        (WebInspector.ResourcesPanel.prototype.get searchableViews):
+        (WebInspector.ResourcesPanel.prototype.addMessageToResource):
+        (WebInspector.ResourcesPanel.prototype._recreateViewForResourceIfNeeded):
+        (WebInspector.ResourcesPanel.prototype.showResource):
+        (WebInspector.ResourcesPanel.prototype.sourceFrameForResource):
+        * inspector/front-end/ScriptsPanel.js:
+        (WebInspector.ScriptsPanel.prototype._showScriptOrResource):
+        * inspector/front-end/StoragePanel.js:
+        (WebInspector.StoragePanel):
+        (WebInspector.StoragePanel.prototype.addFrame):
+        (WebInspector.StoragePanel.prototype.removeFrame):
+        (WebInspector.StoragePanel.prototype.addFrameResource):
+        (WebInspector.StoragePanel.prototype.removeFrameResources):
+        (WebInspector.StoragePanel.prototype.showResource):
+        (WebInspector.BaseStorageTreeElement.prototype.onattach):
+        (WebInspector.BaseStorageTreeElement.prototype.onreveal):
+        (WebInspector.FrameTreeElement):
+        (WebInspector.FrameTreeElement.prototype.onselect):
+        (WebInspector.FrameResourceTreeElement):
+        (WebInspector.FrameResourceTreeElement.prototype.onselect):
+        (WebInspector.FrameResourceTreeElement.prototype.onattach):
+        * inspector/front-end/WebKit.qrc:
+        * inspector/front-end/inspector.css:
+        (.frame-storage-tree-item .icon):
+        (.storage.panel .sidebar.outline-disclosure > ol):
+        (.resources-category-images .image-resource-icon-preview):
+        (.children.small .resources-category-images .image-resource-icon-preview):
+        * inspector/front-end/inspector.js:
+
 2010-10-21  David Kilzer  <ddkilzer@apple.com>
 
         <http://webkit.org/b/48047> Fix warnings found by check-Xcode-source-file-types
index 705a430..a1a96e1 100644 (file)
             'inspector/front-end/Images/excludeButtonGlyph.png',
             'inspector/front-end/Images/focusButtonGlyph.png',
             'inspector/front-end/Images/forward.png',
+            'inspector/front-end/Images/frame.png',
             'inspector/front-end/Images/gearButtonGlyph.png',
             'inspector/front-end/Images/glossyHeader.png',
             'inspector/front-end/Images/glossyHeaderPressed.png',
index 85c30a8..b5a4388 100644 (file)
@@ -112,19 +112,19 @@ module core {
         [handler=Controller] void startTimelineProfiler();
         [handler=Controller] void stopTimelineProfiler();
 
-        [handler=Resource] void cachedResources(out Array resources);
-        [handler=Resource] void resourceContent(in unsigned long frameID, in String url, out String content);
-        [notify] void identifierForInitialRequest(out long identifier, out String url, out unsigned long frameID, out boolean isMainResource);
+        [handler=Resource] void cachedResources(out Object resources);
+        [handler=Resource] void resourceContent(in unsigned long frameId, in String url, out String content);
+        [notify] void identifierForInitialRequest(out long identifier, out String url, out Object loader, out boolean isMainResource);
         [notify] void willSendRequest(out long identifier, out double time, out Object request, out Object redirectResponse);
         [notify] void markResourceAsCached(out long identifier);
         [notify] void didReceiveResponse(out long identifier, out double time, out String resourceType, out Object response);
         [notify] void didReceiveContentLength(out long identifier, out double time, out long lengthReceived);
         [notify] void didFinishLoading(out long identifier, out double finishTime);
         [notify] void didFailLoading(out long identifier, out double time, out String localizedDescription);
-        [notify] void didLoadResourceFromMemoryCache(out double time, out unsigned long frameID, out Object resource);
+        [notify] void didLoadResourceFromMemoryCache(out double time, out Object resource);
         [notify] void setOverrideContent(out long identifier, out String sourceString, out String type);
-        [notify] void didCommitLoad(out unsigned long frameID);
-        [notify] void frameDetachedFromParent(out unsigned long frameID);
+        [notify] void didCommitLoadForFrame(out Object frameTree, out unsigned long loaderId);
+        [notify] void frameDetachedFromParent(out Object frameTree);
 
         [notify] void didCreateWebSocket(out unsigned long identifier, out String requestURL);
         [notify] void willSendWebSocketHandshakeRequest(out unsigned long identifier, out double time, out Object request);
index f99d487..00a1166 100644 (file)
@@ -826,16 +826,17 @@ void InspectorController::didCommitLoad(DocumentLoader* loader)
             pruneResources(resourceMap, loader);
 }
 
-void InspectorController::frameDetachedFromParent(Frame* frame)
+void InspectorController::frameDetachedFromParent(Frame* rootFrame)
 {
     if (!enabled())
         return;
 
     if (m_resourceAgent)
-        m_resourceAgent->frameDetachedFromParent(frame);
+        m_resourceAgent->frameDetachedFromParent(rootFrame);
 
-    if (ResourcesMap* resourceMap = m_frameResources.get(frame))
-        removeAllResources(resourceMap);
+    for (Frame* frame = rootFrame; frame; frame = frame->tree()->traverseNext(rootFrame))
+        if (ResourcesMap* resourceMap = m_frameResources.get(frame))
+            removeAllResources(resourceMap);
 }
 
 void InspectorController::addResource(InspectorResource* resource)
index f49e1d7..0df3e87 100644 (file)
@@ -199,17 +199,22 @@ static PassRefPtr<InspectorObject> buildObjectForResourceResponse(const Resource
     return responseObject;
 }
 
-static PassRefPtr<InspectorObject> buildObjectForMainResource(Frame* frame)
+static PassRefPtr<InspectorObject> buildObjectForDocumentLoader(DocumentLoader* loader)
+{
+    RefPtr<InspectorObject> documentLoaderObject = InspectorObject::create();
+    documentLoaderObject->setNumber("frameId", reinterpret_cast<uintptr_t>(loader->frame()));
+    documentLoaderObject->setNumber("loaderId", reinterpret_cast<uintptr_t>(loader));
+    return documentLoaderObject;
+}
+
+static PassRefPtr<InspectorObject> buildObjectForFrameResource(Frame* frame)
 {
     FrameLoader* frameLoader = frame->loader();
     DocumentLoader* loader = frameLoader->documentLoader();
 
     RefPtr<InspectorObject> resourceObject = InspectorObject::create();
     resourceObject->setString("url", loader->url().string());
-    resourceObject->setString("host", loader->url().host());
-    resourceObject->setString("path", loader->url().path());
-    resourceObject->setString("lastPathComponent", loader->url().lastPathComponent());
-    resourceObject->setString("type", "Document");
+    resourceObject->setObject("loader", buildObjectForDocumentLoader(loader));
     resourceObject->setObject("request", buildObjectForResourceRequest(loader->request()));
     resourceObject->setObject("response", buildObjectForResourceResponse(loader->response()));
     return resourceObject;
@@ -236,21 +241,20 @@ static String cachedResourceTypeString(const CachedResource& cachedResource)
     }
 }
 
-static PassRefPtr<InspectorObject> buildObjectForCachedResource(const CachedResource& cachedResource)
+static PassRefPtr<InspectorObject> buildObjectForCachedResource(DocumentLoader* loader, const CachedResource& cachedResource)
 {
     RefPtr<InspectorObject> resourceObject = InspectorObject::create();
     resourceObject->setString("url", cachedResource.url());
     resourceObject->setString("type", cachedResourceTypeString(cachedResource));
     resourceObject->setNumber("encodedSize", cachedResource.encodedSize());
     resourceObject->setObject("response", buildObjectForResourceResponse(cachedResource.response()));
+    resourceObject->setObject("loader", buildObjectForDocumentLoader(loader));
     return resourceObject;
 }
 
-static PassRefPtr<InspectorObject> buildObjectForFrameResources(Frame* frame)
+static void populateObjectWithFrameResources(Frame* frame, PassRefPtr<InspectorObject> frameResources)
 {
-    RefPtr<InspectorObject> frameResources = InspectorObject::create();
-    frameResources->setNumber("frameID", reinterpret_cast<uintptr_t>(frame));
-    frameResources->setObject("mainResource", buildObjectForMainResource(frame));
+    frameResources->setObject("resource", buildObjectForFrameResource(frame));
     RefPtr<InspectorArray> subresources = InspectorArray::create();
     frameResources->setArray("subresources", subresources);
 
@@ -258,10 +262,11 @@ static PassRefPtr<InspectorObject> buildObjectForFrameResources(Frame* frame)
     CachedResourceLoader::DocumentResourceMap::const_iterator end = allResources.end();
     for (CachedResourceLoader::DocumentResourceMap::const_iterator it = allResources.begin(); it != end; ++it) {
         CachedResource* cachedResource = it->second.get();
-        if (cachedResource)
-            subresources->pushValue(buildObjectForCachedResource(*cachedResource));
+        if (cachedResource) {
+            RefPtr<InspectorObject> cachedResourceObject = buildObjectForCachedResource(frame->loader()->documentLoader(), *cachedResource);
+            subresources->pushValue(cachedResourceObject);
+        }
     }
-    return frameResources;
 }
 
 InspectorResourceAgent::~InspectorResourceAgent()
@@ -270,7 +275,8 @@ InspectorResourceAgent::~InspectorResourceAgent()
 
 void InspectorResourceAgent::identifierForInitialRequest(unsigned long identifier, const KURL& url, DocumentLoader* loader, bool isMainResource)
 {
-    m_frontend->identifierForInitialRequest(identifier, url.string(), reinterpret_cast<uintptr_t>(loader->frame()), isMainResource);
+    RefPtr<InspectorObject> loaderObject = buildObjectForDocumentLoader(loader);
+    m_frontend->identifierForInitialRequest(identifier, url.string(), loaderObject, isMainResource);
 }
 
 void InspectorResourceAgent::willSendRequest(unsigned long identifier, ResourceRequest& request, const ResourceResponse& redirectResponse)
@@ -321,8 +327,7 @@ void InspectorResourceAgent::didFailLoading(unsigned long identifier, const Reso
 
 void InspectorResourceAgent::didLoadResourceFromMemoryCache(DocumentLoader* loader, const CachedResource* resource)
 {
-    Frame* frame = loader->frame();
-    m_frontend->didLoadResourceFromMemoryCache(currentTime(), reinterpret_cast<uintptr_t>(frame), buildObjectForCachedResource(*resource));
+    m_frontend->didLoadResourceFromMemoryCache(currentTime(), buildObjectForCachedResource(loader, *resource));
 }
 
 void InspectorResourceAgent::setOverrideContent(unsigned long identifier, const String& sourceString, InspectorResource::Type type)
@@ -342,18 +347,35 @@ void InspectorResourceAgent::setOverrideContent(unsigned long identifier, const
     m_frontend->setOverrideContent(identifier, sourceString, typeString);
 }
 
+static PassRefPtr<InspectorObject> buildObjectForFrameTree(Frame* frame, bool dumpResources)
+{
+    RefPtr<InspectorObject> frameObject = InspectorObject::create();
+    frameObject->setNumber("id", reinterpret_cast<uintptr_t>(frame));
+    if (dumpResources)
+        populateObjectWithFrameResources(frame, frameObject);
+    RefPtr<InspectorArray> childrenArray;
+    for (Frame* child = frame->tree()->firstChild(); child; child = child->tree()->nextSibling()) {
+        if (!childrenArray) {
+            childrenArray = InspectorArray::create();
+            frameObject->setArray("children", childrenArray);
+        }
+        childrenArray->pushObject(buildObjectForFrameTree(child, dumpResources));
+    }
+    return frameObject;
+}
+
 void InspectorResourceAgent::didCommitLoad(DocumentLoader* loader)
 {
-    Frame* frame = loader->frame();
-    m_frontend->didCommitLoad(reinterpret_cast<uintptr_t>(frame));
+    RefPtr<InspectorObject> frameObject = buildObjectForFrameTree(loader->frame(), false);
+    m_frontend->didCommitLoadForFrame(frameObject, reinterpret_cast<uintptr_t>(loader));
 }
 
 void InspectorResourceAgent::frameDetachedFromParent(Frame* frame)
 {
-    m_frontend->frameDetachedFromParent(reinterpret_cast<uintptr_t>(frame));
+    RefPtr<InspectorObject> frameObject = buildObjectForFrameTree(frame, false);
+    m_frontend->frameDetachedFromParent(frameObject);
 }
 
-
 #if ENABLE(WEB_SOCKETS)
 
 // FIXME: More this into the front-end?
@@ -404,17 +426,16 @@ void InspectorResourceAgent::didCloseWebSocket(unsigned long identifier)
 }
 #endif // ENABLE(WEB_SOCKETS)
 
-void InspectorResourceAgent::cachedResources(RefPtr<InspectorArray>* resources)
+void InspectorResourceAgent::cachedResources(RefPtr<InspectorObject>* object)
 {
-    for (Frame* frame = m_page->mainFrame(); frame; frame = frame->tree()->traverseNext(m_page->mainFrame()))
-        (*resources)->pushObject(buildObjectForFrameResources(frame));
+    *object = buildObjectForFrameTree(m_page->mainFrame(), true);
 }
 
-void InspectorResourceAgent::resourceContent(unsigned long frameID, const String& url, String* content)
+void InspectorResourceAgent::resourceContent(unsigned long frameId, const String& url, String* content)
 {
     RefPtr<InspectorArray> frameResources = InspectorArray::create();
     for (Frame* frame = m_page->mainFrame(); frame; frame = frame->tree()->traverseNext(m_page->mainFrame())) {
-        if (reinterpret_cast<uintptr_t>(frame) != frameID)
+        if (reinterpret_cast<uintptr_t>(frame) != frameId)
             continue;
         InspectorResourceAgent::resourceContent(frame, KURL(ParsedURLString, url), content);
         break;
index f0bead8..fe52a3a 100644 (file)
@@ -97,7 +97,7 @@ public:
 #endif
 
     // Called from frontend 
-    void cachedResources(RefPtr<InspectorArray>*);
+    void cachedResources(RefPtr<InspectorObject>*);
     void resourceContent(unsigned long frameID, const String& url, String* content);
 
 private:
diff --git a/WebCore/inspector/front-end/Images/frame.png b/WebCore/inspector/front-end/Images/frame.png
new file mode 100644 (file)
index 0000000..7bde3e1
Binary files /dev/null and b/WebCore/inspector/front-end/Images/frame.png differ
index 8eed425..44f460c 100644 (file)
@@ -787,12 +787,9 @@ WebInspector.NetworkPanel.prototype = {
         if (!resource || !resource._resourcesView)
             return;
 
-        if (this._resourceViewTypeMatchesResource(resource, resource._resourcesView))
-            return;
-
-        var newView = this._createResourceView(resource);
-        if (newView.__proto__ === resource._resourcesView.__proto__)
+        if (WebInspector.ResourceManager.resourceViewTypeMatchesResource(resource, resource._resourcesView))
             return;
+        var newView = WebInspector.ResourceManager.createResourceView(resource);
 
         var oldView = resource._resourcesView;
         var oldViewParentNode = oldView.visible ? oldView.element.parentNode : null;
@@ -831,7 +828,7 @@ WebInspector.NetworkPanel.prototype = {
         if (this.visibleResource && this.visibleResource._resourcesView)
             this.visibleResource._resourcesView.hide();
 
-        var view = this._resourceViewForResource(resource);
+        var view = WebInspector.ResourceManager.resourceViewForResource(resource);
         view.headersVisible = true;
         view.show(this._viewsContainerElement);
 
@@ -861,15 +858,6 @@ WebInspector.NetworkPanel.prototype = {
         this.updateSidebarWidth();
     },
 
-    _resourceViewForResource: function(resource)
-    {
-        if (!resource)
-            return null;
-        if (!resource._resourcesView)
-            resource._resourcesView = this._createResourceView(resource);
-        return resource._resourcesView;
-    },
-
     _toggleLargerResources: function()
     {
         WebInspector.applicationSettings.resourcesLargeRows = !WebInspector.applicationSettings.resourcesLargeRows;
@@ -890,41 +878,6 @@ WebInspector.NetworkPanel.prototype = {
         }
     },
 
-    _createResourceView: function(resource)
-    {
-        switch (resource.category) {
-            case WebInspector.resourceCategories.documents:
-            case WebInspector.resourceCategories.stylesheets:
-            case WebInspector.resourceCategories.scripts:
-            case WebInspector.resourceCategories.xhr:
-                return new WebInspector.SourceView(resource);
-            case WebInspector.resourceCategories.images:
-                return new WebInspector.ImageView(resource);
-            case WebInspector.resourceCategories.fonts:
-                return new WebInspector.FontView(resource);
-            default:
-                return new WebInspector.ResourceView(resource);
-        }
-    },
-
-    _resourceViewTypeMatchesResource: function(resource, resourceView)
-    {
-        switch (resource.category) {
-            case WebInspector.resourceCategories.documents:
-            case WebInspector.resourceCategories.stylesheets:
-            case WebInspector.resourceCategories.scripts:
-            case WebInspector.resourceCategories.xhr:
-                return resourceView instanceof WebInspector.SourceView;
-            case WebInspector.resourceCategories.images:
-                return resourceView instanceof WebInspector.ImageView;
-            case WebInspector.resourceCategories.fonts:
-                return resourceView instanceof WebInspector.FontView;
-            default:
-                return resourceView instanceof WebInspector.ResourceView;
-        }
-        return false;
-    },
-
     _getPopoverAnchor: function(element)
     {
         var anchor = element.enclosingNodeOrSelfWithClass("network-graph-bar") || element.enclosingNodeOrSelfWithClass("network-graph-label");
index fe2f7d2..acc12a3 100644 (file)
@@ -74,11 +74,11 @@ WebInspector.Resource.Type = {
             case this.Script:
                 return "script";
             case this.XHR:
-                return "XHR";
+                return "xhr";
             case this.Media:
                 return "media";
             case this.WebSocket:
-                return "WebSocket";
+                return "websocket";
             case this.Other:
             default:
                 return "other";
@@ -593,11 +593,7 @@ WebInspector.Resource.prototype = {
 
     getContents: function(callback)
     {
-        // FIXME: eventually, cached resources will have no identifiers.
-        if (this.frameID)
-            InspectorBackend.resourceContent(this.frameID, this.url, callback);
-        else
-            InspectorBackend.getResourceContent(this.identifier, false, callback);
+        WebInspector.ResourceManager.getContents(this, callback);
     }
 }
 
index 7244cea..67479e2 100644 (file)
@@ -40,16 +40,17 @@ WebInspector.ResourceManager = function()
         "didFailLoading",
         "didLoadResourceFromMemoryCache",
         "setOverrideContent",
-        "didCommitLoad",
+        "didCommitLoadForFrame",
         "frameDetachedFromParent",
         "didCreateWebSocket",
         "willSendWebSocketHandshakeRequest",
         "didReceiveWebSocketHandshakeResponse",
         "didCloseWebSocket");
 
-    this._resources = {};
+    this._resourcesById = {};
     this._resourcesByFrame = {};
     this._lastCachedId = 0;
+    InspectorBackend.cachedResources(this._processCachedResources.bind(this));
 }
 
 WebInspector.ResourceManager.prototype = {
@@ -59,36 +60,40 @@ WebInspector.ResourceManager.prototype = {
             WebInspector[arguments[i]] = this[arguments[i]].bind(this);
     },
 
-    identifierForInitialRequest: function(identifier, url, frameID, isMainResource)
+    identifierForInitialRequest: function(identifier, url, loader, isMainResource)
     {
-        var resource = new WebInspector.Resource(identifier, url);
+        var resource = this._createResource(identifier, url, loader);
         if (isMainResource)
             resource.isMainResource = true;
-        this._resources[identifier] = resource;
-
-        if (frameID) {
-            resource.frameID = frameID;
-            var resourcesForFrame = this._resourcesByFrame[frameID];
-            if (!resourcesForFrame) {
-                resourcesForFrame = [];
-                this._resourcesByFrame[frameID] = resourcesForFrame;
-            }
-            resourcesForFrame.push(resource);
-        }
 
-        if (WebInspector.panels.network)
-            WebInspector.panels.network.addResource(resource);
+        WebInspector.panels.network.addResource(resource);
+    },
+
+    _createResource: function(identifier, url, loader)
+    {
+        var resource = new WebInspector.Resource(identifier, url);
+        this._resourcesById[identifier] = resource;
+
+        resource.loader = loader;
+        var resourcesForFrame = this._resourcesByFrame[loader.frameId];
+        if (!resourcesForFrame) {
+            resourcesForFrame = {};
+            this._resourcesByFrame[loader.frameId] = resourcesForFrame;
+        }
+        resourcesForFrame[resource.identifier] = resource;
+        return resource;
     },
 
     willSendRequest: function(identifier, time, request, redirectResponse)
     {
-        var resource = this._resources[identifier];
+        var resource = this._resourcesById[identifier];
         if (!resource)
             return;
 
         // Redirect may have empty URL and we'd like to not crash with invalid HashMap entry.
         // See http/tests/misc/will-send-request-returns-null-on-redirect.html
-        if (!redirectResponse.isNull && request.url.length) {
+        var isRedirect = !redirectResponse.isNull && request.url.length;
+        if (isRedirect) {
             resource.endTime = time;
             this.didReceiveResponse(identifier, time, "Other", redirectResponse);
             resource = this._appendRedirect(resource.identifier, request.url);
@@ -99,7 +104,9 @@ WebInspector.ResourceManager.prototype = {
         resource.requestFormData = request.requestFormData;
         resource.startTime = time;
 
-        if (WebInspector.panels.network)
+        if (isRedirect)
+            WebInspector.panels.network.addResource(resource);
+        else
             WebInspector.panels.network.refreshResource(resource);
     },
 
@@ -107,14 +114,12 @@ WebInspector.ResourceManager.prototype = {
     {
         // We always store last redirect by the original id key. Rest of the redirects are referenced from within the last one.
 
-        var originalResource = this._resources[identifier];
+        var originalResource = this._resourcesById[identifier];
         var redirectIdentifier = originalResource.identifier + ":" + (originalResource.redirects ? originalResource.redirects.length : 0);
         originalResource.identifier = redirectIdentifier;
-        this._resources[redirectIdentifier] = originalResource;
-
-        this.identifierForInitialRequest(identifier, redirectURL, originalResource.frameID);
+        this._resourcesById[redirectIdentifier] = originalResource;
 
-        var newResource = this._resources[identifier];
+        var newResource = this._createResource(identifier, redirectURL, originalResource.loader);
         newResource.redirects = originalResource.redirects || [];
         delete originalResource.redirects;
         newResource.redirects.push(originalResource);
@@ -123,23 +128,28 @@ WebInspector.ResourceManager.prototype = {
 
     markResourceAsCached: function(identifier)
     {
-        var resource = this._resources[identifier];
+        var resource = this._resourcesById[identifier];
         if (!resource)
             return;
 
         resource.cached = true;
-
-        if (WebInspector.panels.network)
-            WebInspector.panels.network.refreshResource(resource);
+        WebInspector.panels.network.refreshResource(resource);
     },
 
     didReceiveResponse: function(identifier, time, resourceType, response)
     {
-        var resource = this._resources[identifier];
+        var resource = this._resourcesById[identifier];
         if (!resource)
             return;
-
+        this._updateResourceWithResponse(resource, response);
         resource.type = WebInspector.Resource.Type[resourceType];
+        resource.responseReceivedTime = time;
+
+        WebInspector.panels.network.refreshResource(resource);
+    },
+
+    _updateResourceWithResponse: function(resource, response)
+    {
         resource.mimeType = response.mimeType;
         resource.expectedContentLength = response.expectedContentLength;
         resource.textEncodingName = response.textEncodingName;
@@ -150,7 +160,6 @@ WebInspector.ResourceManager.prototype = {
         resource.responseHeaders = response.httpHeaderFields;
         resource.connectionReused = response.connectionReused;
         resource.connectionID = response.connectionID;
-        resource.responseReceivedTime = time;
 
         if (response.wasCached)
             resource.cached = true;
@@ -161,101 +170,115 @@ WebInspector.ResourceManager.prototype = {
             resource.requestHeaders = response.rawHeaders.requestHeaders;
             resource.responseHeaders = response.rawHeaders.responseHeaders;
         }
-
-        if (WebInspector.panels.network)
-            WebInspector.panels.network.refreshResource(resource);
     },
 
     didReceiveContentLength: function(identifier, time, lengthReceived)
     {
-        var resource = this._resources[identifier];
+        var resource = this._resourcesById[identifier];
         if (!resource)
             return;
 
         resource.resourceSize += lengthReceived;
         resource.endTime = time;
 
-        if (WebInspector.panels.network)
-            WebInspector.panels.network.refreshResource(resource);
+        WebInspector.panels.network.refreshResource(resource);
     },
 
     didFinishLoading: function(identifier, finishTime)
     {
-        var resource = this._resources[identifier];
+        var resource = this._resourcesById[identifier];
         if (!resource)
             return;
 
         resource.finished = true;
         resource.endTime = finishTime;
 
-        if (WebInspector.panels.network)
-            WebInspector.panels.network.refreshResource(resource);
+        WebInspector.panels.network.refreshResource(resource);
     },
 
     didFailLoading: function(identifier, time, localizedDescription)
     {
-        var resource = this._resources[identifier];
+        var resource = this._resourcesById[identifier];
         if (!resource)
             return;
 
         resource.failed = true;
         resource.endTime = time;
 
-        if (WebInspector.panels.network)
-            WebInspector.panels.network.refreshResource(resource);
+        WebInspector.panels.network.refreshResource(resource);
     },
 
-    didLoadResourceFromMemoryCache: function(time, frameID, cachedResource)
+    didLoadResourceFromMemoryCache: function(time, cachedResource)
     {
         var identifier = "cached:" + this._lastCachedId++;
-        this.identifierForInitialRequest(identifier, cachedResource.url, frameID);
-
-        var resource = this._resources[identifier];
+        var resource = this._createResource(identifier, cachedResource.url, cachedResource.loader);
+        this._updateResourceWithCachedResource(resource, cachedResource);
         resource.cached = true;
-        resource.startTime = resource.responseReceivedTime = time;
-        resource.resourceSize = cachedResource.encodedSize();
+        resource.startTime = resource.responseReceivedTime = resource.endTime = time;
 
-        this.didReceiveResponse(identifier, time, cachedResource.response);
+        WebInspector.panels.network.addResource(resource);
+    },
+
+    _updateResourceWithCachedResource: function(resource, cachedResource)
+    {
+        resource.type = WebInspector.Resource.Type[cachedResource.type];
+        resource.resourceSize = cachedResource.encodedSize;
+        this._updateResourceWithResponse(resource, cachedResource.response);
     },
 
     setOverrideContent: function(identifier, sourceString, type)
     {
-        var resource = this._resources[identifier];
+        var resource = this._resourcesById[identifier];
         if (!resource)
             return;
 
         resource.type = WebInspector.Resource.Type[type];
         resource.overridenContent = sourceString;
 
-        if (WebInspector.panels.network)
-            WebInspector.panels.network.addResource(resource);
+        WebInspector.panels.network.addResource(resource);
     },
 
-    didCommitLoad: function(frameID)
+    didCommitLoadForFrame: function(frameTree, loaderId)
     {
+        this._clearResources(frameTree.id, loaderId);
+        for (var i = 0; frameTree.children && frameTree.children.length; ++i)
+            this.didCommitLoadForFrame(frameTree.children[i], loaderId);
     },
 
-    frameDetachedFromParent: function(frameID)
+    frameDetachedFromParent: function(frameTree)
     {
-        var resourcesForFrame = this._resourcesByFrame[frameID];
-        for (var i = 0; resourcesForFrame && i < resourcesForFrame.length; ++i)
-            delete this._resources[resourcesForFrame[i].identifier];
-        delete this._resourcesByFrame[frameID];
+        this.didCommitLoadForFrame(frameTree, 0);
+    },
+
+    _clearResources: function(frameId, loaderToPreserveId)
+    {
+        var resourcesForFrame = this._resourcesByFrame[frameId];
+        if (resourcesForFrame)
+            return;
+
+        for (var id in resourcesForFrame) {
+            var resource = this._resourcesById[id];
+            if (resource.loaderId === loaderToPreserveId)
+                continue;
+            delete this._resourcesById[id];
+            delete resourcesForFrame[id];
+        }
+        if (!Object.keys(resourcesForFrame).length)
+            delete this._resourcesByFrame[frameId];
     },
 
     didCreateWebSocket: function(identifier, requestURL)
     {
         this.identifierForInitialRequest(identifier, requestURL);
-        var resource = this._resources[identifier];
+        var resource = this._resourcesById[identifier];
         resource.type = WebInspector.Resource.Type.WebSocket;
 
-        if (WebInspector.panels.network)
-            WebInspector.panels.network.addResource(resource);
+        WebInspector.panels.network.addResource(resource);
     },
 
     willSendWebSocketHandshakeRequest: function(identifier, time, request)
     {
-        var resource = this._resources[identifier];
+        var resource = this._resourcesById[identifier];
         if (!resource)
             return;
 
@@ -264,13 +287,12 @@ WebInspector.ResourceManager.prototype = {
         resource.webSocketRequestKey3 = request.webSocketRequestKey3;
         resource.startTime = time;
 
-        if (WebInspector.panels.network)
-            WebInspector.panels.network.refreshResource(resource);
+        WebInspector.panels.network.refreshResource(resource);
     },
 
     didReceiveWebSocketHandshakeResponse: function(identifier, time, response)
     {
-        var resource = this._resources[identifier];
+        var resource = this._resourcesById[identifier];
         if (!resource)
             return;
 
@@ -280,18 +302,103 @@ WebInspector.ResourceManager.prototype = {
         resource.webSocketChallengeResponse = response.webSocketChallengeResponse;
         resource.responseReceivedTime = time;
 
-        if (WebInspector.panels.network)
-            WebInspector.panels.network.refreshResource(resource);
+        WebInspector.panels.network.refreshResource(resource);
     },
 
     didCloseWebSocket: function(identifier, time)
     {
-        var resource = this._resources[identifier];
+        var resource = this._resourcesById[identifier];
         if (!resource)
             return;
         resource.endTime = time;
 
-        if (WebInspector.panels.network)
-            WebInspector.panels.network.refreshResource(resource);
+        WebInspector.panels.network.refreshResource(resource);
+    },
+
+    _processCachedResources: function(mainFramePayload)
+    {
+        this._appendFramesRecursively(null, mainFramePayload);
+    },
+
+    _appendFramesRecursively: function(parentFrameId, framePayload)
+    {
+        var frameResource = this._createResource(null, framePayload.resource.url, framePayload.resource.loader);
+        frameResource.type = WebInspector.Resource.Type["Document"];
+        WebInspector.panels.storage.addFrame(parentFrameId, framePayload.id, frameResource);
+
+        for (var i = 0; framePayload.children && i < framePayload.children.length; ++i)
+            this._appendFramesRecursively(framePayload.id, framePayload.children[i]);
+
+        if (!framePayload.subresources)
+            return;
+
+        var resources = [];
+        for (var i = 0; i < framePayload.subresources.length; ++i) {
+            var cachedResource = framePayload.subresources[i];
+            var resource = this._createResource(null, cachedResource.url, cachedResource.loader);
+            this._updateResourceWithCachedResource(resource, cachedResource);
+            resources.push(resource);
+        }
+
+        function comparator(a, b)
+        {
+            return a.displayName.localeCompare(b.displayName);
+        }
+        resources.sort(comparator);
+
+        for (var i = 0; i < resources.length; ++i)
+            WebInspector.panels.storage.addFrameResource(framePayload.id, resources[i]);
     }
 }
+
+WebInspector.ResourceManager.createResourceView = function(resource)
+{
+    switch (resource.category) {
+    case WebInspector.resourceCategories.documents:
+    case WebInspector.resourceCategories.stylesheets:
+    case WebInspector.resourceCategories.scripts:
+    case WebInspector.resourceCategories.xhr:
+        return new WebInspector.SourceView(resource);
+    case WebInspector.resourceCategories.images:
+        return new WebInspector.ImageView(resource);
+    case WebInspector.resourceCategories.fonts:
+        return new WebInspector.FontView(resource);
+    default:
+        return new WebInspector.ResourceView(resource);
+    }
+}
+
+WebInspector.ResourceManager.resourceViewTypeMatchesResource = function(resource, resourceView)
+{
+    switch (resource.category) {
+    case WebInspector.resourceCategories.documents:
+    case WebInspector.resourceCategories.stylesheets:
+    case WebInspector.resourceCategories.scripts:
+    case WebInspector.resourceCategories.xhr:
+        return resourceView.__proto__ === WebInspector.SourceView.prototype;
+    case WebInspector.resourceCategories.images:
+        return resourceView.__proto__ === WebInspector.ImageView.prototype;
+    case WebInspector.resourceCategories.fonts:
+        return resourceView.__proto__ === WebInspector.FontView.prototype;
+    default:
+        return resourceView.__proto__ === WebInspector.ResourceView.prototype;
+    }
+}
+
+WebInspector.ResourceManager.resourceViewForResource = function(resource)
+{
+    if (!resource)
+        return null;
+    if (!resource._resourcesView)
+        resource._resourcesView = WebInspector.ResourceManager.createResourceView(resource);
+    return resource._resourcesView;
+}
+
+WebInspector.ResourceManager.getContents = function(resource, callback)
+{
+    // FIXME: eventually, cached resources will have no identifiers.
+    if (resource.loader)
+        InspectorBackend.resourceContent(resource.loader.frameId, resource.url, callback);
+    else
+        InspectorBackend.getResourceContent(resource.identifier, false, callback);
+}
index ae67bef..3976e07 100644 (file)
@@ -557,7 +557,7 @@ WebInspector.ResourcesPanel.prototype = {
             var resource = this._resources[i];
             if (!resource._itemsTreeElement || !resource._itemsTreeElement.selectable)
                 continue;
-            var resourceView = this.resourceViewForResource(resource);
+            var resourceView = WebInspector.ResourceManager.resourceViewForResource(resource);
             if (!resourceView.performSearch || resourceView === visibleView)
                 continue;
             views.push(resourceView);
@@ -789,7 +789,7 @@ WebInspector.ResourcesPanel.prototype = {
         if (!this.currentQuery && resource._itemsTreeElement)
             resource._itemsTreeElement.updateErrorsAndWarnings();
 
-        var view = this.resourceViewForResource(resource);
+        var view = WebInspector.ResourceManager.resourceViewForResource(resource);
         if (view.addMessage)
             view.addMessage(msg);
     },
@@ -823,10 +823,10 @@ WebInspector.ResourcesPanel.prototype = {
         if (!resource || !resource._resourcesView)
             return;
 
-        if (this._resourceViewIsConsistentWithCategory(resource, resource._resourcesView))
+        if (WebInspector.ResourceManager.resourceViewTypeMatchesResource(resource, resource._resourcesView))
             return;
+        var newView = WebInspector.ResourceManager.createResourceView(resource);
 
-        var newView = this._createResourceView(resource);
         if (!this.currentQuery && resource._itemsTreeElement)
             resource._itemsTreeElement.updateErrorsAndWarnings();
 
@@ -868,7 +868,7 @@ WebInspector.ResourcesPanel.prototype = {
         if (this.visibleResource && this.visibleResource._resourcesView)
             this.visibleResource._resourcesView.hide();
 
-        var view = this.resourceViewForResource(resource);
+        var view = WebInspector.ResourceManager.resourceViewForResource(resource);
         view.headersVisible = true;
         view.show(this.viewsContainerElement);
 
@@ -909,18 +909,9 @@ WebInspector.ResourcesPanel.prototype = {
         this.updateSidebarWidth();
     },
 
-    resourceViewForResource: function(resource)
-    {
-        if (!resource)
-            return null;
-        if (!resource._resourcesView)
-            resource._resourcesView = this._createResourceView(resource);
-        return resource._resourcesView;
-    },
-
     sourceFrameForResource: function(resource)
     {
-        var view = this.resourceViewForResource(resource);
+        var view = WebInspector.ResourceManager.resourceViewForResource(resource);
         if (!view)
             return null;
 
@@ -1068,40 +1059,6 @@ WebInspector.ResourcesPanel.prototype = {
         this.calculator = this.summaryBar.calculator = selectedOption.calculator;
     },
 
-    _resourceViewIsConsistentWithCategory: function(resource, resourceView)
-    {
-        switch (resource.category) {
-            case WebInspector.resourceCategories.documents:
-            case WebInspector.resourceCategories.stylesheets:
-            case WebInspector.resourceCategories.scripts:
-            case WebInspector.resourceCategories.xhr:
-                return resourceView.__proto__ === WebInspector.SourceView.prototype;
-            case WebInspector.resourceCategories.images:
-                return resourceView.__proto__ === WebInspector.ImageView.prototype;
-            case WebInspector.resourceCategories.fonts:
-                return resourceView.__proto__ === WebInspector.FontView.prototype;
-            default:
-                return resourceView.__proto__ === WebInspector.ResourceView.prototype;
-        }
-    },
-
-    _createResourceView: function(resource)
-    {
-        switch (resource.category) {
-            case WebInspector.resourceCategories.documents:
-            case WebInspector.resourceCategories.stylesheets:
-            case WebInspector.resourceCategories.scripts:
-            case WebInspector.resourceCategories.xhr:
-                return new WebInspector.SourceView(resource);
-            case WebInspector.resourceCategories.images:
-                return new WebInspector.ImageView(resource);
-            case WebInspector.resourceCategories.fonts:
-                return new WebInspector.FontView(resource);
-            default:
-                return new WebInspector.ResourceView(resource);
-        }
-    },
-
     setSidebarWidth: function(width)
     {
         if (this.visibleResource) {
index 0a653c9..2f1628d 100644 (file)
@@ -587,7 +587,7 @@ WebInspector.ScriptsPanel.prototype = {
         if (scriptOrResource instanceof WebInspector.Resource) {
             if (!WebInspector.panels.resources)
                 return null;
-            view = WebInspector.panels.resources.resourceViewForResource(scriptOrResource);
+            view = WebInspector.ResourceManager.resourceViewForResource(scriptOrResource);
             view.headersVisible = false;
         } else if (scriptOrResource instanceof WebInspector.Script)
             view = this.scriptViewForScript(scriptOrResource);
index 0bff136..2d22713 100644 (file)
@@ -34,6 +34,13 @@ WebInspector.StoragePanel = function(database)
     this.createSidebar();
     this.sidebarElement.addStyleClass("outline-disclosure filter-all children small");
 
+    if (Preferences.networkPanelEnabled) {
+        this.resourcesListTreeElement = new WebInspector.StorageCategoryTreeElement(this, WebInspector.UIString("Resources"), "frame-storage-tree-item");
+        this.sidebarTree.appendChild(this.resourcesListTreeElement);
+        this.resourcesListTreeElement.expand();
+        this._treeElementForFrameId = {};
+    }
+
     this.databasesListTreeElement = new WebInspector.StorageCategoryTreeElement(this, WebInspector.UIString("Databases"), "database-storage-tree-item");
     this.sidebarTree.appendChild(this.databasesListTreeElement);
     this.databasesListTreeElement.expand();
@@ -112,6 +119,53 @@ WebInspector.StoragePanel.prototype = {
             this.sidebarTree.selectedTreeElement.deselect();
     },
 
+    addFrame: function(parentFrameId, frameId, frameResource)
+    {
+        var parentTreeElement = parentFrameId ? this._treeElementForFrameId[parentFrameId] : this.resourcesListTreeElement;
+        if (!parentTreeElement) {
+            console.error("No frame with id:" + parentFrameId + " to route " + displayName + " to.")
+            return;
+        }
+
+        var frameTreeElement = new WebInspector.FrameTreeElement(this, frameId, frameResource);
+        this._treeElementForFrameId[frameId] = frameTreeElement;
+        parentTreeElement.appendChild(frameTreeElement);
+    },
+
+    removeFrame: function(frameId)
+    {
+        var frameTreeElement = this._treeElementForFrameId[frameId];
+        if (!frameTreeElement) {
+            console.error("No frame with id:" + frameId + " to remove.");
+            return;
+        }
+
+        delete this._treeElementForFrameId[frameId];
+        frameTreeElement.parent.removeChild(frameTreeElement);
+    },
+
+    addFrameResource: function(frameId, resource)
+    {
+        var frameTreeElement = this._treeElementForFrameId[frameId];
+        if (!frameTreeElement) {
+            console.error("No frame with id:" + frameId + " to add resource to.");
+            return;
+        }
+
+        var resourceTreeElement = new WebInspector.FrameResourceTreeElement(this, resource);
+        frameTreeElement.appendChild(resourceTreeElement);
+    },
+
+    removeFrameResources: function(frameId)
+    {
+        var frameTreeElement = this._treeElementForFrameId[frameId];
+        if (!frameTreeElement) {
+            console.error("No frame with id:" + frameId + " to remove resources from.");
+            return;
+        }
+        frameTreeElement.removeChildren();
+    },
+
     addDatabase: function(database)
     {
         this._databases.push(database);
@@ -166,6 +220,13 @@ WebInspector.StoragePanel.prototype = {
         }
     },
 
+    showResource: function(resource)
+    {
+        var view = WebInspector.ResourceManager.resourceViewForResource(resource);
+        view.headersVisible = false;
+        this._innerShowView(view);
+    },
+
     showDatabase: function(database, tableName)
     {
         if (!database)
@@ -428,9 +489,9 @@ WebInspector.BaseStorageTreeElement.prototype = {
         this.listItemElement.removeChildren();
         this.listItemElement.addStyleClass(this._iconClass);
 
-        var imageElement = document.createElement("img");
-        imageElement.className = "icon";
-        this.listItemElement.appendChild(imageElement);
+        this.imageElement = document.createElement("img");
+        this.imageElement.className = "icon";
+        this.listItemElement.appendChild(this.imageElement);
 
         var titleElement = document.createElement("span");
         titleElement.textContent = this._titleText;
@@ -440,6 +501,12 @@ WebInspector.BaseStorageTreeElement.prototype = {
         var selectionElement = document.createElement("div");
         selectionElement.className = "selection";
         this.listItemElement.appendChild(selectionElement);
+    },
+
+    onreveal: function()
+    {
+        if (this.listItemElement)
+            this.listItemElement.scrollIntoViewIfNeeded(false);
     }
 }
 
@@ -459,6 +526,52 @@ WebInspector.StorageCategoryTreeElement.prototype = {
 }
 WebInspector.StorageCategoryTreeElement.prototype.__proto__ = WebInspector.BaseStorageTreeElement.prototype;
 
+WebInspector.FrameTreeElement = function(storagePanel, frameId, frameResource)
+{
+    WebInspector.BaseStorageTreeElement.call(this, storagePanel, frameResource.displayName, "frame-storage-tree-item");
+    this._frameId = frameId;
+    this._resource = frameResource;
+}
+
+WebInspector.FrameTreeElement.prototype = {
+    onselect: function()
+    {
+        this._storagePanel.showResource(this._resource);
+    }
+}
+WebInspector.FrameTreeElement.prototype.__proto__ = WebInspector.BaseStorageTreeElement.prototype;
+
+WebInspector.FrameResourceTreeElement = function(storagePanel, resource)
+{
+    WebInspector.BaseStorageTreeElement.call(this, storagePanel, resource.displayName, "resource-sidebar-tree-item resources-category-" + resource.category.name);
+    this._resource = resource;
+}
+
+WebInspector.FrameResourceTreeElement.prototype = {
+    onselect: function()
+    {
+        this._storagePanel.showResource(this._resource);
+    },
+
+    onattach: function()
+    {
+        WebInspector.BaseStorageTreeElement.prototype.onattach.call(this);
+
+        if (this._resource.category === WebInspector.resourceCategories.images) {
+            var previewImage = document.createElement("img");
+            previewImage.className = "image-resource-icon-preview";
+            previewImage.src = this._resource.url;
+
+            var iconElement = document.createElement("div");
+            iconElement.className = "icon";
+            iconElement.appendChild(previewImage);
+            this.listItemElement.replaceChild(iconElement, this.imageElement);
+        }
+    }
+}
+
+WebInspector.FrameResourceTreeElement.prototype.__proto__ = WebInspector.BaseStorageTreeElement.prototype;
+
 WebInspector.DatabaseTreeElement = function(storagePanel, database)
 {
     WebInspector.BaseStorageTreeElement.call(this, storagePanel, database.name, "database-storage-tree-item", true);
index 1e5a508..481f8b3 100644 (file)
     <file>Images/excludeButtonGlyph.png</file>
     <file>Images/focusButtonGlyph.png</file>
     <file>Images/forward.png</file>
+    <file>Images/frame.png</file>
     <file>Images/gearButtonGlyph.png</file>
     <file>Images/glossyHeader.png</file>
     <file>Images/glossyHeaderPressed.png</file>
index 7012eb6..db29a6a 100644 (file)
@@ -1881,6 +1881,10 @@ body.inactive .sidebar {
     background-color: rgb(232, 232, 232);
 }
 
+.frame-storage-tree-item .icon {
+    content: url(Images/frame.png);
+}
+
 .database-storage-tree-item .icon {
     content: url(Images/database.png);
 }
@@ -1919,7 +1923,7 @@ body.inactive .sidebar {
     overflow-x: auto;
 }
 
-.storage.panel .outline-disclosure > ol {
+.storage.panel .sidebar.outline-disclosure > ol {
     margin-left: -12px;
     padding-right: 0px !important;
 }
@@ -3394,7 +3398,7 @@ body.inactive .sidebar-tree-item.selected {
     content: "";
 }
 
-.resource-sidebar-tree-item.resources-category-images .image-resource-icon-preview {
+.resources-category-images .image-resource-icon-preview {
     position: absolute;
     margin: auto;
     top: 3px;
@@ -3412,7 +3416,7 @@ body.inactive .sidebar-tree-item.selected {
     content: "";
 }
 
-.children.small .resource-sidebar-tree-item.resources-category-images .image-resource-icon-preview {
+.children.small .resources-category-images .image-resource-icon-preview {
     top: 2px;
     bottom: 1px;
     left: 3px;
index 9bd88d6..4afc474 100644 (file)
@@ -507,8 +507,8 @@ WebInspector.doLoadedDone = function()
     // this.changes = new WebInspector.ChangesView(this.drawer);
     // TODO: Remove class="hidden" from inspector.html on button#changes-status-bar-item
     this.drawer.visibleView = this.console;
-    // FIXME: uncomment when ready.
-    // this.resourceManager = new WebInspector.ResourceManager();
+    if (Preferences.networkPanelEnabled)
+        this.resourceManager = new WebInspector.ResourceManager();
     this.domAgent = new WebInspector.DOMAgent();
 
     this.resourceCategories = {