Title: [87383] trunk
Revision
87383
Author
[email protected]
Date
2011-05-26 07:28:04 -0700 (Thu, 26 May 2011)

Log Message

2011-05-26  Vsevolod Vlasov  <[email protected]>

        Reviewed by Yury Semikhatsky.

        Web Inspector: Use different SourceFrame instances for ResourcesPanel and NetworkPanel
        https://bugs.webkit.org/show_bug.cgi?id=59193

        * inspector/debugger/source-frame.html:
2011-05-26  Vsevolod Vlasov  <[email protected]>

        Reviewed by Yury Semikhatsky.

        Web Inspector: Use different SourceFrame instances for ResourcesPanel and NetworkPanel
        https://bugs.webkit.org/show_bug.cgi?id=59193

        * inspector/front-end/NetworkItemView.js:
        (WebInspector.NetworkItemView):
        (WebInspector.NetworkItemView._contentViewForResource):
        * inspector/front-end/NetworkPanel.js:
        (WebInspector.NetworkPanel.prototype._refreshResource):
        * inspector/front-end/Resource.js:
        (WebInspector.Resource.prototype.get messages):
        (WebInspector.Resource.prototype.addMessage):
        (WebInspector.Resource.prototype.set errors):
        (WebInspector.Resource.prototype.set warnings):
        (WebInspector.Resource.prototype.clearErrorsAndWarnings):
        * inspector/front-end/ResourceTreeModel.js:
        (WebInspector.ResourceTreeModel.prototype._consoleMessageAdded):
        * inspector/front-end/ResourceView.js:
        (WebInspector.ResourceView.hasTextContent):
        (WebInspector.ResourceView.nonSourceViewForResource):
        (WebInspector.ResourceSourceFrame):
        (WebInspector.ResourceSourceFrame.mimeTypeForResource):
        (WebInspector.ResourceSourceFrame.prototype.requestContent):
        (WebInspector.ResourceSourceFrame.prototype.suggestedFileName):
        (WebInspector.EditableResourceSourceFrame):
        (WebInspector.EditableResourceSourceFrame.prototype.doubleClick):
        (WebInspector.EditableResourceSourceFrame.prototype.editContent):
        (WebInspector.EditableResourceSourceFrame.prototype.cancelEditing):
        (WebInspector.EditableResourceSourceFrame.prototype.afterTextChanged):
        (WebInspector.EditableResourceSourceFrame.prototype._clearIncrementalUpdateTimer):
        (WebInspector.ResourceRevisionSourceFrame):
        (WebInspector.ResourceRevisionSourceFrame.prototype.requestContent):
        * inspector/front-end/ResourcesPanel.js:
        (WebInspector.ResourcesPanel.prototype.showResource):
        (WebInspector.ResourcesPanel.prototype._showResourceView):
        (WebInspector.ResourcesPanel.prototype._resourceViewForResource):
        (WebInspector.ResourcesPanel.prototype._showRevisionView):
        (WebInspector.ResourcesPanel.prototype._sourceViewForRevision):
        (WebInspector.ResourcesPanel.prototype.searchCanceled):
        (WebInspector.ResourcesPanel.prototype._findTreeElementForRevision):
        (WebInspector.ResourcesPanel.prototype._findTreeElementForRevision.getParent):
        (WebInspector.FrameResourceTreeElement):
        (WebInspector.FrameResourceTreeElement.prototype.onattach):
        (WebInspector.FrameResourceTreeElement.prototype._updateErrorsAndWarningsBubbles):
        (WebInspector.FrameResourceTreeElement.prototype._errorsWarningsCleared):
        (WebInspector.FrameResourceTreeElement.prototype._errorsWarningsMessageAdded):
        (WebInspector.FrameResourceTreeElement.prototype._appendRevision):
        (WebInspector.FrameResourceTreeElement.prototype.sourceView):
        (WebInspector.FrameResourceTreeElement.prototype._createSourceView):
        (WebInspector.FrameResourceTreeElement.prototype._recreateSourceView):
        (WebInspector.ResourceRevisionTreeElement):
        (WebInspector.ResourceRevisionTreeElement.prototype._handleContextMenuEvent):
        (WebInspector.ResourceRevisionTreeElement.prototype.sourceView):

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (87382 => 87383)


