Chromium Code Reviews| Index: Source/core/inspector/InjectedScriptSource.js |
| diff --git a/Source/core/inspector/InjectedScriptSource.js b/Source/core/inspector/InjectedScriptSource.js |
| index 1c03a23a06448097931cb3b917edf25f3a3e7b01..e7378ac547d8e5245cfbb0f65a25d514edcd145c 100644 |
| --- a/Source/core/inspector/InjectedScriptSource.js |
| +++ b/Source/core/inspector/InjectedScriptSource.js |
| @@ -1091,8 +1091,9 @@ var injectedScript = new InjectedScript(); |
| * @param {boolean=} generatePreview |
| * @param {?Array.<string>=} columnNames |
| * @param {boolean=} isTable |
| + * @param {boolean=} skipEntriesPreview |
| */ |
| -InjectedScript.RemoteObject = function(object, objectGroupName, forceValueType, generatePreview, columnNames, isTable) |
| +InjectedScript.RemoteObject = function(object, objectGroupName, forceValueType, generatePreview, columnNames, isTable, skipEntriesPreview) |
| { |
| this.type = typeof object; |
| if (injectedScript.isPrimitiveValue(object) || object === null || forceValueType) { |
| @@ -1133,7 +1134,7 @@ InjectedScript.RemoteObject = function(object, objectGroupName, forceValueType, |
| this.description = injectedScript._describe(object); |
| if (generatePreview && (this.type === "object" || injectedScript._isHTMLAllCollection(object))) |
| - this.preview = this._generatePreview(object, undefined, columnNames, isTable); |
| + this.preview = this._generatePreview(object, undefined, columnNames, isTable, skipEntriesPreview); |
| } |
| InjectedScript.RemoteObject.prototype = { |
| @@ -1142,20 +1143,28 @@ InjectedScript.RemoteObject.prototype = { |
| * @param {?Array.<string>=} firstLevelKeys |
| * @param {?Array.<string>=} secondLevelKeys |
| * @param {boolean=} isTable |
| + * @param {boolean=} skipEntriesPreview |
| * @return {!RuntimeAgent.ObjectPreview} preview |
| */ |
| - _generatePreview: function(object, firstLevelKeys, secondLevelKeys, isTable) |
| + _generatePreview: function(object, firstLevelKeys, secondLevelKeys, isTable, skipEntriesPreview) |
| { |
| - var preview = { __proto__: null }; |
| - preview.lossless = true; |
| - preview.overflow = false; |
| - preview.properties = []; |
| + var preview = { |
| + type: /** @type {!RuntimeAgent.ObjectPreviewType.<string>} */ (this.type), |
| + description: this.description || toStringDescription(this.value), |
| + lossless: true, |
| + overflow: false, |
| + properties: [], |
| + __proto__: null |
| + }; |
| + if (this.subtype) |
| + preview.subtype = /** @type {!RuntimeAgent.ObjectPreviewSubtype.<string>} */ (this.subtype); |
| var firstLevelKeysCount = firstLevelKeys ? firstLevelKeys.length : 0; |
| var propertiesThreshold = { |
| properties: isTable ? 1000 : max(5, firstLevelKeysCount), |
| - indexes: isTable ? 1000 : max(100, firstLevelKeysCount) |
| + indexes: isTable ? 1000 : max(100, firstLevelKeysCount), |
| + __proto__: null |
| }; |
| try { |
| @@ -1184,6 +1193,9 @@ InjectedScript.RemoteObject.prototype = { |
| } |
| this._appendPropertyDescriptors(preview, internalProperties, propertiesThreshold, secondLevelKeys, isTable); |
| + if (this.subtype === "map" || this.subtype === "set") |
| + this._appendEntriesPreview(object, preview, skipEntriesPreview); |
| + |
| } catch (e) { |
| preview.lossless = false; |
| } |
| @@ -1291,6 +1303,65 @@ InjectedScript.RemoteObject.prototype = { |
| }, |
| /** |
| + * @param {!Object} object |
| + * @param {!RuntimeAgent.ObjectPreview} preview |
| + * @param {boolean=} skipEntriesPreview |
| + */ |
| + _appendEntriesPreview: function(object, preview, skipEntriesPreview) |
| + { |
| + var entries = InjectedScriptHost.collectionEntries(object); |
| + if (!entries) |
| + return; |
| + if (skipEntriesPreview) { |
| + if (entries.length) { |
| + preview.overflow = true; |
| + preview.lossless = false; |
| + } |
| + return; |
| + } |
| + preview.entries = []; |
| + var entriesThreshold = 5; |
| + for (var i = 0; i < entries.length; ++i) { |
| + if (preview.entries.length >= entriesThreshold) { |
| + preview.overflow = true; |
| + preview.lossless = false; |
| + break; |
| + } |
| + var entry = nullifyObjectProto(entries[i]); |
| + var previewEntry = { |
| + value: generateValuePreview(entry.value), |
| + __proto__: null |
| + }; |
| + if ("key" in entry) |
| + previewEntry.key = generateValuePreview(entry.key); |
| + push(preview.entries, previewEntry); |
|
yurys
2014/09/14 12:42:03
Is it to avoid calling overwritten Array.prototype
aandrey
2014/09/15 06:51:57
Yep. We also have a presubmit check to catch this.
|
| + } |
| + |
| + /** |
| + * @param {*} value |
| + * @return {!RuntimeAgent.ObjectPreview} |
| + */ |
| + function generateValuePreview(value) |
| + { |
| + var remoteObject = new InjectedScript.RemoteObject(value, undefined, undefined, true, undefined, undefined, true); |
| + var valuePreview = remoteObject.preview || { |
| + type: remoteObject.type, |
| + subtype: remoteObject.subtype, |
| + description: remoteObject.description || toStringDescription(remoteObject.value), |
| + lossless: true, |
| + overflow: false, |
| + properties: [], |
| + __proto__: null |
| + }; |
| + if (remoteObject.objectId) |
| + injectedScript.releaseObject(remoteObject.objectId); |
| + if (!valuePreview.lossless) |
| + preview.lossless = false; |
| + return valuePreview; |
| + } |
| + }, |
| + |
| + /** |
| * @param {string} string |
| * @param {number} maxLength |
| * @param {boolean=} middle |