| Index: Source/devtools/front_end/console/ConsoleViewMessage.js
|
| diff --git a/Source/devtools/front_end/console/ConsoleViewMessage.js b/Source/devtools/front_end/console/ConsoleViewMessage.js
|
| index cec9422a28d15744acb0eaf29748f3ccff43aad3..4fdf0068a77b6402cdd0723962a0cc03003613d1 100644
|
| --- a/Source/devtools/front_end/console/ConsoleViewMessage.js
|
| +++ b/Source/devtools/front_end/console/ConsoleViewMessage.js
|
| @@ -51,8 +51,10 @@ WebInspector.ConsoleViewMessage = function(consoleMessage, linkifier, nestingLev
|
| /** @type {!Object.<string, function(!WebInspector.RemoteObject, !Element, boolean=)>} */
|
| this._customFormatters = {
|
| "object": this._formatParameterAsObject,
|
| - "array": this._formatParameterAsArray,
|
| - "node": this._formatParameterAsNode,
|
| + "array": this._formatParameterAsArray,
|
| + "node": this._formatParameterAsNode,
|
| + "map": this._formatParameterAsObject,
|
| + "set": this._formatParameterAsObject,
|
| "string": this._formatParameterAsString
|
| };
|
| }
|
| @@ -402,28 +404,27 @@ WebInspector.ConsoleViewMessage.prototype = {
|
| */
|
| _formatParameterAsObject: function(obj, elem, includePreview)
|
| {
|
| - this._formatParameterAsArrayOrObject(obj, obj.description || "", elem, includePreview);
|
| + this._formatParameterAsArrayOrObject(obj, elem, includePreview);
|
| },
|
|
|
| /**
|
| * @param {!WebInspector.RemoteObject} obj
|
| - * @param {string} description
|
| * @param {!Element} elem
|
| * @param {boolean=} includePreview
|
| */
|
| - _formatParameterAsArrayOrObject: function(obj, description, elem, includePreview)
|
| + _formatParameterAsArrayOrObject: function(obj, elem, includePreview)
|
| {
|
| var titleElement = document.createElement("span");
|
| - if (description)
|
| - titleElement.createTextChild(description);
|
| if (includePreview && obj.preview) {
|
| titleElement.classList.add("console-object-preview");
|
| - var lossless = this._appendObjectPreview(obj, description, titleElement);
|
| + var lossless = this._appendObjectPreview(titleElement, obj.preview, obj);
|
| if (lossless) {
|
| elem.appendChild(titleElement);
|
| titleElement.addEventListener("contextmenu", this._contextMenuEventFired.bind(this, obj), false);
|
| return;
|
| }
|
| + } else {
|
| + titleElement.createTextChild(obj.description || "");
|
| }
|
| var section = new WebInspector.ObjectPropertiesSection(obj, titleElement);
|
| section.enableContextMenu();
|
| @@ -445,43 +446,85 @@ WebInspector.ConsoleViewMessage.prototype = {
|
| },
|
|
|
| /**
|
| - * @param {!WebInspector.RemoteObject} obj
|
| - * @param {string} description
|
| - * @param {!Element} titleElement
|
| + * @param {!Element} parentElement
|
| + * @param {!RuntimeAgent.ObjectPreview} preview
|
| + * @param {?WebInspector.RemoteObject} object
|
| * @return {boolean} true iff preview captured all information.
|
| */
|
| - _appendObjectPreview: function(obj, description, titleElement)
|
| + _appendObjectPreview: function(parentElement, preview, object)
|
| {
|
| - var preview = obj.preview;
|
| - var isArray = obj.subtype === "array";
|
| + var description = preview.description;
|
| + if (preview.type !== "object" || preview.subtype === "null") {
|
| + parentElement.appendChild(this._renderPropertyPreview(preview.type, preview.subtype, description));
|
| + return true;
|
| + }
|
| + if (description && preview.subtype !== "array")
|
| + parentElement.createTextChildren(description, " ");
|
| + if (preview.entries)
|
| + return this._appendEntriesPreview(parentElement, preview);
|
| + return this._appendPropertiesPreview(parentElement, preview, object);
|
| + },
|
|
|
| - if (description)
|
| - titleElement.createTextChild(" ");
|
| - titleElement.createTextChild(isArray ? "[" : "{");
|
| + /**
|
| + * @param {!Element} parentElement
|
| + * @param {!RuntimeAgent.ObjectPreview} preview
|
| + * @param {?WebInspector.RemoteObject} object
|
| + * @return {boolean} true iff preview captured all information.
|
| + */
|
| + _appendPropertiesPreview: function(parentElement, preview, object)
|
| + {
|
| + var isArray = preview.subtype === "array";
|
| + parentElement.createTextChild(isArray ? "[" : "{");
|
| for (var i = 0; i < preview.properties.length; ++i) {
|
| if (i > 0)
|
| - titleElement.createTextChild(", ");
|
| + parentElement.createTextChild(", ");
|
|
|
| var property = preview.properties[i];
|
| var name = property.name;
|
| if (!isArray || name != i) {
|
| if (/^\s|\s$|^$|\n/.test(name))
|
| - titleElement.createChild("span", "name").createTextChildren("\"", name.replace(/\n/g, "\u21B5"), "\"");
|
| + parentElement.createChild("span", "name").createTextChildren("\"", name.replace(/\n/g, "\u21B5"), "\"");
|
| else
|
| - titleElement.createChild("span", "name").textContent = name;
|
| - titleElement.createTextChild(": ");
|
| + parentElement.createChild("span", "name").textContent = name;
|
| + parentElement.createTextChild(": ");
|
| }
|
|
|
| - titleElement.appendChild(this._renderPropertyPreviewOrAccessor(obj, [property]));
|
| + parentElement.appendChild(this._renderPropertyPreviewOrAccessor(object, [property]));
|
| }
|
| if (preview.overflow)
|
| - titleElement.createChild("span").textContent = "\u2026";
|
| - titleElement.createTextChild(isArray ? "]" : "}");
|
| + parentElement.createChild("span").textContent = "\u2026";
|
| + parentElement.createTextChild(isArray ? "]" : "}");
|
| return preview.lossless;
|
| },
|
|
|
| /**
|
| - * @param {!WebInspector.RemoteObject} object
|
| + * @param {!Element} parentElement
|
| + * @param {!RuntimeAgent.ObjectPreview} preview
|
| + * @return {boolean} true iff preview captured all information.
|
| + */
|
| + _appendEntriesPreview: function(parentElement, preview)
|
| + {
|
| + var lossless = preview.lossless && !preview.properties.length;
|
| + parentElement.createTextChild("{");
|
| + for (var i = 0; i < preview.entries.length; ++i) {
|
| + if (i > 0)
|
| + parentElement.createTextChild(", ");
|
| +
|
| + var entry = preview.entries[i];
|
| + if (entry.key) {
|
| + this._appendObjectPreview(parentElement, entry.key, null);
|
| + parentElement.createTextChild(" => ");
|
| + }
|
| + this._appendObjectPreview(parentElement, entry.value, null);
|
| + }
|
| + if (preview.overflow)
|
| + parentElement.createChild("span").textContent = "\u2026";
|
| + parentElement.createTextChild("}");
|
| + return lossless;
|
| + },
|
| +
|
| + /**
|
| + * @param {?WebInspector.RemoteObject} object
|
| * @param {!Array.<!RuntimeAgent.PropertyPreview>} propertyPath
|
| * @return {!Element}
|
| */
|
| @@ -502,17 +545,13 @@ WebInspector.ConsoleViewMessage.prototype = {
|
| _renderPropertyPreview: function(type, subtype, description)
|
| {
|
| var span = document.createElementWithClass("span", "console-formatted-" + (subtype || type));
|
| + description = description || "";
|
|
|
| if (type === "function") {
|
| span.textContent = "function";
|
| return span;
|
| }
|
|
|
| - if (type === "object" && subtype === "regexp") {
|
| - span.textContent = description;
|
| - return span;
|
| - }
|
| -
|
| if (type === "object" && subtype === "node" && description) {
|
| span.classList.add("console-formatted-preview-node");
|
| WebInspector.DOMPresentationUtils.createSpansForNodeTitle(span, description);
|
| @@ -571,7 +610,7 @@ WebInspector.ConsoleViewMessage.prototype = {
|
| _formatParameterAsArray: function(array, elem)
|
| {
|
| if (this.useArrayPreviewInFormatter(array)) {
|
| - this._formatParameterAsArrayOrObject(array, "", elem, true);
|
| + this._formatParameterAsArrayOrObject(array, elem, true);
|
| return;
|
| }
|
|
|
| @@ -730,7 +769,7 @@ WebInspector.ConsoleViewMessage.prototype = {
|
| },
|
|
|
| /**
|
| - * @param {!WebInspector.RemoteObject} object
|
| + * @param {?WebInspector.RemoteObject} object
|
| * @param {!Array.<string>} propertyPath
|
| * @param {boolean} isArrayEntry
|
| * @return {!Element}
|
|
|