--- trunk/LayoutTests/ChangeLog	2011-05-26 14:01:38 UTC (rev 87382)
+++ trunk/LayoutTests/ChangeLog	2011-05-26 14:28:04 UTC (rev 87383)
@@ -1,3 +1,12 @@
+2011-05-26  Vsevolod Vlasov  <[email protected]>
+
+        Reviewed by Yury Semikhatsky.
+
+        Web Inspector: Use different SourceFrame instances for ResourcesPanel and NetworkPanel
+        https://bugs.webkit.org/show_bug.cgi?id=59193
+
+        * inspector/debugger/source-frame.html:
+
 2011-05-26  Philippe Normand  <[email protected]>
 
         Unreviewed, skip flaky test on GTK.

Modified: trunk/LayoutTests/inspector/debugger/source-frame.html (87382 => 87383)


--- trunk/LayoutTests/inspector/debugger/source-frame.html	2011-05-26 14:01:38 UTC (rev 87382)
+++ trunk/LayoutTests/inspector/debugger/source-frame.html	2011-05-26 14:28:04 UTC (rev 87383)
@@ -33,7 +33,7 @@
 
         function testConsoleMessage(next)
         {
-              InspectorTest.addSniffer(WebInspector.SourceFrame.prototype, "addMessage", didAddMessage);
+              InspectorTest.addSniffer(WebInspector.Resource.prototype, "addMessage", didAddMessage);
               InspectorTest.evaluateInPage("addErrorToConsole()");
 
               function didAddMessage(message)

Modified: trunk/Source/WebCore/ChangeLog (87382 => 87383)


--- trunk/Source/WebCore/ChangeLog	2011-05-26 14:01:38 UTC (rev 87382)
+++ trunk/Source/WebCore/ChangeLog	2011-05-26 14:28:04 UTC (rev 87383)
@@ -1,3 +1,60 @@
+2011-05-26  Vsevolod Vlasov  <[email protected]>
+
+        Reviewed by Yury Semikhatsky.
+
+        Web Inspector: Use different SourceFrame instances for ResourcesPanel and NetworkPanel
+        https://bugs.webkit.org/show_bug.cgi?id=59193
+
+        * inspector/front-end/NetworkItemView.js:
+        (WebInspector.NetworkItemView):
+        (WebInspector.NetworkItemView._contentViewForResource):
+        * inspector/front-end/NetworkPanel.js:
+        (WebInspector.NetworkPanel.prototype._refreshResource):
+        * inspector/front-end/Resource.js:
+        (WebInspector.Resource.prototype.get messages):
+        (WebInspector.Resource.prototype.addMessage):
+        (WebInspector.Resource.prototype.set errors):
+        (WebInspector.Resource.prototype.set warnings):
+        (WebInspector.Resource.prototype.clearErrorsAndWarnings):
+        * inspector/front-end/ResourceTreeModel.js:
+        (WebInspector.ResourceTreeModel.prototype._consoleMessageAdded):
+        * inspector/front-end/ResourceView.js:
+        (WebInspector.ResourceView.hasTextContent):
+        (WebInspector.ResourceView.nonSourceViewForResource):
+        (WebInspector.ResourceSourceFrame):
+        (WebInspector.ResourceSourceFrame.mimeTypeForResource):
+        (WebInspector.ResourceSourceFrame.prototype.requestContent):
+        (WebInspector.ResourceSourceFrame.prototype.suggestedFileName):
+        (WebInspector.EditableResourceSourceFrame):
+        (WebInspector.EditableResourceSourceFrame.prototype.doubleClick):
+        (WebInspector.EditableResourceSourceFrame.prototype.editContent):
+        (WebInspector.EditableResourceSourceFrame.prototype.cancelEditing):
+        (WebInspector.EditableResourceSourceFrame.prototype.afterTextChanged):
+        (WebInspector.EditableResourceSourceFrame.prototype._clearIncrementalUpdateTimer):
+        (WebInspector.ResourceRevisionSourceFrame):
+        (WebInspector.ResourceRevisionSourceFrame.prototype.requestContent):
+        * inspector/front-end/ResourcesPanel.js:
+        (WebInspector.ResourcesPanel.prototype.showResource):
+        (WebInspector.ResourcesPanel.prototype._showResourceView):
+        (WebInspector.ResourcesPanel.prototype._resourceViewForResource):
+        (WebInspector.ResourcesPanel.prototype._showRevisionView):
+        (WebInspector.ResourcesPanel.prototype._sourceViewForRevision):
+        (WebInspector.ResourcesPanel.prototype.searchCanceled):
+        (WebInspector.ResourcesPanel.prototype._findTreeElementForRevision):
+        (WebInspector.ResourcesPanel.prototype._findTreeElementForRevision.getParent):
+        (WebInspector.FrameResourceTreeElement):
+        (WebInspector.FrameResourceTreeElement.prototype.onattach):
+        (WebInspector.FrameResourceTreeElement.prototype._updateErrorsAndWarningsBubbles):
+        (WebInspector.FrameResourceTreeElement.prototype._errorsWarningsCleared):
+        (WebInspector.FrameResourceTreeElement.prototype._errorsWarningsMessageAdded):
+        (WebInspector.FrameResourceTreeElement.prototype._appendRevision):
+        (WebInspector.FrameResourceTreeElement.prototype.sourceView):
+        (WebInspector.FrameResourceTreeElement.prototype._createSourceView):
+        (WebInspector.FrameResourceTreeElement.prototype._recreateSourceView):
+        (WebInspector.ResourceRevisionTreeElement):
+        (WebInspector.ResourceRevisionTreeElement.prototype._handleContextMenuEvent):
+        (WebInspector.ResourceRevisionTreeElement.prototype.sourceView):
+
 2011-05-26  Andreas Kling  <[email protected]>
 
         Reviewed by Darin Adler.

Modified: trunk/Source/WebCore/inspector/front-end/NetworkItemView.js (87382 => 87383)


--- trunk/Source/WebCore/inspector/front-end/NetworkItemView.js	2011-05-26 14:01:38 UTC (rev 87382)
+++ trunk/Source/WebCore/inspector/front-end/NetworkItemView.js	2011-05-26 14:28:04 UTC (rev 87383)
@@ -35,17 +35,12 @@
     this.element.addStyleClass("network-item-view");
 
     this._headersView = new WebInspector.ResourceHeadersView(resource);
-    // Do not store reference to content view - it can be recreated.
-    var contentView = WebInspector.ResourceView.resourceViewForResource(resource);
-
     this._tabbedPane = new WebInspector.TabbedPane(this.element);
     this._tabbedPane.appendTab("headers", WebInspector.UIString("Headers"), this._headersView);
 
-    if (contentView.hasContent()) {
-        // Reusing this view, so hide it at first.
-        contentView.visible = false;
+    var contentView = WebInspector.NetworkItemView._contentViewForResource(resource);
+    if (contentView.hasContent())
         this._tabbedPane.appendTab("content", WebInspector.UIString("Content"), contentView);
-    }
 
     if (resource.type === WebInspector.Resource.Type.XHR && resource.content) {
         var parsedJSON = WebInspector.ResourceJSONView.parseJSON(resource.content);
@@ -68,6 +63,13 @@
     this._tabbedPane.addEventListener("tab-selected", this._tabSelected, this);
 }
 
+WebInspector.NetworkItemView._contentViewForResource = function(resource)
+{
+    if (WebInspector.ResourceView.hasTextContent(resource))
+        return new WebInspector.ResourceSourceFrame(resource)
+    return WebInspector.ResourceView.nonSourceViewForResource(resource);
+}
+
 WebInspector.NetworkItemView.prototype = {
     show: function(parentElement)
     {

Modified: trunk/Source/WebCore/inspector/front-end/NetworkPanel.js (87382 => 87383)


--- trunk/Source/WebCore/inspector/front-end/NetworkPanel.js	2011-05-26 14:01:38 UTC (rev 87382)
+++ trunk/Source/WebCore/inspector/front-end/NetworkPanel.js	2011-05-26 14:28:04 UTC (rev 87383)
@@ -791,17 +791,6 @@
     {
         this._staleResources.push(resource);
         this._scheduleRefresh();
-
-        var oldView = WebInspector.ResourceView.existingResourceViewForResource(resource);
-        if (!oldView)
-            return;
-
-        if (WebInspector.ResourceView.resourceViewTypeMatchesResource(resource))
-            return;
-
-        var newView = WebInspector.ResourceView.recreateResourceView(resource);
-        if (this.visibleView === oldView)
-            this.visibleView = newView;
     },
 
     clear: function()

Modified: trunk/Source/WebCore/inspector/front-end/Resource.js (87382 => 87383)


--- trunk/Source/WebCore/inspector/front-end/Resource.js	2011-05-26 14:01:38 UTC (rev 87382)
+++ trunk/Source/WebCore/inspector/front-end/Resource.js	2011-05-26 14:28:04 UTC (rev 87383)
@@ -693,6 +693,22 @@
         return size;
     },
 
+    get messages()
+    {
+        return this._messages || [];
+    },
+
+    addMessage: function(msg)
+    {
+        if (!msg.isErrorOrWarning() || !msg.message) 
+            return;
+
+        if (!this._messages)
+            this._messages = [];
+        this._messages.push(msg);
+        this.dispatchEventToListeners("errors-warnings-message-added", msg);
+    },
+
     get errors()
     {
         return this._errors || 0;
@@ -701,7 +717,6 @@
     set errors(x)
     {
         this._errors = x;
-        this.dispatchEventToListeners("errors-warnings-updated");
     },
 
     get warnings()
@@ -712,14 +727,14 @@
     set warnings(x)
     {
         this._warnings = x;
-        this.dispatchEventToListeners("errors-warnings-updated");
     },
 
     clearErrorsAndWarnings: function()
     {
+        this._messages = [];
         this._warnings = 0;
         this._errors = 0;
-        this.dispatchEventToListeners("errors-warnings-updated");
+        this.dispatchEventToListeners("errors-warnings-cleared");
     },
 
     _mimeTypeIsConsistentWithType: function()

Modified: trunk/Source/WebCore/inspector/front-end/ResourceTreeModel.js (87382 => 87383)


--- trunk/Source/WebCore/inspector/front-end/ResourceTreeModel.js	2011-05-26 14:01:38 UTC (rev 87382)
+++ trunk/Source/WebCore/inspector/front-end/ResourceTreeModel.js	2011-05-26 14:28:04 UTC (rev 87383)
@@ -231,10 +231,7 @@
             resource.errors += msg.repeatDelta;
             break;
         }
-
-        var view = WebInspector.ResourceView.resourceViewForResource(resource);
-        if (view.addMessage && msg.isErrorOrWarning() && msg.message)
-            view.addMessage(msg);
+        resource.addMessage(msg);
     },
 
     _consoleCleared: function()

Modified: trunk/Source/WebCore/inspector/front-end/ResourceView.js (87382 => 87383)


--- trunk/Source/WebCore/inspector/front-end/ResourceView.js	2011-05-26 14:01:38 UTC (rev 87382)
+++ trunk/Source/WebCore/inspector/front-end/ResourceView.js	2011-05-26 14:28:04 UTC (rev 87383)
@@ -43,82 +43,34 @@
 
 WebInspector.ResourceView.prototype.__proto__ = WebInspector.View.prototype;
 
-WebInspector.ResourceView.createResourceView = function(resource)
+WebInspector.ResourceView.hasTextContent = function(resource)
 {
     switch (resource.category) {
     case WebInspector.resourceCategories.documents:
     case WebInspector.resourceCategories.scripts:
     case WebInspector.resourceCategories.xhr:
     case WebInspector.resourceCategories.stylesheets:
-        return new WebInspector.ResourceSourceFrame(resource);
-    case WebInspector.resourceCategories.images:
-        return new WebInspector.ImageView(resource);
-    case WebInspector.resourceCategories.fonts:
-        return new WebInspector.FontView(resource);
+        return true;
     default:
-        return new WebInspector.ResourceView(resource);
+        return false;
     }
 }
 
-WebInspector.ResourceView.resourceViewTypeMatchesResource = function(resource)
+WebInspector.ResourceView.nonSourceViewForResource = function(resource)
 {
-    var resourceView = resource._resourceView;
     switch (resource.category) {
-    case WebInspector.resourceCategories.documents:
-    case WebInspector.resourceCategories.scripts:
-    case WebInspector.resourceCategories.xhr:
-    case WebInspector.resourceCategories.stylesheets:
-        return resourceView.__proto__ === WebInspector.ResourceSourceFrame.prototype;
     case WebInspector.resourceCategories.images:
-        return resourceView.__proto__ === WebInspector.ImageView.prototype;
+        return new WebInspector.ImageView(resource);
     case WebInspector.resourceCategories.fonts:
-        return resourceView.__proto__ === WebInspector.FontView.prototype;
+        return new WebInspector.FontView(resource);
     default:
-        return resourceView.__proto__ === WebInspector.ResourceView.prototype;
+        return new WebInspector.ResourceView(resource);
     }
 }
 
-WebInspector.ResourceView.resourceViewForResource = function(resource)
-{
-    if (!resource)
-        return null;
-    if (!resource._resourceView)
-        resource._resourceView = WebInspector.ResourceView.createResourceView(resource);
-    return resource._resourceView;
-}
-
-WebInspector.ResourceView.recreateResourceView = function(resource)
-{
-    var newView = WebInspector.ResourceView.createResourceView(resource);
-
-    var oldView = resource._resourceView;
-    var oldViewParentNode = oldView.visible ? oldView.element.parentNode : null;
-    var scrollTop = oldView.scrollTop;
-
-    resource._resourceView.detach();
-    delete resource._resourceView;
-
-    resource._resourceView = newView;
-
-    if (oldViewParentNode)
-        newView.show(oldViewParentNode);
-    if (scrollTop)
-        newView.scrollTop = scrollTop;
-
-    return newView;
-}
-
-WebInspector.ResourceView.existingResourceViewForResource = function(resource)
-{
-    if (!resource)
-        return null;
-    return resource._resourceView;
-}
-
-
 WebInspector.ResourceSourceFrame = function(resource)
 {
-    WebInspector.SourceFrame.call(this, new WebInspector.SourceFrameDelegate(), resource.url);
+    WebInspector.SourceFrame.call(this, new WebInspector.SourceFrameDelegate(resource), resource.url);
     this._resource = resource;
 }
 
@@ -130,15 +82,44 @@
     4: "text/_javascript_"
 }
 
