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

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

Issue 2566443004: DevTools: merge array formatting logic (Closed)
Patch Set: 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
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..04c493ccf8529d7da6d10f2305a41cbe0dde4a68 100644
--- a/third_party/WebKit/Source/devtools/front_end/console/ConsoleViewMessage.js
+++ b/third_party/WebKit/Source/devtools/front_end/console/ConsoleViewMessage.js
@@ -624,70 +624,12 @@ Console.ConsoleViewMessage = class {
var isLongArray = array.arrayLength() > 100;
if (usePrintedArrayFormat || isLongArray)
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);
luoe 2016/12/08 22:36:45 this._formatAsAccessorProperty and this._formatAsA
- }
-
- 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, true);
+ var section = new Components.ObjectPropertiesSection(array, titleElement, this._linkifier);
+ section.element.classList.add('console-view-object-properties-section');
+ section.enableContextMenu();
+ return section.element;
}
/**

Powered by Google App Engine
This is Rietveld 408576698