OLD | NEW |
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 28 matching lines...) Expand all Loading... |
39 var arrayName = preview.subtype === 'typedarray' ? SDK.RemoteObject.arra
yNameFromDescription(description) : ''; | 39 var arrayName = preview.subtype === 'typedarray' ? SDK.RemoteObject.arra
yNameFromDescription(description) : ''; |
40 text = arrayName + arrayLengthText; | 40 text = arrayName + arrayLengthText; |
41 } else { | 41 } else { |
42 var hideDescription = previewExperimentEnabled && description === 'Objec
t'; | 42 var hideDescription = previewExperimentEnabled && description === 'Objec
t'; |
43 text = hideDescription ? '' : description; | 43 text = hideDescription ? '' : description; |
44 } | 44 } |
45 if (text.length > 0) | 45 if (text.length > 0) |
46 parentElement.createChild('span', 'object-description').textContent = te
xt + ' '; | 46 parentElement.createChild('span', 'object-description').textContent = te
xt + ' '; |
47 } | 47 } |
48 | 48 |
49 parentElement.createTextChild(isArrayOrTypedArray ? '[' : '{'); | 49 var propertiesElement = parentElement.createChild('span', 'object-properties
-preview source-code'); |
| 50 propertiesElement.createTextChild(isArrayOrTypedArray ? '[' : '{'); |
50 if (preview.entries) | 51 if (preview.entries) |
51 this._appendEntriesPreview(parentElement, preview); | 52 this._appendEntriesPreview(propertiesElement, preview); |
52 else if (isArrayOrTypedArray) | 53 else if (isArrayOrTypedArray) |
53 this._appendArrayPropertiesPreview(parentElement, preview); | 54 this._appendArrayPropertiesPreview(propertiesElement, preview); |
54 else | 55 else |
55 this._appendObjectPropertiesPreview(parentElement, preview); | 56 this._appendObjectPropertiesPreview(propertiesElement, preview); |
56 if (preview.overflow) | 57 if (preview.overflow) |
57 parentElement.createChild('span').textContent = '\u2026'; | 58 propertiesElement.createChild('span').textContent = '\u2026'; |
58 parentElement.createTextChild(isArrayOrTypedArray ? ']' : '}'); | 59 propertiesElement.createTextChild(isArrayOrTypedArray ? ']' : '}'); |
59 } | 60 } |
60 | 61 |
61 /** | 62 /** |
62 * @param {string} description | 63 * @param {string} description |
63 * @return {string} | 64 * @return {string} |
64 */ | 65 */ |
65 _abbreviateFullQualifiedClassName(description) { | 66 _abbreviateFullQualifiedClassName(description) { |
66 var abbreviatedDescription = description.split('.'); | 67 var abbreviatedDescription = description.split('.'); |
67 for (var i = 0; i < abbreviatedDescription.length - 1; ++i) | 68 for (var i = 0; i < abbreviatedDescription.length - 1; ++i) |
68 abbreviatedDescription[i] = abbreviatedDescription[i].trimMiddle(3); | 69 abbreviatedDescription[i] = abbreviatedDescription[i].trimMiddle(3); |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
215 var span = createElementWithClass('span', 'object-value-' + (subtype || type
)); | 216 var span = createElementWithClass('span', 'object-value-' + (subtype || type
)); |
216 description = description || ''; | 217 description = description || ''; |
217 | 218 |
218 if (type === 'accessor') { | 219 if (type === 'accessor') { |
219 span.textContent = '(...)'; | 220 span.textContent = '(...)'; |
220 span.title = Common.UIString('The property is computed with a getter'); | 221 span.title = Common.UIString('The property is computed with a getter'); |
221 return span; | 222 return span; |
222 } | 223 } |
223 | 224 |
224 if (type === 'function') { | 225 if (type === 'function') { |
225 span.textContent = 'function'; | 226 span.textContent = '\u0192'; |
226 return span; | 227 return span; |
227 } | 228 } |
228 | 229 |
229 if (type === 'object' && subtype === 'node' && description) { | 230 if (type === 'object' && subtype === 'node' && description) { |
230 Components.DOMPresentationUtils.createSpansForNodeTitle(span, description)
; | 231 Components.DOMPresentationUtils.createSpansForNodeTitle(span, description)
; |
231 return span; | 232 return span; |
232 } | 233 } |
233 | 234 |
234 if (type === 'string') { | 235 if (type === 'string') { |
235 span.createTextChildren('"', description.replace(/\n/g, '\u21B5'), '"'); | 236 span.createTextChildren('"', description.replace(/\n/g, '\u21B5'), '"'); |
236 return span; | 237 return span; |
237 } | 238 } |
238 | 239 |
239 if (type === 'object' && !subtype) { | 240 if (type === 'object' && !subtype) { |
240 span.textContent = this._abbreviateFullQualifiedClassName(description); | 241 var preview = this._abbreviateFullQualifiedClassName(description); |
| 242 if (preview === 'Object') |
| 243 preview = '{\u2026}'; |
| 244 span.textContent = preview; |
241 span.title = description; | 245 span.title = description; |
242 return span; | 246 return span; |
243 } | 247 } |
244 | 248 |
245 span.textContent = description; | 249 span.textContent = description; |
246 return span; | 250 return span; |
247 } | 251 } |
248 }; | 252 }; |
OLD | NEW |