+WebInspector.ResourceSourceFrame.mimeTypeForResource = function(resource) {
+    return WebInspector.ResourceSourceFrame.DefaultMIMETypeForResourceType[resource.type] || resource.mimeType;
+}
+
 WebInspector.ResourceSourceFrame.prototype = {
     get resource()
     {
         return this._resource;
     },
 
+    requestContent: function(callback)
+    {
+        function contentLoaded(text)
+        {
+            var mimeType = WebInspector.ResourceSourceFrame.mimeTypeForResource(this.resource);
+            callback(mimeType, text);
+        }
+        
+        this.resource.requestContent(contentLoaded.bind(this));
+    },
+
+    suggestedFileName: function()
+    {
+        return this.resource.displayName;
+    }
+}
+
+WebInspector.ResourceSourceFrame.prototype.__proto__ = WebInspector.SourceFrame.prototype;
+
+WebInspector.EditableResourceSourceFrame = function(resource)
+{
+    WebInspector.ResourceSourceFrame.call(this, resource);
+}
+
+WebInspector.EditableResourceSourceFrame.prototype = {
     doubleClick: function(lineNumber)
     {
-        if (!this._resource.isEditable())
+        if (!this.resource.isEditable())
             return;
 
         if (this._commitEditingInProgress)
@@ -152,14 +133,14 @@
     {
         this._clearIncrementalUpdateTimer();
         var majorChange = true;
-        this._resource.setContent(newText, majorChange, callback);
+        this.resource.setContent(newText, majorChange, callback);
     },
 
     cancelEditing: function()
     {
         this._clearIncrementalUpdateTimer();
         const majorChange = false;
-        this._resource.setContent(this._viewerState.textModelContent, majorChange);
+        this.resource.setContent(this._viewerState.textModelContent, majorChange);
         WebInspector.SourceFrame.prototype.cancelEditing.call(this);
     },
 
@@ -168,7 +149,7 @@
         function commitIncrementalEdit()
         {
             var majorChange = false;
-            this._resource.setContent(this._textModel.text, majorChange, function() {});
+            this.resource.setContent(this._textModel.text, majorChange, function() {});
         }
         const updateTimeout = 200;
         this._incrementalUpdateTimer = setTimeout(commitIncrementalEdit.bind(this), updateTimeout);
@@ -180,55 +161,32 @@
             clearTimeout(this._incrementalUpdateTimer);
         delete this._incrementalUpdateTimer;
     },
-
-    requestContent: function(callback)
-    {
-        function contentLoaded(text)
-        {
-            var mimeType = WebInspector.ResourceSourceFrame.DefaultMIMETypeForResourceType[this._resource.type] || this._resource.mimeType;
-            callback(mimeType, text);
-        }
-        this._resource.requestContent(contentLoaded.bind(this));
-    },
-
-    suggestedFileName: function()
-    {
-        return this._resource.displayName;
-    }
 }
 
