Title: [136044] branches/chromium/1312
Revision
136044
Author
[email protected]
Date
2012-11-28 12:32:37 -0800 (Wed, 28 Nov 2012)

Log Message

Merge 135720 - Web Inspector: object preview does not render node id, className; logs too many functions for jQuery.
https://bugs.webkit.org/show_bug.cgi?id=103222

Reviewed by Yury Semikhatsky.

Source/WebCore:

- Added node class name and id into the preview
- Now keeps track of properties separately from array indexes.

* inspector/InjectedScriptSource.js:
(.):
* inspector/InspectorOverlayPage.html:
* inspector/front-end/ConsoleMessage.js:
(WebInspector.ConsoleMessageImpl.prototype._appendObjectPreview):
(WebInspector.ConsoleMessageImpl.prototype._appendPropertyPreview):

LayoutTests:

* inspector/console/command-line-api-expected.txt:
* inspector/console/command-line-api-inspect-expected.txt:
* inspector/console/console-dir-expected.txt:
* inspector/console/console-format-collections-expected.txt:
* inspector/console/console-format-expected.txt:
* inspector/elements/event-listener-sidebar-expected.txt:
* inspector/elements/event-listeners-about-blank-expected.txt:
* platform/chromium-linux/inspector/console/console-format-collections-expected.txt: Removed.
* platform/chromium/inspector/console/command-line-api-inspect-expected.txt:
* platform/chromium/inspector/console/console-dir-expected.txt:
* platform/chromium/inspector/console/console-format-collections-expected.txt:

[email protected]
BUG=135720
Review URL: https://chromiumcodereview.appspot.com/11434008

Modified Paths

Diff

Modified: branches/chromium/1312/LayoutTests/inspector/console/command-line-api-expected.txt (136043 => 136044)


--- branches/chromium/1312/LayoutTests/inspector/console/command-line-api-expected.txt	2012-11-28 20:30:07 UTC (rev 136043)
+++ branches/chromium/1312/LayoutTests/inspector/console/command-line-api-expected.txt	2012-11-28 20:32:37 UTC (rev 136044)
@@ -1,4 +1,4 @@
-CONSOLE MESSAGE: line 1029: The console function $() has changed from $=getElementById(id) to $=querySelector(selector). You might try $("#%s")
+CONSOLE MESSAGE: line 1047: The console function $() has changed from $=getElementById(id) to $=querySelector(selector). You might try $("#%s")
 Tests that command line api works.
 
 

Modified: branches/chromium/1312/LayoutTests/inspector/console/command-line-api-inspect-expected.txt (136043 => 136044)


--- branches/chromium/1312/LayoutTests/inspector/console/command-line-api-inspect-expected.txt	2012-11-28 20:30:07 UTC (rev 136043)
+++ branches/chromium/1312/LayoutTests/inspector/console/command-line-api-inspect-expected.txt	2012-11-28 20:32:37 UTC (rev 136044)
@@ -4,7 +4,7 @@
 Running: testRevealElement
 
 
-WebInspector.inspect called with: <p>
+WebInspector.inspect called with: p#p1
 WebInspector.inspect's hints are: []
 inspect($('#p1')) = 
 Selected node id: 'p1'.

Modified: branches/chromium/1312/LayoutTests/inspector/console/console-dir-expected.txt (136043 => 136044)


--- branches/chromium/1312/LayoutTests/inspector/console/console-dir-expected.txt	2012-11-28 20:30:07 UTC (rev 136043)
+++ branches/chromium/1312/LayoutTests/inspector/console/console-dir-expected.txt	2012-11-28 20:32:37 UTC (rev 136044)
@@ -12,7 +12,7 @@
     __proto__: Array[0] console-dir.html:9
 
 NodeList[1]
-    0: <html>
+    0: html
     constructor: NodeListConstructor
     length: 1
     __proto__: NodeListPrototype console-dir.html:10

