Refactors code that updates the errors and warnings count in the
authortimothy@apple.com <timothy@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 16 Apr 2008 21:46:32 +0000 (21:46 +0000)
committertimothy@apple.com <timothy@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 16 Apr 2008 21:46:32 +0000 (21:46 +0000)
resources sidebar so other functions can easily trigger updates.

Reviewed by Adam Roben.

* page/inspector/ResourcesPanel.js:
(WebInspector.ResourcesPanel.prototype.addMessageToResource): Call updateErrorsAndWarnings.
Removes code that updates the bubbleText and class names.
(WebInspector.ResourcesPanel.prototype.clearMessages): Ditto.
(WebInspector.ResourceSidebarTreeElement.prototype.updateErrorsAndWarnings):
Added. Updates the bubbleText and adds or removes the class names
depending on if the values are zero.

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

WebCore/ChangeLog
WebCore/page/inspector/ResourcesPanel.js

index cd79a80..dbbffbb 100644 (file)
@@ -1,3 +1,18 @@
+2008-04-16  Timothy Hatcher  <timothy@apple.com>
+
+        Refactors code that updates the errors and warnings count in the
+        resources sidebar so other functions can easily trigger updates.
+
+        Reviewed by Adam Roben.
+
+        * page/inspector/ResourcesPanel.js:
+        (WebInspector.ResourcesPanel.prototype.addMessageToResource): Call updateErrorsAndWarnings.
+        Removes code that updates the bubbleText and class names.
+        (WebInspector.ResourcesPanel.prototype.clearMessages): Ditto.
+        (WebInspector.ResourceSidebarTreeElement.prototype.updateErrorsAndWarnings):
+        Added. Updates the bubbleText and adds or removes the class names
+        depending on if the values are zero.
+
 2008-04-16  Antti Koivisto  <antti@apple.com>
 
         Reviewed by Alexey.
index 54b4b93..36d5d2e 100644 (file)
@@ -303,22 +303,16 @@ WebInspector.ResourcesPanel.prototype = {
         if (!resource)
             return;
 
-        var bubbleClass;
         switch (msg.level) {
         case WebInspector.ConsoleMessage.MessageLevel.Warning:
             ++resource.warnings;
-            bubbleClass = "warning";
             break;
         case WebInspector.ConsoleMessage.MessageLevel.Error:
             ++resource.errors;
-            bubbleClass = "error";
             break;
         }
 
-        resource._resourcesTreeElement.bubbleText = (resource.warnings + resource.errors);
-
-        if (bubbleClass)
-            resource._resourcesTreeElement.bubbleElement.addStyleClass(bubbleClass);
+        resource._resourcesTreeElement.updateErrorsAndWarnings();
 
         var view = this._resourceView(resource);
         if (view.addMessage)
@@ -333,9 +327,7 @@ WebInspector.ResourcesPanel.prototype = {
             resource.warnings = 0;
             resource.errors = 0;
 
-            resource._resourcesTreeElement.bubbleText = "";
-            resource._resourcesTreeElement.bubbleElement.removeStyleClass("error");
-            resource._resourcesTreeElement.bubbleElement.removeStyleClass("warning");
+            resource._resourcesTreeElement.updateErrorsAndWarnings();
 
             var view = resource._resourcesView;
             if (!view || !view.clearMessages)
@@ -376,7 +368,7 @@ WebInspector.ResourcesPanel.prototype = {
         var barLeftElement = resource._resourcesTreeElement.barLeftElement;
         barLeftElement.style.left = percentages.start + "%";
         barLeftElement.style.right = (100 - percentages.end) + "%";
-        
+
         var barRightElement = resource._resourcesTreeElement.barRightElement;
         barRightElement.style.left = percentages.middle + "%";
         barRightElement.style.right = (100 - percentages.end) + "%";
@@ -1278,6 +1270,24 @@ WebInspector.ResourceSidebarTreeElement.prototype = {
             this._listItemNode.className = newClassName;
     },
 
+    updateErrorsAndWarnings: function()
+    {
+        if (this.resource.warnings || this.resource.errors)
+            this.bubbleText = (this.resource.warnings + this.resource.errors);
+        else
+            this.bubbleText = "";
+
+        if (this.resource.warnings)
+            this.bubbleElement.addStyleClass("warning");
+        else
+            this.bubbleElement.removeStyleClass("warning");
+
+        if (this.resource.errors)
+            this.bubbleElement.addStyleClass("error");
+        else
+            this.bubbleElement.removeStyleClass("error");
+    },
+
     updateGraphSideWidth: function(width)
     {
         width += 1; // Add one to account for the sidebar border width.