-WebInspector.ResourceSourceFrame.prototype.__proto__ = WebInspector.SourceFrame.prototype;
+WebInspector.EditableResourceSourceFrame.prototype.__proto__ = WebInspector.ResourceSourceFrame.prototype;
 
-WebInspector.RevisionSourceFrame = function(revision)
+WebInspector.ResourceRevisionSourceFrame = function(revision)
 {
-    WebInspector.SourceFrame.call(this, new WebInspector.SourceFrameDelegate(), revision.resource.url);
+    WebInspector.ResourceSourceFrame.call(this, revision.resource);
     this._revision = revision;
 }
 
-WebInspector.RevisionSourceFrame.prototype = {
+WebInspector.ResourceRevisionSourceFrame.prototype = {
     get resource()
     {
         return this._revision.resource;
     },
 
-    doubleClick: function(lineNumber)
-    {
-    },
-
     requestContent: function(callback)
     {
         function contentLoaded(text)
         {
-            var mimeType = WebInspector.ResourceSourceFrame.DefaultMIMETypeForResourceType[this._revision.resource.type] || this._revision.resource.mimeType;
+            var mimeType = WebInspector.ResourceSourceFrame.mimeTypeForResource(this.resource);
             callback(mimeType, text);
         }
+
         this._revision.requestContent(contentLoaded.bind(this));
     },
-
-    suggestedFileName: function()
-    {
-        return this._revision.resource.displayName;
-    }
 }
 
-WebInspector.RevisionSourceFrame.prototype.__proto__ = WebInspector.SourceFrame.prototype;
+WebInspector.ResourceRevisionSourceFrame.prototype.__proto__ = WebInspector.ResourceSourceFrame.prototype;

Modified: trunk/Source/WebCore/inspector/front-end/ResourcesPanel.js (87382 => 87383)


--- trunk/Source/WebCore/inspector/front-end/ResourcesPanel.js	2011-05-26 14:01:38 UTC (rev 87382)
+++ trunk/Source/WebCore/inspector/front-end/ResourcesPanel.js	2011-05-26 14:28:04 UTC (rev 87383)
@@ -363,7 +363,7 @@
         }
 
         if (line !== undefined) {
-            var view = WebInspector.ResourceView.resourceViewForResource(resource);
+            var view = this._resourceViewForResource(resource);
             if (view.highlightLine)
                 view.highlightLine(line);
         }
