| Index: third_party/WebKit/Source/devtools/front_end/components/RemoteObjectPreviewFormatter.js
|
| diff --git a/third_party/WebKit/Source/devtools/front_end/components/RemoteObjectPreviewFormatter.js b/third_party/WebKit/Source/devtools/front_end/components/RemoteObjectPreviewFormatter.js
|
| index 54b36b0506c204d162804a7155aecbb6f9195e9d..e868de21d1c13af41141602360d3487945baa96f 100644
|
| --- a/third_party/WebKit/Source/devtools/front_end/components/RemoteObjectPreviewFormatter.js
|
| +++ b/third_party/WebKit/Source/devtools/front_end/components/RemoteObjectPreviewFormatter.js
|
| @@ -6,6 +6,19 @@
|
| */
|
| Components.RemoteObjectPreviewFormatter = class {
|
| /**
|
| + * @param {!Protocol.Runtime.PropertyPreview} a
|
| + * @param {!Protocol.Runtime.PropertyPreview} b
|
| + * @return {number}
|
| + */
|
| + static _objectPropertyComparator(a, b) {
|
| + if (a.type !== 'function' && b.type === 'function')
|
| + return -1;
|
| + if (a.type === 'function' && b.type !== 'function')
|
| + return 1;
|
| + return 0;
|
| + }
|
| +
|
| + /**
|
| * @param {!Element} parentElement
|
| * @param {!Protocol.Runtime.ObjectPreview} preview
|
| */
|
| @@ -49,20 +62,8 @@ Components.RemoteObjectPreviewFormatter = class {
|
| * @param {!Protocol.Runtime.ObjectPreview} preview
|
| */
|
| _appendObjectPropertiesPreview(parentElement, preview) {
|
| - var properties = preview.properties.filter(p => p.type !== 'accessor').stableSort(compareFunctionsLast);
|
| -
|
| - /**
|
| - * @param {!Protocol.Runtime.PropertyPreview} a
|
| - * @param {!Protocol.Runtime.PropertyPreview} b
|
| - */
|
| - function compareFunctionsLast(a, b) {
|
| - if (a.type !== 'function' && b.type === 'function')
|
| - return -1;
|
| - if (a.type === 'function' && b.type !== 'function')
|
| - return 1;
|
| - return 0;
|
| - }
|
| -
|
| + var properties = preview.properties.filter(p => p.type !== 'accessor')
|
| + .stableSort(Components.RemoteObjectPreviewFormatter._objectPropertyComparator);
|
| for (var i = 0; i < properties.length; ++i) {
|
| if (i > 0)
|
| parentElement.createTextChild(', ');
|
| @@ -81,18 +82,17 @@ Components.RemoteObjectPreviewFormatter = class {
|
| _appendArrayPropertiesPreview(parentElement, preview) {
|
| var arrayLength = SDK.RemoteObject.arrayLength(preview);
|
| var properties = preview.properties;
|
| - properties = properties.slice().stableSort(compareIndexesFirst);
|
| + var indexProperties = properties.filter(p => toArrayIndex(p.name) !== -1).stableSort(arrayPropertyComparator);
|
| + var otherProperties = properties.filter(p => toArrayIndex(p.name) === -1)
|
| + .stableSort(Components.RemoteObjectPreviewFormatter._objectPropertyComparator);
|
|
|
| /**
|
| * @param {!Protocol.Runtime.PropertyPreview} a
|
| * @param {!Protocol.Runtime.PropertyPreview} b
|
| + * @return {number}
|
| */
|
| - function compareIndexesFirst(a, b) {
|
| - var index1 = toArrayIndex(a.name);
|
| - var index2 = toArrayIndex(b.name);
|
| - if (index1 < 0)
|
| - return index2 < 0 ? 0 : 1;
|
| - return index2 < 0 ? -1 : index1 - index2;
|
| + function arrayPropertyComparator(a, b) {
|
| + return toArrayIndex(a.name) - toArrayIndex(b.name);
|
| }
|
|
|
| /**
|
| @@ -106,17 +106,45 @@ Components.RemoteObjectPreviewFormatter = class {
|
| return -1;
|
| }
|
|
|
| - for (var i = 0; i < properties.length; ++i) {
|
| + var lastNonEmptyArrayIndex = -1;
|
| + var property;
|
| + for (var i = 0; i < indexProperties.length; ++i) {
|
| if (i > 0)
|
| parentElement.createTextChild(', ');
|
| -
|
| - var property = properties[i];
|
| - if (property.name !== String(i) || i >= arrayLength) {
|
| - parentElement.appendChild(this._renderDisplayName(property.name));
|
| - parentElement.createTextChild(': ');
|
| + property = indexProperties[i];
|
| + var index = toArrayIndex(property.name);
|
| + if (index - lastNonEmptyArrayIndex > 1) {
|
| + appendUndefined(index);
|
| + parentElement.createTextChild(', ');
|
| }
|
| + lastNonEmptyArrayIndex = index;
|
| parentElement.appendChild(this._renderPropertyPreviewOrAccessor([property]));
|
| }
|
| +
|
| + var elementsAdded = indexProperties.length > 0;
|
| + if (arrayLength - lastNonEmptyArrayIndex > 1) {
|
| + if (lastNonEmptyArrayIndex > -1)
|
| + parentElement.createTextChild(', ');
|
| + appendUndefined(arrayLength);
|
| + elementsAdded = true;
|
| + }
|
| +
|
| + for (var i = 0; i < otherProperties.length; ++i) {
|
| + if (elementsAdded || i > 0)
|
| + parentElement.createTextChild(', ');
|
| + property = otherProperties[i];
|
| + parentElement.appendChild(this._renderDisplayName(property.name));
|
| + parentElement.createTextChild(': ');
|
| + parentElement.appendChild(this._renderPropertyPreviewOrAccessor([property]));
|
| + }
|
| +
|
| + /**
|
| + * @param {number} index
|
| + */
|
| + function appendUndefined(index) {
|
| + var span = parentElement.createChild('span', 'object-value-undefined');
|
| + span.textContent = Common.UIString('undefined × %d', index - lastNonEmptyArrayIndex - 1);
|
| + }
|
| }
|
|
|
| /**
|
|
|