Web Inspector: Lazily Create GeneralTreeElement Status Elements
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 22 Feb 2015 16:49:13 +0000 (16:49 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 22 Feb 2015 16:49:13 +0000 (16:49 +0000)
https://bugs.webkit.org/show_bug.cgi?id=141873

Patch by Joseph Pecoraro <pecoraro@apple.com> on 2015-02-22
Reviewed by Timothy Hatcher.

* UserInterface/Views/GeneralTreeElement.js:
(WebInspector.GeneralTreeElement.prototype.set status):
(WebInspector.GeneralTreeElement.prototype.onattach):
(WebInspector.GeneralTreeElement.prototype._createElementsIfNeeded):
(WebInspector.GeneralTreeElement.prototype._updateStatusElement):
Lazily create and attach the status element container if
"this.status" is actually used by a GeneralTreeElement subclass.

* UserInterface/Views/ResourceTreeElement.js:
(WebInspector.ResourceTreeElement.prototype._updateStatus):
Set to the empty string instead of null to avoid inadvertently
creating status elements for no reason.

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

Source/WebInspectorUI/ChangeLog
Source/WebInspectorUI/UserInterface/Views/GeneralTreeElement.js
Source/WebInspectorUI/UserInterface/Views/ResourceTreeElement.js

index 22261c4..99f4784 100644 (file)
@@ -1,5 +1,25 @@
 2015-02-22  Joseph Pecoraro  <pecoraro@apple.com>
 
+        Web Inspector: Lazily Create GeneralTreeElement Status Elements
+        https://bugs.webkit.org/show_bug.cgi?id=141873
+
+        Reviewed by Timothy Hatcher.
+
+        * UserInterface/Views/GeneralTreeElement.js:
+        (WebInspector.GeneralTreeElement.prototype.set status):
+        (WebInspector.GeneralTreeElement.prototype.onattach):
+        (WebInspector.GeneralTreeElement.prototype._createElementsIfNeeded):
+        (WebInspector.GeneralTreeElement.prototype._updateStatusElement):
+        Lazily create and attach the status element container if
+        "this.status" is actually used by a GeneralTreeElement subclass.
+
+        * UserInterface/Views/ResourceTreeElement.js:
+        (WebInspector.ResourceTreeElement.prototype._updateStatus):
+        Set to the empty string instead of null to avoid inadvertently
+        creating status elements for no reason.
+
+2015-02-22  Joseph Pecoraro  <pecoraro@apple.com>
+
         Web Inspector: Give ObjectPreviewView a showTitle/showPreview toggle
         https://bugs.webkit.org/show_bug.cgi?id=141874
 
index 0ff3e10..ccaa2f6 100644 (file)
@@ -206,6 +206,11 @@ WebInspector.GeneralTreeElement.prototype = {
         if (this._status === x)
             return;
 
+        if (!this._statusElement) {
+            this._statusElement = document.createElement("div");
+            this._statusElement.className = WebInspector.GeneralTreeElement.StatusElementStyleClassName;
+        }
+
         this._status = x || "";
         this._updateStatusElement();
     },
@@ -236,7 +241,6 @@ WebInspector.GeneralTreeElement.prototype = {
     {
         this._createElementsIfNeeded();
         this._updateTitleElements();
-        this._updateStatusElement();
 
         this._listItemNode.classList.add(WebInspector.GeneralTreeElement.StyleClassName);
 
@@ -253,7 +257,6 @@ WebInspector.GeneralTreeElement.prototype = {
 
         this._listItemNode.appendChild(this._disclosureButton);
         this._listItemNode.appendChild(this._iconElement);
-        this._listItemNode.appendChild(this._statusElement);
         this._listItemNode.appendChild(this._titlesElement);
 
         if (this.oncontextmenu && typeof this.oncontextmenu === "function") {
@@ -265,6 +268,8 @@ WebInspector.GeneralTreeElement.prototype = {
             this._boundContextMenuEventHandler = function(event) { this.treeOutline.oncontextmenu(event, this); }.bind(this);
             this._listItemNode.addEventListener("contextmenu", this._boundContextMenuEventHandler, true);
         }
+
+        this._updateStatusElement();
     },
 
     ondetach: function()
@@ -314,9 +319,6 @@ WebInspector.GeneralTreeElement.prototype = {
         this._iconElement = document.createElement("img");
         this._iconElement.className = WebInspector.GeneralTreeElement.IconElementStyleClassName;
 
-        this._statusElement = document.createElement("div");
-        this._statusElement.className = WebInspector.GeneralTreeElement.StatusElementStyleClassName;
-
         this._titlesElement = document.createElement("div");
         this._titlesElement.className = WebInspector.GeneralTreeElement.TitlesElementStyleClassName;
 
@@ -385,9 +387,12 @@ WebInspector.GeneralTreeElement.prototype = {
 
     _updateStatusElement: function()
     {
-        if (!this._createdElements)
+        if (!this._statusElement)
             return;
 
+        if (!this._statusElement.parentNode && this._listItemNode)
+            this._listItemNode.insertBefore(this._statusElement, this._titlesElement);
+
         if (this._status instanceof Node) {
             this._statusElement.removeChildren();
             this._statusElement.appendChild(this._status);
index 30c75fd..b8098a9 100644 (file)
@@ -169,7 +169,7 @@ WebInspector.ResourceTreeElement.prototype = {
             if (this._resource.isMainResource() && frame && frame.isMainFrame() && this instanceof WebInspector.FrameTreeElement)
                 this.updateStatusForMainFrame();
             else
-                this.status = null;
+                this.status = "";
         } else {
             var spinner = new WebInspector.IndeterminateProgressSpinner;
             this.status = spinner.element;