@@ -372,23 +372,41 @@
 
     _showResourceView: function(resource)
     {
-        var view = WebInspector.ResourceView.resourceViewForResource(resource);
-        // FIXME: This could be removed once we stop caching SourceFrames.        
+        var view = this._resourceViewForResource(resource);
+        if (!view) {
+            this.visibleView.hide();
+            return;
+        }
         if (view.searchCanceled)
             view.searchCanceled();
         this._fetchAndApplyDiffMarkup(view, resource);
         this._innerShowView(view);
     },
 
+    _resourceViewForResource: function(resource)
+    {
+        if (WebInspector.ResourceView.hasTextContent(resource)) {
+            var treeElement = this._findTreeElementForResource(resource);
+            if (!treeElement)
+                return null;
+            return treeElement.sourceView();
+        }
+        return WebInspector.ResourceView.nonSourceViewForResource(resource);
+    },
+
     _showRevisionView: function(revision)
     {
-        if (!revision._view)
-            revision._view = new WebInspector.RevisionSourceFrame(revision);
-        var view = revision._view;
+        var view = this._sourceViewForRevision(revision);
         this._fetchAndApplyDiffMarkup(view, revision.resource, revision);
         this._innerShowView(view);
     },
 
+    _sourceViewForRevision: function(revision)
+    {
+        var treeElement = this._findTreeElementForRevision(revision);
+        return treeElement.sourceView();
+    },
+
     _fetchAndApplyDiffMarkup: function(view, resource, revision)
     {
         var baseRevision = resource.history[0];
@@ -788,8 +806,14 @@
 
     searchCanceled: function()
     {
+        function callback(resourceTreeElement)
+        {
+            resourceTreeElement._updateErrorsAndWarningsBubbles();
+        }
+
         WebInspector.searchController.updateSearchMatchesCount(0, this);
         this._resetSearchResults();
+        this._forAllResourceTreeElements(callback);
     },
 
     jumpToNextSearchResult: function()
@@ -836,6 +860,21 @@
         return this.sidebarTree.findTreeElement(resource, isAncestor, getParent);
     },
 
