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

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

Issue 2514893004: DevTools: show array entries that are getters (Closed)
Patch Set: Add needsManualRebase to TE Created 4 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: 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 567fd3aa1d307f225e5339421f31985df2fef2c6..9a54ade3e0a73b8ea8f88d9948dfc32f2cea9489 100644
--- a/third_party/WebKit/Source/devtools/front_end/console/ConsoleViewMessage.js
+++ b/third_party/WebKit/Source/devtools/front_end/console/ConsoleViewMessage.js
@@ -153,7 +153,7 @@ Console.ConsoleViewMessage = class {
}
if (columnRendered) {
- var cellElement = this._renderPropertyPreviewOrAccessor(table, [rowProperty, cellProperty]);
+ var cellElement = this._previewFormatter.renderPropertyPreviewOrAccessor([rowProperty, cellProperty], table);
cellElement.classList.add('console-message-nowrap-below');
rowValue[cellProperty.name] = cellElement;
}
@@ -522,7 +522,7 @@ Console.ConsoleViewMessage = class {
var titleElement = createElement('span');
if (includePreview && obj.preview) {
titleElement.classList.add('console-object-preview');
- this._previewFormatter.appendObjectPreview(titleElement, obj.preview);
+ this._previewFormatter.appendObjectPreview(titleElement, obj.preview, obj);
} else if (obj.type === 'function') {
Components.ObjectPropertiesSection.formatObjectAsFunction(obj, titleElement, false);
titleElement.classList.add('object-value-function');
@@ -574,19 +574,6 @@ Console.ConsoleViewMessage = class {
}
/**
- * @param {?SDK.RemoteObject} object
- * @param {!Array.<!Protocol.Runtime.PropertyPreview>} propertyPath
- * @return {!Element}
- */
- _renderPropertyPreviewOrAccessor(object, propertyPath) {
- var property = propertyPath.peekLast();
- if (property.type === 'accessor')
- return this._formatAsAccessorProperty(object, propertyPath.map(property => property.name), false);
- return this._previewFormatter.renderPropertyPreview(
- property.type, /** @type {string} */ (property.subtype), property.value);
- }
-
- /**
* @param {!SDK.RemoteObject} object
* @return {!Element}
*/
@@ -646,10 +633,13 @@ Console.ConsoleViewMessage = class {
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);
+ var formatter = this._previewFormatter;
+ if (property.getter) {
+ elements[name] = formatter.formatAsAccessorProperty([name], array);
+ } else if (property.value) {
+ var output = property.value;
+ elements[name] = formatter.renderPropertyPreview(output.type, output.subtype, output.description);
+ }
}
titleElement.createTextChild('[');
@@ -716,58 +706,6 @@ Console.ConsoleViewMessage = class {
}
/**
- * @param {!SDK.RemoteObject} output
- * @return {!Element}
- */
- _formatAsArrayEntry(output) {
- return this._previewFormatter.renderPropertyPreview(output.type, output.subtype, output.description);
- }
-
- /**
- * @param {?SDK.RemoteObject} object
- * @param {!Array.<string>} propertyPath
- * @param {boolean} isArrayEntry
- * @return {!Element}
- */
- _formatAsAccessorProperty(object, propertyPath, isArrayEntry) {
- var rootElement = Components.ObjectPropertyTreeElement.createRemoteObjectAccessorPropertySpan(
- object, propertyPath, onInvokeGetterClick.bind(this));
-
- /**
- * @param {?SDK.RemoteObject} result
- * @param {boolean=} wasThrown
- * @this {Console.ConsoleViewMessage}
- */
- function onInvokeGetterClick(result, wasThrown) {
- if (!result)
- return;
- rootElement.removeChildren();
- if (wasThrown) {
- var element = rootElement.createChild('span');
- element.textContent = Common.UIString('<exception>');
- element.title = /** @type {string} */ (result.description);
- } else if (isArrayEntry) {
- rootElement.appendChild(this._formatAsArrayEntry(result));
- } else {
- // Make a PropertyPreview from the RemoteObject similar to the backend logic.
- const maxLength = 100;
- var type = result.type;
- var subtype = result.subtype;
- var description = '';
- if (type !== 'function' && result.description) {
- if (type === 'string' || subtype === 'regexp')
- description = result.description.trimMiddle(maxLength);
- else
- description = result.description.trimEnd(maxLength);
- }
- rootElement.appendChild(this._previewFormatter.renderPropertyPreview(type, subtype, description));
- }
- }
-
- return rootElement;
- }
-
- /**
* @param {string} format
* @param {!Array.<!SDK.RemoteObject>} parameters
* @param {!Element} formattedResult

Powered by Google App Engine
This is Rietveld 408576698