Modified: branches/chromium/1312/LayoutTests/inspector/console/console-format-collections-expected.txt (136043 => 136044)


--- branches/chromium/1312/LayoutTests/inspector/console/console-format-collections-expected.txt	2012-11-28 20:30:07 UTC (rev 136043)
+++ branches/chromium/1312/LayoutTests/inspector/console/console-format-collections-expected.txt	2012-11-28 20:32:37 UTC (rev 136044)
@@ -27,12 +27,12 @@
 Array[2] console-format-collections.html:41
 NonArrayWithLength console-format-collections.html:44
 Arguments[2] console-format-collections.html:51
-[<select>, item: function] console-format-collections.html:15
-[<script>, <script>, <script>, item: function, namedItem: function] console-format-collections.html:19
-[<option>, <option>, selectedIndex: 0, remove: function, add: function, item: function, namedItem: function] console-format-collections.html:23
-[<html>, <head>, <script>, <script>, <script>, <body>, <p>, <div>, <form>, <select>, <option>, <option>, <input>, <input>, namedItem: function, tags: function, item: function] console-format-collections.html:27
-[<select>, <input>, <input>, item: function, namedItem: function] console-format-collections.html:31
-[<input>, <input>, item: function] console-format-collections.html:35
+[select#sel, item: function] console-format-collections.html:15
+[script, script, script, item: function, namedItem: function] console-format-collections.html:19
+[option, option, selectedIndex: 0, remove: function, namedItem: function, add: function, item: function…] console-format-collections.html:23
+[html, head, script, script, script, body, p, div, form#f, select#sel, option, option, input, input, namedItem: function, tags: function, item: function] console-format-collections.html:27
+[select#sel, input, input, namedItem: function, item: function, namedItem: function] console-format-collections.html:31
+[input, input, item: function] console-format-collections.html:35
 [1, Array[2]] console-format-collections.html:41
 NonArrayWithLength {keys: Array[0]} console-format-collections.html:44
 [1, "2"] console-format-collections.html:51

Modified: branches/chromium/1312/LayoutTests/inspector/console/console-format-expected.txt (136043 => 136044)


--- branches/chromium/1312/LayoutTests/inspector/console/console-format-expected.txt	2012-11-28 20:30:07 UTC (rev 136043)
+++ branches/chromium/1312/LayoutTests/inspector/console/console-format-expected.txt	2012-11-28 20:32:37 UTC (rev 136044)
@@ -83,7 +83,7 @@
 globals[4]
 Error {}
 <p id="p">Tests that console logging dumps proper messages.</p> console-format.html:54
-[<p>] console-format.html:55
+[p#p] console-format.html:55
 globals[5]
 <p id="p">Tests that console logging dumps proper messages.</p>
 function () { return 1; } console-format.html:54

Modified: branches/chromium/1312/LayoutTests/inspector/elements/event-listener-sidebar-expected.txt (136043 => 136044)


--- branches/chromium/1312/LayoutTests/inspector/elements/event-listener-sidebar-expected.txt	2012-11-28 20:30:07 UTC (rev 136043)
+++ branches/chromium/1312/LayoutTests/inspector/elements/event-listener-sidebar-expected.txt	2012-11-28 20:32:37 UTC (rev 136044)
@@ -21,7 +21,7 @@
     isAttribute: false
     lineNumber: 15
     listenerBody: function (event) { console.log("click - button - capturing"); }
-    node: <button>
+    node: button#node
     sourceName: [clipped-for-test]/LayoutTests/inspector/elements/event-listener-sidebar.html
     type: click
     useCapture: true
@@ -29,7 +29,7 @@
     isAttribute: false
     lineNumber: 12
     listenerBody: function clickHandler(event) { console.log("click - button - bubbling (registered before attribute)"); }
-    node: <button>
+    node: button#node
     sourceName: [clipped-for-test]/LayoutTests/inspector/elements/event-listener-sidebar.html
     type: click
     useCapture: false
@@ -37,7 +37,7 @@
     isAttribute: true
     lineNumber: 16
     listenerBody: function (event) { console.log("click - button - attribute"); }
-    node: <button>
+    node: button#node
     sourceName: [clipped-for-test]/LayoutTests/inspector/elements/event-listener-sidebar.html
     type: click
     useCapture: false
@@ -45,7 +45,7 @@
     isAttribute: false
     lineNumber: 17
     listenerBody: function (event) { console.log("click - button - bubbling (registered after attribute)"); }
-    node: <button>
+    node: button#node
     sourceName: [clipped-for-test]/LayoutTests/inspector/elements/event-listener-sidebar.html
     type: click
     useCapture: false
@@ -63,7 +63,7 @@
     isAttribute: false
     lineNumber: 10
     listenerBody: function f() {}
-    node: <body>
+    node: body
     sourceName: [clipped-for-test]/LayoutTests/inspector/elements/event-listener-sidebar.html
     type: custom event
     useCapture: true
@@ -73,7 +73,7 @@
     isAttribute: false
     lineNumber: 14
     listenerBody: function hoverHandler(event) { console.log("hover - button - bubbling"); }
-    node: <button>
+    node: button#node
     sourceName: [clipped-for-test]/LayoutTests/inspector/elements/event-listener-sidebar.html
     type: hover
     useCapture: false
@@ -107,7 +107,7 @@
     isAttribute: false
     lineNumber: 10
     listenerBody: function f() {}
-    node: <body>
+    node: body
     sourceName: [clipped-for-test]/LayoutTests/inspector/elements/event-listener-sidebar.html
     type: custom event
     useCapture: true

Modified: branches/chromium/1312/LayoutTests/inspector/elements/event-listeners-about-blank-expected.txt (136043 => 136044)


--- branches/chromium/1312/LayoutTests/inspector/elements/event-listeners-about-blank-expected.txt	2012-11-28 20:30:07 UTC (rev 136043)
+++ branches/chromium/1312/LayoutTests/inspector/elements/event-listeners-about-blank-expected.txt	2012-11-28 20:32:37 UTC (rev 136044)
@@ -7,7 +7,7 @@
     isAttribute: false
     lineNumber: 9
     listenerBody: function f() {}
-    node: <body>
+    node: body
     sourceName: [clipped-for-test]/LayoutTests/inspector/elements/event-listeners-about-blank.html
     type: click
     useCapture: true
@@ -17,7 +17,7 @@
     isAttribute: false
     lineNumber: 9
     listenerBody: function f() {}
-    node: <div>
+    node: div#div-in-iframe
     sourceName: [clipped-for-test]/LayoutTests/inspector/elements/event-listeners-about-blank.html
     type: hover
     useCapture: true

Modified: branches/chromium/1312/LayoutTests/platform/chromium/inspector/console/command-line-api-inspect-expected.txt (136043 => 136044)


--- branches/chromium/1312/LayoutTests/platform/chromium/inspector/console/command-line-api-inspect-expected.txt	2012-11-28 20:30:07 UTC (rev 136043)
+++ branches/chromium/1312/LayoutTests/platform/chromium/inspector/console/command-line-api-inspect-expected.txt	2012-11-28 20:32:37 UTC (rev 136044)
@@ -4,7 +4,7 @@
 Running: testRevealElement
 
 
-WebInspector.inspect called with: <p>
+WebInspector.inspect called with: p#p1
 WebInspector.inspect's hints are: []
 inspect($('#p1')) = 
 Selected node id: 'p1'.

Modified: branches/chromium/1312/LayoutTests/platform/chromium/inspector/console/console-dir-expected.txt (136043 => 136044)


--- branches/chromium/1312/LayoutTests/platform/chromium/inspector/console/console-dir-expected.txt	2012-11-28 20:30:07 UTC (rev 136043)
+++ branches/chromium/1312/LayoutTests/platform/chromium/inspector/console/console-dir-expected.txt	2012-11-28 20:32:37 UTC (rev 136044)
@@ -12,7 +12,7 @@
     __proto__: Array[0] console-dir.html:9
 
 NodeList[1]
-    0: <html>
+    0: html
     length: 1
     __proto__: NodeList console-dir.html:10
 

Modified: branches/chromium/1312/LayoutTests/platform/chromium/inspector/console/console-format-collections-expected.txt (136043 => 136044)


--- branches/chromium/1312/LayoutTests/platform/chromium/inspector/console/console-format-collections-expected.txt	2012-11-28 20:30:07 UTC (rev 136043)
+++ branches/chromium/1312/LayoutTests/platform/chromium/inspector/console/console-format-collections-expected.txt	2012-11-28 20:32:37 UTC (rev 136044)
@@ -2,7 +2,7 @@
 CONSOLE MESSAGE: line 19: [object HTMLCollection]
 CONSOLE MESSAGE: line 23: [object HTMLOptionsCollection]
 CONSOLE MESSAGE: line 27: undefined
-CONSOLE MESSAGE: line 31: [object HTMLCollection]
+CONSOLE MESSAGE: line 31: [object HTMLFormControlsCollection]
 CONSOLE MESSAGE: line 35: [object NodeList]
 CONSOLE MESSAGE: line 41: 1,2,
 CONSOLE MESSAGE: line 44: [object Object]
@@ -11,7 +11,7 @@
 CONSOLE MESSAGE: line 19: [object HTMLCollection]
 CONSOLE MESSAGE: line 23: [object HTMLOptionsCollection]
 CONSOLE MESSAGE: line 27: undefined
-CONSOLE MESSAGE: line 31: [object HTMLCollection]
+CONSOLE MESSAGE: line 31: [object HTMLFormControlsCollection]
 CONSOLE MESSAGE: line 35: [object NodeList]
 CONSOLE MESSAGE: line 41: 1,2,
 CONSOLE MESSAGE: line 44: [object Object]
@@ -22,17 +22,17 @@
 HTMLCollection[3] console-format-collections.html:19
 HTMLOptionsCollection[2] console-format-collections.html:23
 HTMLAllCollection[14] console-format-collections.html:27
-HTMLCollection[3] console-format-collections.html:31
+HTMLFormControlsCollection[3] console-format-collections.html:31
 NodeList[2] console-format-collections.html:35
 Array[2] console-format-collections.html:41
 NonArrayWithLength console-format-collections.html:44
 Arguments[2] console-format-collections.html:51
-[<select>, item: function] console-format-collections.html:15
-[<script>, <script>, <script>, item: function, namedItem: function] console-format-collections.html:19
-[<option>, <option>, selectedIndex: 0, add: function, remove: function, item: function, namedItem: function] console-format-collections.html:23
-[<html>, <head>, <script>, <script>, <script>, <body>, <p>, <div>, <form>, <select>, <option>, <option>, <input>, <input>, item: function, namedItem: function, tags: function] console-format-collections.html:27
-[<select>, <input>, <input>, item: function, namedItem: function] console-format-collections.html:31
-[<input>, <input>, item: function] console-format-collections.html:35
+[select#sel, item: function] console-format-collections.html:15
+[script, script, script, item: function, namedItem: function] console-format-collections.html:19
+[option, option, selectedIndex: 0, namedItem: function, add: function, remove: function, item: function…] console-format-collections.html:23
+[html, head, script, script, script, body, p, div, form#f, select#sel, option, option, input, input, item: function, namedItem: function, tags: function] console-format-collections.html:27
+[select#sel, input, input, namedItem: function, item: function, namedItem: function] console-format-collections.html:31
+[input, input, item: function] console-format-collections.html:35
 [1, Array[2]] console-format-collections.html:41
 NonArrayWithLength {keys: Array[0]} console-format-collections.html:44
 [1, "2"] console-format-collections.html:51

Modified: branches/chromium/1312/Source/WebCore/inspector/InjectedScriptSource.js (136043 => 136044)


--- branches/chromium/1312/Source/WebCore/inspector/InjectedScriptSource.js	2012-11-28 20:30:07 UTC (rev 136043)
+++ branches/chromium/1312/Source/WebCore/inspector/InjectedScriptSource.js	2012-11-28 20:32:37 UTC (rev 136044)
@@ -712,7 +712,9 @@
             var description = obj.nodeName.toLowerCase();
             switch (obj.nodeType) {
             case 1 /* Node.ELEMENT_NODE */:
-                description =  "<" + description + ">";
+                description += obj.id ? "#" + obj.id : "";
+                var className = obj.className;
+                description += className ? "." + className : "";
                 break;
             case 10 /*Node.DOCUMENT_TYPE_NODE */:
                 description = "<!DOCTYPE " + description + ">";
@@ -809,22 +811,25 @@
         this.preview.properties = [];
 
         var isArray = this.subtype === "array";
-        var elementsToDump = isArray ? 100 : 5;
+        var propertiesThreshold = {
+            properties: 5,
+            indexes: 100
+        };
 
         for (var o = object; injectedScript._isDefined(o); o = o.__proto__)
-            this._generateProtoPreview(o, elementsToDump);
+            this._generateProtoPreview(o, propertiesThreshold);
     },
 
     /**
      * @param {Object} object
-     * @param {number} elementsToDump
+     * @param {Object} propertiesThreshold
      */
-    _generateProtoPreview: function(object, elementsToDump)
+    _generateProtoPreview: function(object, propertiesThreshold)
     {
         var propertyNames = Object.keys(/** @type {!Object} */(object));
         try {
             for (var i = 0; i < propertyNames.length; ++i) {
-                if (this.preview.properties.length >= elementsToDump) {
+                if (!propertiesThreshold.properties || !propertiesThreshold.indexes) {
                     this.preview.overflow = true;
                     this.preview.lossless = false;
                     break;
@@ -841,7 +846,7 @@
 
                 var value = descriptor.value;
                 if (value === null) {
-                    this.preview.properties.push({ name: name, type: "object", value: "null" });
+                    this._appendPropertyPreview({ name: name, type: "object", value: "null" }, propertiesThreshold);
                     continue;
                 }
     
@@ -856,7 +861,7 @@
                         }
                         value = "\"" + value.replace(/\n/g, "\u21B5") + "\"";
                     }
-                    this.preview.properties.push({ name: name, type: type, value: value + "" });
+                    this._appendPropertyPreview({ name: name, type: type, value: value + "" }, propertiesThreshold);
                     continue;
                 }
     
@@ -870,13 +875,26 @@
                 var property = { name: name, type: type, value: description };
                 if (subtype)
                     property.subtype = subtype;
-                this.preview.properties.push(property);
+                this._appendPropertyPreview(property, propertiesThreshold);
             }
         } catch (e) {
         }
     },
 
     /**
+     * @param {Object} property
+     * @param {Object} propertiesThreshold
+     */
+    _appendPropertyPreview: function(property, propertiesThreshold)
+    {
+        if (isNaN(property.name))
+            propertiesThreshold.properties--;
+        else
+            propertiesThreshold.indexes--;
+        this.preview.properties.push(property);
+    },
+
+    /**
      * @param {string} string
      * @param {number} maxLength
      * @param {boolean=} middle

Modified: branches/chromium/1312/Source/WebCore/inspector/InspectorOverlayPage.html (136043 => 136044)


--- branches/chromium/1312/Source/WebCore/inspector/InspectorOverlayPage.html	2012-11-28 20:30:07 UTC (rev 136043)
+++ branches/chromium/1312/Source/WebCore/inspector/InspectorOverlayPage.html	2012-11-28 20:32:37 UTC (rev 136044)
@@ -83,13 +83,20 @@
 }
 
 #tag-name {
+    /* Keep this in sync with view-source.css (.webkit-html-tag-name) */
     color: rgb(136, 18, 128);
 }
 
 #node-id {
+    /* Keep this in sync with view-source.css (.webkit-html-attribute-value) */
     color: rgb(26, 26, 166);
 }
 
+#class-name {
+    /* Keep this in sync with view-source.css (.webkit-html-attribute-name) */
+    color: rgb(153, 69, 0);
+}
+
 #right-gutter {
     display: none;
     right: 0;
@@ -335,8 +342,11 @@
         return;
 
     document.getElementById("tag-name").textContent = elementInfo.tagName;
-    document.getElementById("node-id").textContent = elementInfo.nodeId ? "#" + elementInfo.nodeId : "";
-    document.getElementById("class-name").textContent = elementInfo.className || "";
+    document.getElementById("node-id").textContent = elementInfo.idValue ? "#" + elementInfo.idValue : "";
+    var className = elementInfo.className;
+    if (className.length > 50)
+       className = className.substring(0, 50) + "\u2026";
+    document.getElementById("class-name").textContent = className;
     document.getElementById("node-width").textContent = elementInfo.nodeWidth;
     document.getElementById("node-height").textContent = elementInfo.nodeHeight;
     var elementTitle = document.getElementById("element-title");

Modified: branches/chromium/1312/Source/WebCore/inspector/front-end/ConsoleMessage.js (136043 => 136044)


--- branches/chromium/1312/Source/WebCore/inspector/front-end/ConsoleMessage.js	2012-11-28 20:30:07 UTC (rev 136043)
+++ branches/chromium/1312/Source/WebCore/inspector/front-end/ConsoleMessage.js	2012-11-28 20:32:37 UTC (rev 136044)
@@ -318,17 +318,7 @@
                 titleElement.createTextChild(": ");
             }
 
-            var span = titleElement.createChild("span", "console-formatted-" + property.type);
-            if (property.type === "object") {
-                if (property.subtype === "node")
-                    span.addStyleClass("console-formatted-preview-node");
-                else if (property.subtype === "regexp")
-                    span.addStyleClass("console-formatted-string");
-                span.textContent = property.value;
-            } else if (property.type === "function")
-                span.textContent = "function";
-            else
-                span.textContent = property.value;
+            this._appendPropertyPreview(titleElement, property);
         }
         if (preview.overflow)
             titleElement.createChild("span").textContent = "\u2026";
@@ -336,6 +326,39 @@
         return preview.lossless;
     },
 
+    /**
+     * @param {Element} titleElement
+     * @param {RuntimeAgent.PropertyPreview} property
+     */
+    _appendPropertyPreview: function(titleElement, property)
+    {
+        var span = titleElement.createChild("span", "console-formatted-" + property.type);
+
+        if (property.type === "function") {
+            span.textContent = "function";
+            return;
+        }
+
+        if (property.type === "object" && property.subtype === "regexp") {
+            span.addStyleClass("console-formatted-string");
+            span.textContent = property.value;
+            return;
+        }
+
+        if (property.type === "object" && property.subtype === "node") {
+            span.addStyleClass("console-formatted-preview-node");
+            var match = property.value.match(/([^#.]+)(#[^.]+)?(\..*)?/);
+            span.createChild("span", "webkit-html-tag-name").textContent = match[1];
+            if (match[2])
+                span.createChild("span", "webkit-html-attribute-value").textContent = match[2];
+            if (match[3])
+                span.createChild("span", "webkit-html-attribute-name").textContent = match[3];
+            return;
+        }
+
+        span.textContent = property.value;
+    },
+
     _formatParameterAsNode: function(object, elem)
     {
         function printNode(nodeId)
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to