+    _findTreeElementForRevision: function(revision)
+    {
+        function isAncestor(ancestor, object)
+        {
+            return false;
+        }
+
+        function getParent(object)
+        {
+            return null;
+        }
+
+        return this.sidebarTree.findTreeElement(revision, isAncestor, getParent);
+    },
+
     showView: function(view)
     {
         if (view)
@@ -1147,7 +1186,8 @@
 {
     WebInspector.BaseStorageTreeElement.call(this, storagePanel, resource, resource.displayName, ["resource-sidebar-tree-item", "resources-category-" + resource.category.name]);
     this._resource = resource;
-    this._resource.addEventListener("errors-warnings-updated", this._errorsWarningsUpdated, this);
+    this._resource.addEventListener("errors-warnings-cleared", this._errorsWarningsCleared, this);
+    this._resource.addEventListener("errors-warnings-message-added", this._errorsWarningsMessageAdded, this);
     this._resource.addEventListener(WebInspector.Resource.Events.RevisionAdded, this._revisionAdded, this);
     this.tooltip = resource.url;
 }
@@ -1191,6 +1231,8 @@
         this.listItemElement.draggable = true;
         this.listItemElement.addEventListener("dragstart", this._ondragstart.bind(this), false);
         this.listItemElement.addEventListener("contextmenu", this._handleContextMenuEvent.bind(this), true);
+
+        this._updateErrorsAndWarningsBubbles();
     },
 
     _ondragstart: function(event)
