Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(294)

Unified Diff: Source/WebCore/inspector/InjectedScriptSource.js

Issue 11434008: Merge 135720 - Web Inspector: object preview does not render node id, className; logs too many func… (Closed) Base URL: http://svn.webkit.org/repository/webkit/branches/chromium/1312/
Patch Set: Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/WebCore/inspector/InjectedScriptSource.js
===================================================================
--- Source/WebCore/inspector/InjectedScriptSource.js (revision 136041)
+++ Source/WebCore/inspector/InjectedScriptSource.js (working copy)
@@ -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

Powered by Google App Engine
This is Rietveld 408576698