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

Unified Diff: third_party/WebKit/Source/devtools/front_end/console/ConsoleViewMessage.js

Issue 2566443004: DevTools: merge array formatting logic (Closed)
Patch Set: rebase Created 4 years 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
« no previous file with comments | « third_party/WebKit/Source/devtools/front_end/components/RemoteObjectPreviewFormatter.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/devtools/front_end/console/ConsoleViewMessage.js
diff --git a/third_party/WebKit/Source/devtools/front_end/console/ConsoleViewMessage.js b/third_party/WebKit/Source/devtools/front_end/console/ConsoleViewMessage.js
index 73aedc4e179d8c807b396adce17e0a2844e34dd4..cb7fe590c27e7ccb3ea080ed418494a4d7357b59 100644
--- a/third_party/WebKit/Source/devtools/front_end/console/ConsoleViewMessage.js
+++ b/third_party/WebKit/Source/devtools/front_end/console/ConsoleViewMessage.js
@@ -622,72 +622,14 @@ Console.ConsoleViewMessage = class {
var usePrintedArrayFormat = this._message.type !== SDK.ConsoleMessage.MessageType.DirXML &&
this._message.type !== SDK.ConsoleMessage.MessageType.Result;
var isLongArray = array.arrayLength() > 100;
- if (usePrintedArrayFormat || isLongArray)
+ if (usePrintedArrayFormat || isLongArray || !array.preview)
return this._formatParameterAsObject(array, usePrintedArrayFormat || !isLongArray);
- var result = createElement('span');
- array.getAllProperties(false, printArrayResult.bind(this));
- return result;
-
- /**
- * @param {?Array.<!SDK.RemoteObjectProperty>} properties
- * @this {!Console.ConsoleViewMessage}
- */
- function printArrayResult(properties) {
- if (!properties) {
- result.appendChild(this._formatParameterAsObject(array, false));
- return;
- }
-
- var titleElement = createElementWithClass('span', 'console-object-preview');
- if (array.subtype === 'typedarray')
- titleElement.createTextChild(array.description + ' ');
- var elements = {};
- for (var i = 0; i < properties.length; ++i) {
- var property = properties[i];
- var name = property.name;
- if (isNaN(name))
- continue;
- if (property.getter)
- elements[name] = this._formatAsAccessorProperty(array, [name], true);
- else if (property.value)
- elements[name] = this._formatAsArrayEntry(property.value);
- }
-
- titleElement.createTextChild('[');
- var lastNonEmptyIndex = -1;
-
- function appendUndefined(titleElement, index) {
- if (index - lastNonEmptyIndex <= 1)
- return;
- var span = titleElement.createChild('span', 'object-value-undefined');
- span.textContent = Common.UIString('undefined × %d', index - lastNonEmptyIndex - 1);
- }
-
- var length = array.arrayLength();
- for (var i = 0; i < length; ++i) {
- var element = elements[i];
- if (!element)
- continue;
-
- if (i - lastNonEmptyIndex > 1) {
- appendUndefined(titleElement, i);
- titleElement.createTextChild(', ');
- }
-
- titleElement.appendChild(element);
- lastNonEmptyIndex = i;
- if (i < length - 1)
- titleElement.createTextChild(', ');
- }
- appendUndefined(titleElement, length);
-
- titleElement.createTextChild(']');
-
- var section = new Components.ObjectPropertiesSection(array, titleElement, this._linkifier);
- section.element.classList.add('console-view-object-properties-section');
- section.enableContextMenu();
- result.appendChild(section.element);
- }
+ var titleElement = createElementWithClass('span', 'console-object-preview');
+ this._previewFormatter.appendObjectPreview(titleElement, array.preview);
+ var section = new Components.ObjectPropertiesSection(array, titleElement, this._linkifier);
+ section.element.classList.add('console-view-object-properties-section');
+ section.enableContextMenu();
+ return section.element;
}
/**
« no previous file with comments | « third_party/WebKit/Source/devtools/front_end/components/RemoteObjectPreviewFormatter.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698