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

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

Issue 2596133002: Reland of DevTools: merge array formatting logic (Closed)
Patch Set: test Created 3 years, 12 months 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 884af2c0c76778351bf61a79af790ad9ff386d42..44007078fd193f6dbd8affa017cc711c314fba13 100644
--- a/third_party/WebKit/Source/devtools/front_end/console/ConsoleViewMessage.js
+++ b/third_party/WebKit/Source/devtools/front_end/console/ConsoleViewMessage.js
@@ -463,7 +463,7 @@ Console.ConsoleViewMessage = class {
switch (type) {
case 'array':
case 'typedarray':
- element = this._formatParameterAsArray(output);
+ element = this._formatParameterAsObject(output, includePreview);
break;
case 'error':
element = this._formatParameterAsError(output);
@@ -618,82 +618,6 @@ Console.ConsoleViewMessage = class {
}
/**
- * @param {!SDK.RemoteObject} array
- * @return {!Element}
- */
- _formatParameterAsArray(array) {
- var usePrintedArrayFormat = this._message.type !== SDK.ConsoleMessage.MessageType.DirXML &&
- this._message.type !== SDK.ConsoleMessage.MessageType.Result;
- 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);
- }
-
- 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);
- }
- }
-
- /**
* @param {!SDK.RemoteObject} output
* @return {!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