Web Inspector: Expanding Object with only __proto__ looks poor should have a label
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 7 May 2015 21:16:59 +0000 (21:16 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 7 May 2015 21:16:59 +0000 (21:16 +0000)
https://bugs.webkit.org/show_bug.cgi?id=144755

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

Better handle cases where expanding an object has only a __proto__
and no other properties.

* UserInterface/Views/ObjectTreePropertyTreeElement.js:
(WebInspector.ObjectTreePropertyTreeElement.mode.prototype.this.children.length):
(WebInspector.ObjectTreePropertyTreeElement):
* UserInterface/Views/ObjectTreeView.css:
(.object-tree-outline li .empty-message):
* UserInterface/Views/ObjectTreeView.js:
(WebInspector.ObjectTreeView.createEmptyMessageElement):
(WebInspector.ObjectTreeView.comparePropertyDescriptors):
(WebInspector.ObjectTreeView.prototype._updateProperties):

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

Source/WebInspectorUI/ChangeLog
Source/WebInspectorUI/UserInterface/Views/ObjectTreePropertyTreeElement.js
Source/WebInspectorUI/UserInterface/Views/ObjectTreeView.css
Source/WebInspectorUI/UserInterface/Views/ObjectTreeView.js

index 3055e75..c76a6b4 100644 (file)
@@ -1,5 +1,25 @@
 2015-05-07  Joseph Pecoraro  <pecoraro@apple.com>
 
+        Web Inspector: Expanding Object with only __proto__ looks poor should have a label
+        https://bugs.webkit.org/show_bug.cgi?id=144755
+
+        Reviewed by Timothy Hatcher.
+
+        Better handle cases where expanding an object has only a __proto__
+        and no other properties.
+
+        * UserInterface/Views/ObjectTreePropertyTreeElement.js:
+        (WebInspector.ObjectTreePropertyTreeElement.mode.prototype.this.children.length):
+        (WebInspector.ObjectTreePropertyTreeElement):
+        * UserInterface/Views/ObjectTreeView.css:
+        (.object-tree-outline li .empty-message):
+        * UserInterface/Views/ObjectTreeView.js:
+        (WebInspector.ObjectTreeView.createEmptyMessageElement):
+        (WebInspector.ObjectTreeView.comparePropertyDescriptors):
+        (WebInspector.ObjectTreeView.prototype._updateProperties):
+
+2015-05-07  Joseph Pecoraro  <pecoraro@apple.com>
+
         Web Inspector: Fix querySelector in ResourceContentView.js, caught by assertion
         https://bugs.webkit.org/show_bug.cgi?id=144756
 
index 08b199a..88e6b78 100644 (file)
@@ -363,6 +363,7 @@ WebInspector.ObjectTreePropertyTreeElement = class ObjectTreePropertyTreeElement
                 prototypeName = this._sanitizedPrototypeString(resolvedValue);
         }
 
+        var hadProto = false;
         for (var propertyDescriptor of properties) {
             // FIXME: If this is a pure API ObjectTree, we should show the native getters.
             // For now, just skip native binding getters in API mode, since we likely
@@ -377,11 +378,14 @@ WebInspector.ObjectTreePropertyTreeElement = class ObjectTreePropertyTreeElement
                     this.appendChild(new WebInspector.ObjectTreePropertyTreeElement(propertyDescriptor, propertyPath, mode, prototypeName));
             } else
                 this.appendChild(new WebInspector.ObjectTreePropertyTreeElement(propertyDescriptor, propertyPath, mode, prototypeName));
+
+            if (propertyDescriptor.name === "__proto__")
+                hadProto = true;
         }
 
-        if (!this.children.length) {
+        if (!this.children.length || (hadProto && this.children.length === 1)) {
             var emptyMessageElement = WebInspector.ObjectTreeView.createEmptyMessageElement(WebInspector.UIString("No Properties."));
-            this.appendChild(new WebInspector.TreeElement(emptyMessageElement, null, false));
+            this.insertChild(new WebInspector.TreeElement(emptyMessageElement, null, false), 0);
         }
     }
 };
index a17782c..ca736fe 100644 (file)
 
 .object-tree-outline li .empty-message {
     color: rgb(60%, 60%, 60%);
-    margin-left: 7px;
+    margin-left: 15px;
     font-family: -webkit-system-font, sans-serif;
     font-size: 12px;
 }
index d26a76a..ef4349c 100644 (file)
@@ -94,7 +94,7 @@ WebInspector.ObjectTreeView = class ObjectTreeView extends WebInspector.Object
         emptyMessageElement.className = "empty-message";
         emptyMessageElement.textContent = message;
         return emptyMessageElement;
-    };
+    }
 
     static comparePropertyDescriptors(propertyA, propertyB)
     {
@@ -153,7 +153,7 @@ WebInspector.ObjectTreeView = class ObjectTreeView extends WebInspector.Object
             b = b.substring(chunkb.length);
         }
         return diff;
-    };
+    }
 
     // Public
 
@@ -289,6 +289,7 @@ WebInspector.ObjectTreeView = class ObjectTreeView extends WebInspector.Object
         var isArray = this._object.isArray();
         var isPropertyMode = this._mode === WebInspector.ObjectTreeView.Mode.Properties;
 
+        var hadProto = false;
         for (var propertyDescriptor of properties) {
             if (isArray && isPropertyMode) {
                 if (propertyDescriptor.isIndexProperty())
@@ -297,11 +298,14 @@ WebInspector.ObjectTreeView = class ObjectTreeView extends WebInspector.Object
                     this._outline.appendChild(new WebInspector.ObjectTreePropertyTreeElement(propertyDescriptor, propertyPath, this._mode));
             } else
                 this._outline.appendChild(new WebInspector.ObjectTreePropertyTreeElement(propertyDescriptor, propertyPath, this._mode));
+
+            if (propertyDescriptor.name === "__proto__")
+                hadProto = true;
         }
 
-        if (!this._outline.children.length) {
+        if (!this._outline.children.length || (hadProto && this._outline.children.length === 1)) {
             var emptyMessageElement = WebInspector.ObjectTreeView.createEmptyMessageElement(WebInspector.UIString("No Properties."));
-            this._outline.appendChild(new WebInspector.TreeElement(emptyMessageElement, null, false));
+            this._outline.insertChild(new WebInspector.TreeElement(emptyMessageElement, null, false), 0);
         }
     }