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

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/object_ui/RemoteObjectPreviewFormatter.js

Issue 2723773003: DevTools: restore array lengths for long arrays (Closed)
Patch Set: ac Created 3 years, 9 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 /** 4 /**
5 * @unrestricted 5 * @unrestricted
6 */ 6 */
7 ObjectUI.RemoteObjectPreviewFormatter = class { 7 ObjectUI.RemoteObjectPreviewFormatter = class {
8 /** 8 /**
9 * @param {!Protocol.Runtime.PropertyPreview} a 9 * @param {!Protocol.Runtime.PropertyPreview} a
10 * @param {!Protocol.Runtime.PropertyPreview} b 10 * @param {!Protocol.Runtime.PropertyPreview} b
(...skipping 14 matching lines...) Expand all
25 */ 25 */
26 appendObjectPreview(parentElement, preview, isEntry) { 26 appendObjectPreview(parentElement, preview, isEntry) {
27 const previewExperimentEnabled = Runtime.experiments.isEnabled('objectPrevie ws'); 27 const previewExperimentEnabled = Runtime.experiments.isEnabled('objectPrevie ws');
28 var description = preview.description; 28 var description = preview.description;
29 if (preview.type !== 'object' || preview.subtype === 'null' || (previewExper imentEnabled && isEntry)) { 29 if (preview.type !== 'object' || preview.subtype === 'null' || (previewExper imentEnabled && isEntry)) {
30 parentElement.appendChild(this.renderPropertyPreview(preview.type, preview .subtype, description)); 30 parentElement.appendChild(this.renderPropertyPreview(preview.type, preview .subtype, description));
31 return; 31 return;
32 } 32 }
33 const isArrayOrTypedArray = preview.subtype === 'array' || preview.subtype = == 'typedarray'; 33 const isArrayOrTypedArray = preview.subtype === 'array' || preview.subtype = == 'typedarray';
34 if (description) { 34 if (description) {
35 if (previewExperimentEnabled) { 35 var text;
36 // Hide the description for plain objects and plain arrays. 36 if (isArrayOrTypedArray) {
37 const plainObjectDescription = 'Object'; 37 var arrayLength = SDK.RemoteObject.arrayLength(preview);
38 const size = SDK.RemoteObject.arrayLength(preview) || SDK.RemoteObject.m apOrSetEntriesCount(preview); 38 var arrayLengthText = arrayLength > 1 ? ('(' + arrayLength + ')') : '';
39 var text = preview.subtype === 'typedarray' ? SDK.RemoteObject.arrayName FromDescription(description) : ''; 39 var arrayName = preview.subtype === 'typedarray' ? SDK.RemoteObject.arra yNameFromDescription(description) : '';
40 if (isArrayOrTypedArray) 40 text = arrayName + arrayLengthText;
41 text += size > 1 ? ('(' + size + ')') : ''; 41 } else {
42 else 42 var hideDescription = previewExperimentEnabled && description === 'Objec t';
43 text = description === plainObjectDescription ? '' : description; 43 text = hideDescription ? '' : description;
44 if (text.length > 0)
45 parentElement.createChild('span', 'object-description').textContent = text + ' ';
46 } else if (preview.subtype !== 'array') {
47 parentElement.createTextChildren(description, ' ');
48 } 44 }
45 if (text.length > 0)
46 parentElement.createChild('span', 'object-description').textContent = te xt + ' ';
49 } 47 }
50 48
51 parentElement.createTextChild(isArrayOrTypedArray ? '[' : '{'); 49 parentElement.createTextChild(isArrayOrTypedArray ? '[' : '{');
52 if (preview.entries) 50 if (preview.entries)
53 this._appendEntriesPreview(parentElement, preview); 51 this._appendEntriesPreview(parentElement, preview);
54 else if (isArrayOrTypedArray) 52 else if (isArrayOrTypedArray)
55 this._appendArrayPropertiesPreview(parentElement, preview); 53 this._appendArrayPropertiesPreview(parentElement, preview);
56 else 54 else
57 this._appendObjectPropertiesPreview(parentElement, preview); 55 this._appendObjectPropertiesPreview(parentElement, preview);
58 if (preview.overflow) 56 if (preview.overflow)
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 if (type === 'object' && !subtype) { 239 if (type === 'object' && !subtype) {
242 span.textContent = this._abbreviateFullQualifiedClassName(description); 240 span.textContent = this._abbreviateFullQualifiedClassName(description);
243 span.title = description; 241 span.title = description;
244 return span; 242 return span;
245 } 243 }
246 244
247 span.textContent = description; 245 span.textContent = description;
248 return span; 246 return span;
249 } 247 }
250 }; 248 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698