@@ -1277,15 +1319,8 @@
         }
     },
 
-    _errorsWarningsUpdated: function()
+    _updateErrorsAndWarningsBubbles: function()
     {
-        // FIXME: move to the SourceFrame.
-        if (!this._resource.warnings && !this._resource.errors) {
-            var view = WebInspector.ResourceView.existingResourceViewForResource(this._resource);
-            if (view && view.clearMessages)
-                view.clearMessages();
-        }
-
         if (this._storagePanel.currentQuery)
             return;
 
@@ -1300,7 +1335,26 @@
         if (this._resource.errors)
             this._bubbleElement.addStyleClass("error");
     },
+    
+    _errorsWarningsCleared: function()
+    {
+        // FIXME: move to the SourceFrame.
+        if (this._sourceView)
+            this._sourceView.clearMessages();
+        
+        this._updateErrorsAndWarningsBubbles();
+    },
+    
+    _errorsWarningsMessageAdded: function(event)
+    {
+        var msg = event.data;
 
+        if (this._sourceView)
+            this._sourceView.addMessage(msg);
+        
+        this._updateErrorsAndWarningsBubbles();
+    },
+
     _populateRevisions: function()
     {
         for (var i = 0; i < this._resource.history.length; ++i)
@@ -1315,13 +1369,50 @@
     _appendRevision: function(revision)
     {
         this.insertChild(new WebInspector.ResourceRevisionTreeElement(this._storagePanel, revision), 0);
-        var oldView = WebInspector.ResourceView.existingResourceViewForResource(this._resource);
+        var oldView = this._sourceView;
         if (oldView) {
-            var newView = WebInspector.ResourceView.recreateResourceView(this._resource);
+            // This is needed when resource content was changed from scripts panel.
+            var newView = this._recreateSourceView();
             if (oldView === this._storagePanel.visibleView)
                 this._storagePanel._showResourceView(this._resource);
         }
-    }
+    },
+
+    sourceView: function()
+    {
+        if (!this._sourceView) {
+            this._sourceView = this._createSourceView();
+            if (this._resource.messages) {
+                for (var i = 0; i < this._resource.messages.length; i++)
+                    this._sourceView.addMessage(this._resource.messages[i]);
+            }
+        }
+        return this._sourceView;
+    },
+
+    _createSourceView: function()
+    {
+        return new WebInspector.EditableResourceSourceFrame(this._resource);
+    },
+
+    _recreateSourceView: function()
+    {
+        var oldView = this._sourceView;
+        var newView = this._createSourceView();
+
+        var oldViewParentNode = oldView.visible ? oldView.element.parentNode : null;
+        var scrollTop = oldView.scrollTop;
+
+        this._sourceView.detach();
+        this._sourceView = newView;
+
+        if (oldViewParentNode)
+            newView.show(oldViewParentNode);
+        if (scrollTop)
+            newView.scrollTop = scrollTop;
+
+        return newView;
+    }    
 }
 
 WebInspector.FrameResourceTreeElement.prototype.__proto__ = WebInspector.BaseStorageTreeElement.prototype;
@@ -1451,7 +1542,7 @@
 WebInspector.ResourceRevisionTreeElement = function(storagePanel, revision)
 {
     var title = revision.timestamp ? revision.timestamp.toLocaleTimeString() : WebInspector.UIString("(original)");
-    WebInspector.BaseStorageTreeElement.call(this, storagePanel, null, title, ["resource-sidebar-tree-item", "resources-category-" + revision.resource.category.name]);
+    WebInspector.BaseStorageTreeElement.call(this, storagePanel, revision, title, ["resource-sidebar-tree-item", "resources-category-" + revision.resource.category.name]);
     if (revision.timestamp)
         this.tooltip = revision.timestamp.toLocaleString();
     this._revision = revision;
@@ -1502,6 +1593,13 @@
         }
 
         contextMenu.show(event);
+    },
+
+    sourceView: function()
+    {
+        if (!this._sourceView)
+            this._sourceView = new WebInspector.ResourceRevisionSourceFrame(this._revision);
+        return this._sourceView;
     }
 }
 
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to