| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. | 2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. |
| 3 * Copyright (C) 2009 Joseph Pecoraro | 3 * Copyright (C) 2009 Joseph Pecoraro |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
| 7 * are met: | 7 * are met: |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| 11 * notice, this list of conditions and the following disclaimer in the | 11 * notice, this list of conditions and the following disclaimer in the |
| 12 * documentation and/or other materials provided with the distribution. | 12 * documentation and/or other materials provided with the distribution. |
| 13 * | 13 * |
| 14 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY | 14 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY |
| 15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
| 17 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR | 17 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR |
| 18 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | 18 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
| 19 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | 19 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
| 20 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | 20 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
| 21 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | 21 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
| 22 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 22 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 25 */ | 25 */ |
| 26 | 26 |
| 27 /** | 27 /** |
| 28 * @unrestricted | 28 * @unrestricted |
| 29 */ | 29 */ |
| 30 Components.ObjectPropertiesSection = class extends UI.TreeOutlineInShadow { | 30 ObjectUI.ObjectPropertiesSection = class extends UI.TreeOutlineInShadow { |
| 31 /** | 31 /** |
| 32 * @param {!SDK.RemoteObject} object | 32 * @param {!SDK.RemoteObject} object |
| 33 * @param {?string|!Element=} title | 33 * @param {?string|!Element=} title |
| 34 * @param {!Components.Linkifier=} linkifier | 34 * @param {!Components.Linkifier=} linkifier |
| 35 * @param {?string=} emptyPlaceholder | 35 * @param {?string=} emptyPlaceholder |
| 36 * @param {boolean=} ignoreHasOwnProperty | 36 * @param {boolean=} ignoreHasOwnProperty |
| 37 * @param {!Array.<!SDK.RemoteObjectProperty>=} extraProperties | 37 * @param {!Array.<!SDK.RemoteObjectProperty>=} extraProperties |
| 38 */ | 38 */ |
| 39 constructor(object, title, linkifier, emptyPlaceholder, ignoreHasOwnProperty,
extraProperties) { | 39 constructor(object, title, linkifier, emptyPlaceholder, ignoreHasOwnProperty,
extraProperties) { |
| 40 super(); | 40 super(); |
| 41 this._object = object; | 41 this._object = object; |
| 42 this._editable = true; | 42 this._editable = true; |
| 43 this.hideOverflow(); | 43 this.hideOverflow(); |
| 44 this.setFocusable(false); | 44 this.setFocusable(false); |
| 45 this._objectTreeElement = new Components.ObjectPropertiesSection.RootElement
( | 45 this._objectTreeElement = new ObjectUI.ObjectPropertiesSection.RootElement( |
| 46 object, linkifier, emptyPlaceholder, ignoreHasOwnProperty, extraProperti
es); | 46 object, linkifier, emptyPlaceholder, ignoreHasOwnProperty, extraProperti
es); |
| 47 this.appendChild(this._objectTreeElement); | 47 this.appendChild(this._objectTreeElement); |
| 48 if (typeof title === 'string' || !title) { | 48 if (typeof title === 'string' || !title) { |
| 49 this.titleElement = this.element.createChild('span'); | 49 this.titleElement = this.element.createChild('span'); |
| 50 this.titleElement.textContent = title || ''; | 50 this.titleElement.textContent = title || ''; |
| 51 } else { | 51 } else { |
| 52 this.titleElement = title; | 52 this.titleElement = title; |
| 53 this.element.appendChild(title); | 53 this.element.appendChild(title); |
| 54 } | 54 } |
| 55 | 55 |
| 56 this.element._section = this; | 56 this.element._section = this; |
| 57 this.registerRequiredCSS('components/objectValue.css'); | 57 this.registerRequiredCSS('object_ui/objectValue.css'); |
| 58 this.registerRequiredCSS('components/objectPropertiesSection.css'); | 58 this.registerRequiredCSS('object_ui/objectPropertiesSection.css'); |
| 59 this.rootElement().childrenListElement.classList.add('source-code', 'object-
properties-section'); | 59 this.rootElement().childrenListElement.classList.add('source-code', 'object-
properties-section'); |
| 60 } | 60 } |
| 61 | 61 |
| 62 /** | 62 /** |
| 63 * @param {!SDK.RemoteObject} object | 63 * @param {!SDK.RemoteObject} object |
| 64 * @param {!Components.Linkifier=} linkifier | 64 * @param {!Components.Linkifier=} linkifier |
| 65 * @param {boolean=} skipProto | 65 * @param {boolean=} skipProto |
| 66 * @return {!Element} | 66 * @return {!Element} |
| 67 */ | 67 */ |
| 68 static defaultObjectPresentation(object, linkifier, skipProto) { | 68 static defaultObjectPresentation(object, linkifier, skipProto) { |
| 69 var componentRoot = createElementWithClass('span', 'source-code'); | 69 var componentRoot = createElementWithClass('span', 'source-code'); |
| 70 var shadowRoot = UI.createShadowRootWithCoreStyles(componentRoot, 'component
s/objectValue.css'); | 70 var shadowRoot = UI.createShadowRootWithCoreStyles(componentRoot, 'object_ui
/objectValue.css'); |
| 71 shadowRoot.appendChild( | 71 shadowRoot.appendChild( |
| 72 Components.ObjectPropertiesSection.createValueElement(object, false /* w
asThrown */, true /* showPreview */)); | 72 ObjectUI.ObjectPropertiesSection.createValueElement(object, false /* was
Thrown */, true /* showPreview */)); |
| 73 if (!object.hasChildren) | 73 if (!object.hasChildren) |
| 74 return componentRoot; | 74 return componentRoot; |
| 75 | 75 |
| 76 var objectPropertiesSection = new Components.ObjectPropertiesSection(object,
componentRoot, linkifier); | 76 var objectPropertiesSection = new ObjectUI.ObjectPropertiesSection(object, c
omponentRoot, linkifier); |
| 77 objectPropertiesSection.editable = false; | 77 objectPropertiesSection.editable = false; |
| 78 if (skipProto) | 78 if (skipProto) |
| 79 objectPropertiesSection.skipProto(); | 79 objectPropertiesSection.skipProto(); |
| 80 | 80 |
| 81 return objectPropertiesSection.element; | 81 return objectPropertiesSection.element; |
| 82 } | 82 } |
| 83 | 83 |
| 84 /** | 84 /** |
| 85 * @param {!SDK.RemoteObjectProperty} propertyA | 85 * @param {!SDK.RemoteObjectProperty} propertyA |
| 86 * @param {!SDK.RemoteObjectProperty} propertyB | 86 * @param {!SDK.RemoteObjectProperty} propertyB |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 210 /** | 210 /** |
| 211 * @param {!SDK.RemoteObject} value | 211 * @param {!SDK.RemoteObject} value |
| 212 * @param {boolean} wasThrown | 212 * @param {boolean} wasThrown |
| 213 * @param {boolean} showPreview | 213 * @param {boolean} showPreview |
| 214 * @param {!Element=} parentElement | 214 * @param {!Element=} parentElement |
| 215 * @param {!Components.Linkifier=} linkifier | 215 * @param {!Components.Linkifier=} linkifier |
| 216 * @return {!Element} | 216 * @return {!Element} |
| 217 */ | 217 */ |
| 218 static createValueElementWithCustomSupport(value, wasThrown, showPreview, pare
ntElement, linkifier) { | 218 static createValueElementWithCustomSupport(value, wasThrown, showPreview, pare
ntElement, linkifier) { |
| 219 if (value.customPreview()) { | 219 if (value.customPreview()) { |
| 220 var result = (new Components.CustomPreviewComponent(value)).element; | 220 var result = (new ObjectUI.CustomPreviewComponent(value)).element; |
| 221 result.classList.add('object-properties-section-custom-section'); | 221 result.classList.add('object-properties-section-custom-section'); |
| 222 return result; | 222 return result; |
| 223 } | 223 } |
| 224 return Components.ObjectPropertiesSection.createValueElement( | 224 return ObjectUI.ObjectPropertiesSection.createValueElement(value, wasThrown,
showPreview, parentElement, linkifier); |
| 225 value, wasThrown, showPreview, parentElement, linkifier); | |
| 226 } | 225 } |
| 227 | 226 |
| 228 /** | 227 /** |
| 229 * @param {!SDK.RemoteObject} value | 228 * @param {!SDK.RemoteObject} value |
| 230 * @param {boolean} wasThrown | 229 * @param {boolean} wasThrown |
| 231 * @param {boolean} showPreview | 230 * @param {boolean} showPreview |
| 232 * @param {!Element=} parentElement | 231 * @param {!Element=} parentElement |
| 233 * @param {!Components.Linkifier=} linkifier | 232 * @param {!Components.Linkifier=} linkifier |
| 234 * @return {!Element} | 233 * @return {!Element} |
| 235 */ | 234 */ |
| 236 static createValueElement(value, wasThrown, showPreview, parentElement, linkif
ier) { | 235 static createValueElement(value, wasThrown, showPreview, parentElement, linkif
ier) { |
| 237 var valueElement; | 236 var valueElement; |
| 238 var type = value.type; | 237 var type = value.type; |
| 239 var subtype = value.subtype; | 238 var subtype = value.subtype; |
| 240 var description = value.description; | 239 var description = value.description; |
| 241 if (type === 'object' && subtype === 'internal#location') { | 240 if (type === 'object' && subtype === 'internal#location') { |
| 242 var rawLocation = value.debuggerModel().createRawLocationByScriptId( | 241 var rawLocation = value.debuggerModel().createRawLocationByScriptId( |
| 243 value.value.scriptId, value.value.lineNumber, value.value.columnNumber
); | 242 value.value.scriptId, value.value.lineNumber, value.value.columnNumber
); |
| 244 if (rawLocation && linkifier) | 243 if (rawLocation && linkifier) |
| 245 return linkifier.linkifyRawLocation(rawLocation, ''); | 244 return linkifier.linkifyRawLocation(rawLocation, ''); |
| 246 valueElement = createUnknownInternalLocationElement(); | 245 valueElement = createUnknownInternalLocationElement(); |
| 247 } else if (type === 'string' && typeof description === 'string') { | 246 } else if (type === 'string' && typeof description === 'string') { |
| 248 valueElement = createStringElement(); | 247 valueElement = createStringElement(); |
| 249 } else if (type === 'function') { | 248 } else if (type === 'function') { |
| 250 valueElement = Components.ObjectPropertiesSection.valueElementForFunctionD
escription(description); | 249 valueElement = ObjectUI.ObjectPropertiesSection.valueElementForFunctionDes
cription(description); |
| 251 } else if (type === 'object' && subtype === 'node' && description) { | 250 } else if (type === 'object' && subtype === 'node' && description) { |
| 252 valueElement = createNodeElement(); | 251 valueElement = createNodeElement(); |
| 253 } else if (type === 'number' && description && description.indexOf('e') !==
-1) { | 252 } else if (type === 'number' && description && description.indexOf('e') !==
-1) { |
| 254 valueElement = createNumberWithExponentElement(); | 253 valueElement = createNumberWithExponentElement(); |
| 255 if (parentElement) // FIXME: do it in the caller. | 254 if (parentElement) // FIXME: do it in the caller. |
| 256 parentElement.classList.add('hbox'); | 255 parentElement.classList.add('hbox'); |
| 257 } else { | 256 } else { |
| 258 valueElement = createElementWithClass('span', 'object-value-' + (subtype |
| type)); | 257 valueElement = createElementWithClass('span', 'object-value-' + (subtype |
| type)); |
| 259 valueElement.title = description || ''; | 258 valueElement.title = description || ''; |
| 260 if (Runtime.experiments.isEnabled('objectPreviews') && value.preview && sh
owPreview) { | 259 if (Runtime.experiments.isEnabled('objectPreviews') && value.preview && sh
owPreview) { |
| 261 var previewFormatter = new Components.RemoteObjectPreviewFormatter(); | 260 var previewFormatter = new ObjectUI.RemoteObjectPreviewFormatter(); |
| 262 previewFormatter.appendObjectPreview(valueElement, value.preview, false
/* isEntry */); | 261 previewFormatter.appendObjectPreview(valueElement, value.preview, false
/* isEntry */); |
| 263 } else { | 262 } else { |
| 264 valueElement.setTextContentTruncatedIfNeeded(description); | 263 valueElement.setTextContentTruncatedIfNeeded(description); |
| 265 } | 264 } |
| 266 } | 265 } |
| 267 | 266 |
| 268 if (wasThrown) { | 267 if (wasThrown) { |
| 269 var wrapperElement = createElementWithClass('span', 'error value'); | 268 var wrapperElement = createElementWithClass('span', 'error value'); |
| 270 wrapperElement.createTextChild('[' + Common.UIString('Exception') + ': '); | 269 wrapperElement.createTextChild('[' + Common.UIString('Exception') + ': '); |
| 271 wrapperElement.appendChild(valueElement); | 270 wrapperElement.appendChild(valueElement); |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 341 function didGetDetails(response) { | 340 function didGetDetails(response) { |
| 342 if (linkify && response && response.location) { | 341 if (linkify && response && response.location) { |
| 343 element.classList.add('linkified'); | 342 element.classList.add('linkified'); |
| 344 element.addEventListener('click', () => Common.Revealer.reveal(response.
location)); | 343 element.addEventListener('click', () => Common.Revealer.reveal(response.
location)); |
| 345 } | 344 } |
| 346 | 345 |
| 347 // The includePreview flag is false for formats such as console.dir(). | 346 // The includePreview flag is false for formats such as console.dir(). |
| 348 var defaultName = includePreview ? '' : 'anonymous'; | 347 var defaultName = includePreview ? '' : 'anonymous'; |
| 349 if (response && response.functionName) | 348 if (response && response.functionName) |
| 350 defaultName = response.functionName; | 349 defaultName = response.functionName; |
| 351 var valueElement = Components.ObjectPropertiesSection.valueElementForFunct
ionDescription( | 350 var valueElement = ObjectUI.ObjectPropertiesSection.valueElementForFunctio
nDescription( |
| 352 func.description, includePreview, defaultName); | 351 func.description, includePreview, defaultName); |
| 353 element.appendChild(valueElement); | 352 element.appendChild(valueElement); |
| 354 } | 353 } |
| 355 } | 354 } |
| 356 | 355 |
| 357 skipProto() { | 356 skipProto() { |
| 358 this._skipProto = true; | 357 this._skipProto = true; |
| 359 } | 358 } |
| 360 | 359 |
| 361 expand() { | 360 expand() { |
| (...skipping 25 matching lines...) Expand all Loading... |
| 387 } | 386 } |
| 388 | 387 |
| 389 titleLessMode() { | 388 titleLessMode() { |
| 390 this._objectTreeElement.listItemElement.classList.add('hidden'); | 389 this._objectTreeElement.listItemElement.classList.add('hidden'); |
| 391 this._objectTreeElement.childrenListElement.classList.add('title-less-mode')
; | 390 this._objectTreeElement.childrenListElement.classList.add('title-less-mode')
; |
| 392 this._objectTreeElement.expand(); | 391 this._objectTreeElement.expand(); |
| 393 } | 392 } |
| 394 }; | 393 }; |
| 395 | 394 |
| 396 /** @const */ | 395 /** @const */ |
| 397 Components.ObjectPropertiesSection._arrayLoadThreshold = 100; | 396 ObjectUI.ObjectPropertiesSection._arrayLoadThreshold = 100; |
| 398 | 397 |
| 399 | 398 |
| 400 /** | 399 /** |
| 401 * @unrestricted | 400 * @unrestricted |
| 402 */ | 401 */ |
| 403 Components.ObjectPropertiesSection.RootElement = class extends UI.TreeElement { | 402 ObjectUI.ObjectPropertiesSection.RootElement = class extends UI.TreeElement { |
| 404 /** | 403 /** |
| 405 * @param {!SDK.RemoteObject} object | 404 * @param {!SDK.RemoteObject} object |
| 406 * @param {!Components.Linkifier=} linkifier | 405 * @param {!Components.Linkifier=} linkifier |
| 407 * @param {?string=} emptyPlaceholder | 406 * @param {?string=} emptyPlaceholder |
| 408 * @param {boolean=} ignoreHasOwnProperty | 407 * @param {boolean=} ignoreHasOwnProperty |
| 409 * @param {!Array.<!SDK.RemoteObjectProperty>=} extraProperties | 408 * @param {!Array.<!SDK.RemoteObjectProperty>=} extraProperties |
| 410 */ | 409 */ |
| 411 constructor(object, linkifier, emptyPlaceholder, ignoreHasOwnProperty, extraPr
operties) { | 410 constructor(object, linkifier, emptyPlaceholder, ignoreHasOwnProperty, extraPr
operties) { |
| 412 var contentElement = createElement('content'); | 411 var contentElement = createElement('content'); |
| 413 super(contentElement); | 412 super(contentElement); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 446 * @return {boolean} | 445 * @return {boolean} |
| 447 */ | 446 */ |
| 448 ondblclick(e) { | 447 ondblclick(e) { |
| 449 return true; | 448 return true; |
| 450 } | 449 } |
| 451 | 450 |
| 452 /** | 451 /** |
| 453 * @override | 452 * @override |
| 454 */ | 453 */ |
| 455 onpopulate() { | 454 onpopulate() { |
| 456 Components.ObjectPropertyTreeElement._populate( | 455 ObjectUI.ObjectPropertyTreeElement._populate( |
| 457 this, this._object, !!this.treeOutline._skipProto, this._linkifier, this
._emptyPlaceholder, | 456 this, this._object, !!this.treeOutline._skipProto, this._linkifier, this
._emptyPlaceholder, |
| 458 this._ignoreHasOwnProperty, this._extraProperties); | 457 this._ignoreHasOwnProperty, this._extraProperties); |
| 459 } | 458 } |
| 460 }; | 459 }; |
| 461 | 460 |
| 462 /** | 461 /** |
| 463 * @unrestricted | 462 * @unrestricted |
| 464 */ | 463 */ |
| 465 Components.ObjectPropertyTreeElement = class extends UI.TreeElement { | 464 ObjectUI.ObjectPropertyTreeElement = class extends UI.TreeElement { |
| 466 /** | 465 /** |
| 467 * @param {!SDK.RemoteObjectProperty} property | 466 * @param {!SDK.RemoteObjectProperty} property |
| 468 * @param {!Components.Linkifier=} linkifier | 467 * @param {!Components.Linkifier=} linkifier |
| 469 */ | 468 */ |
| 470 constructor(property, linkifier) { | 469 constructor(property, linkifier) { |
| 471 // Pass an empty title, the title gets made later in onattach. | 470 // Pass an empty title, the title gets made later in onattach. |
| 472 super(); | 471 super(); |
| 473 | 472 |
| 474 this.property = property; | 473 this.property = property; |
| 475 this.toggleOnClick = true; | 474 this.toggleOnClick = true; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 491 */ | 490 */ |
| 492 static _populate( | 491 static _populate( |
| 493 treeElement, | 492 treeElement, |
| 494 value, | 493 value, |
| 495 skipProto, | 494 skipProto, |
| 496 linkifier, | 495 linkifier, |
| 497 emptyPlaceholder, | 496 emptyPlaceholder, |
| 498 flattenProtoChain, | 497 flattenProtoChain, |
| 499 extraProperties, | 498 extraProperties, |
| 500 targetValue) { | 499 targetValue) { |
| 501 if (value.arrayLength() > Components.ObjectPropertiesSection._arrayLoadThres
hold) { | 500 if (value.arrayLength() > ObjectUI.ObjectPropertiesSection._arrayLoadThresho
ld) { |
| 502 treeElement.removeChildren(); | 501 treeElement.removeChildren(); |
| 503 Components.ArrayGroupingTreeElement._populateArray(treeElement, value, 0,
value.arrayLength() - 1, linkifier); | 502 ObjectUI.ArrayGroupingTreeElement._populateArray(treeElement, value, 0, va
lue.arrayLength() - 1, linkifier); |
| 504 return; | 503 return; |
| 505 } | 504 } |
| 506 | 505 |
| 507 /** | 506 /** |
| 508 * @param {?Array.<!SDK.RemoteObjectProperty>} properties | 507 * @param {?Array.<!SDK.RemoteObjectProperty>} properties |
| 509 * @param {?Array.<!SDK.RemoteObjectProperty>} internalProperties | 508 * @param {?Array.<!SDK.RemoteObjectProperty>} internalProperties |
| 510 */ | 509 */ |
| 511 function callback(properties, internalProperties) { | 510 function callback(properties, internalProperties) { |
| 512 treeElement.removeChildren(); | 511 treeElement.removeChildren(); |
| 513 if (!properties) | 512 if (!properties) |
| 514 return; | 513 return; |
| 515 | 514 |
| 516 extraProperties = extraProperties || []; | 515 extraProperties = extraProperties || []; |
| 517 for (var i = 0; i < extraProperties.length; ++i) | 516 for (var i = 0; i < extraProperties.length; ++i) |
| 518 properties.push(extraProperties[i]); | 517 properties.push(extraProperties[i]); |
| 519 | 518 |
| 520 Components.ObjectPropertyTreeElement.populateWithProperties( | 519 ObjectUI.ObjectPropertyTreeElement.populateWithProperties( |
| 521 treeElement, properties, internalProperties, skipProto, targetValue ||
value, linkifier, emptyPlaceholder); | 520 treeElement, properties, internalProperties, skipProto, targetValue ||
value, linkifier, emptyPlaceholder); |
| 522 } | 521 } |
| 523 | 522 |
| 524 var generatePreview = Runtime.experiments.isEnabled('objectPreviews'); | 523 var generatePreview = Runtime.experiments.isEnabled('objectPreviews'); |
| 525 if (flattenProtoChain) | 524 if (flattenProtoChain) |
| 526 value.getAllProperties(false, generatePreview, callback); | 525 value.getAllProperties(false, generatePreview, callback); |
| 527 else | 526 else |
| 528 SDK.RemoteObject.loadFromObjectPerProto(value, generatePreview, callback); | 527 SDK.RemoteObject.loadFromObjectPerProto(value, generatePreview, callback); |
| 529 } | 528 } |
| 530 | 529 |
| 531 /** | 530 /** |
| 532 * @param {!UI.TreeElement} treeNode | 531 * @param {!UI.TreeElement} treeNode |
| 533 * @param {!Array.<!SDK.RemoteObjectProperty>} properties | 532 * @param {!Array.<!SDK.RemoteObjectProperty>} properties |
| 534 * @param {?Array.<!SDK.RemoteObjectProperty>} internalProperties | 533 * @param {?Array.<!SDK.RemoteObjectProperty>} internalProperties |
| 535 * @param {boolean} skipProto | 534 * @param {boolean} skipProto |
| 536 * @param {?SDK.RemoteObject} value | 535 * @param {?SDK.RemoteObject} value |
| 537 * @param {!Components.Linkifier=} linkifier | 536 * @param {!Components.Linkifier=} linkifier |
| 538 * @param {?string=} emptyPlaceholder | 537 * @param {?string=} emptyPlaceholder |
| 539 */ | 538 */ |
| 540 static populateWithProperties( | 539 static populateWithProperties( |
| 541 treeNode, | 540 treeNode, |
| 542 properties, | 541 properties, |
| 543 internalProperties, | 542 internalProperties, |
| 544 skipProto, | 543 skipProto, |
| 545 value, | 544 value, |
| 546 linkifier, | 545 linkifier, |
| 547 emptyPlaceholder) { | 546 emptyPlaceholder) { |
| 548 properties.sort(Components.ObjectPropertiesSection.CompareProperties); | 547 properties.sort(ObjectUI.ObjectPropertiesSection.CompareProperties); |
| 549 | 548 |
| 550 var tailProperties = []; | 549 var tailProperties = []; |
| 551 var protoProperty = null; | 550 var protoProperty = null; |
| 552 for (var i = 0; i < properties.length; ++i) { | 551 for (var i = 0; i < properties.length; ++i) { |
| 553 var property = properties[i]; | 552 var property = properties[i]; |
| 554 property.parentObject = value; | 553 property.parentObject = value; |
| 555 if (property.name === '__proto__' && !property.isAccessorProperty()) { | 554 if (property.name === '__proto__' && !property.isAccessorProperty()) { |
| 556 protoProperty = property; | 555 protoProperty = property; |
| 557 continue; | 556 continue; |
| 558 } | 557 } |
| 559 | 558 |
| 560 if (property.isOwn && property.getter) { | 559 if (property.isOwn && property.getter) { |
| 561 var getterProperty = new SDK.RemoteObjectProperty('get ' + property.name
, property.getter, false); | 560 var getterProperty = new SDK.RemoteObjectProperty('get ' + property.name
, property.getter, false); |
| 562 getterProperty.parentObject = value; | 561 getterProperty.parentObject = value; |
| 563 tailProperties.push(getterProperty); | 562 tailProperties.push(getterProperty); |
| 564 } | 563 } |
| 565 if (property.isOwn && property.setter) { | 564 if (property.isOwn && property.setter) { |
| 566 var setterProperty = new SDK.RemoteObjectProperty('set ' + property.name
, property.setter, false); | 565 var setterProperty = new SDK.RemoteObjectProperty('set ' + property.name
, property.setter, false); |
| 567 setterProperty.parentObject = value; | 566 setterProperty.parentObject = value; |
| 568 tailProperties.push(setterProperty); | 567 tailProperties.push(setterProperty); |
| 569 } | 568 } |
| 570 var canShowProperty = property.getter || !property.isAccessorProperty(); | 569 var canShowProperty = property.getter || !property.isAccessorProperty(); |
| 571 if (canShowProperty && property.name !== '__proto__') | 570 if (canShowProperty && property.name !== '__proto__') |
| 572 treeNode.appendChild(new Components.ObjectPropertyTreeElement(property,
linkifier)); | 571 treeNode.appendChild(new ObjectUI.ObjectPropertyTreeElement(property, li
nkifier)); |
| 573 } | 572 } |
| 574 for (var i = 0; i < tailProperties.length; ++i) | 573 for (var i = 0; i < tailProperties.length; ++i) |
| 575 treeNode.appendChild(new Components.ObjectPropertyTreeElement(tailProperti
es[i], linkifier)); | 574 treeNode.appendChild(new ObjectUI.ObjectPropertyTreeElement(tailProperties
[i], linkifier)); |
| 576 if (!skipProto && protoProperty) | 575 if (!skipProto && protoProperty) |
| 577 treeNode.appendChild(new Components.ObjectPropertyTreeElement(protoPropert
y, linkifier)); | 576 treeNode.appendChild(new ObjectUI.ObjectPropertyTreeElement(protoProperty,
linkifier)); |
| 578 | 577 |
| 579 if (internalProperties) { | 578 if (internalProperties) { |
| 580 for (var i = 0; i < internalProperties.length; i++) { | 579 for (var i = 0; i < internalProperties.length; i++) { |
| 581 internalProperties[i].parentObject = value; | 580 internalProperties[i].parentObject = value; |
| 582 var treeElement = new Components.ObjectPropertyTreeElement(internalPrope
rties[i], linkifier); | 581 var treeElement = new ObjectUI.ObjectPropertyTreeElement(internalPropert
ies[i], linkifier); |
| 583 if (internalProperties[i].name === '[[Entries]]') { | 582 if (internalProperties[i].name === '[[Entries]]') { |
| 584 treeElement.setExpandable(true); | 583 treeElement.setExpandable(true); |
| 585 treeElement.expand(); | 584 treeElement.expand(); |
| 586 } | 585 } |
| 587 treeNode.appendChild(treeElement); | 586 treeNode.appendChild(treeElement); |
| 588 } | 587 } |
| 589 } | 588 } |
| 590 | 589 |
| 591 Components.ObjectPropertyTreeElement._appendEmptyPlaceholderIfNeeded(treeNod
e, emptyPlaceholder); | 590 ObjectUI.ObjectPropertyTreeElement._appendEmptyPlaceholderIfNeeded(treeNode,
emptyPlaceholder); |
| 592 } | 591 } |
| 593 | 592 |
| 594 /** | 593 /** |
| 595 * @param {!UI.TreeElement} treeNode | 594 * @param {!UI.TreeElement} treeNode |
| 596 * @param {?string=} emptyPlaceholder | 595 * @param {?string=} emptyPlaceholder |
| 597 */ | 596 */ |
| 598 static _appendEmptyPlaceholderIfNeeded(treeNode, emptyPlaceholder) { | 597 static _appendEmptyPlaceholderIfNeeded(treeNode, emptyPlaceholder) { |
| 599 if (treeNode.childCount()) | 598 if (treeNode.childCount()) |
| 600 return; | 599 return; |
| 601 var title = createElementWithClass('div', 'gray-info-message'); | 600 var title = createElementWithClass('div', 'gray-info-message'); |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 671 } | 670 } |
| 672 | 671 |
| 673 /** | 672 /** |
| 674 * @override | 673 * @override |
| 675 */ | 674 */ |
| 676 onpopulate() { | 675 onpopulate() { |
| 677 var propertyValue = /** @type {!SDK.RemoteObject} */ (this.property.value); | 676 var propertyValue = /** @type {!SDK.RemoteObject} */ (this.property.value); |
| 678 console.assert(propertyValue); | 677 console.assert(propertyValue); |
| 679 var skipProto = this.treeOutline ? this.treeOutline._skipProto : true; | 678 var skipProto = this.treeOutline ? this.treeOutline._skipProto : true; |
| 680 var targetValue = this.property.name !== '__proto__' ? propertyValue : this.
property.parentObject; | 679 var targetValue = this.property.name !== '__proto__' ? propertyValue : this.
property.parentObject; |
| 681 Components.ObjectPropertyTreeElement._populate( | 680 ObjectUI.ObjectPropertyTreeElement._populate( |
| 682 this, propertyValue, skipProto, this._linkifier, undefined, undefined, u
ndefined, targetValue); | 681 this, propertyValue, skipProto, this._linkifier, undefined, undefined, u
ndefined, targetValue); |
| 683 } | 682 } |
| 684 | 683 |
| 685 /** | 684 /** |
| 686 * @override | 685 * @override |
| 687 * @return {boolean} | 686 * @return {boolean} |
| 688 */ | 687 */ |
| 689 ondblclick(event) { | 688 ondblclick(event) { |
| 690 var inEditableElement = event.target.isSelfOrDescendant(this.valueElement) |
| | 689 var inEditableElement = event.target.isSelfOrDescendant(this.valueElement) |
| |
| 691 (this.expandedValueElement && event.target.isSelfOrDescendant(this.expan
dedValueElement)); | 690 (this.expandedValueElement && event.target.isSelfOrDescendant(this.expan
dedValueElement)); |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 739 return null; | 738 return null; |
| 740 | 739 |
| 741 var valueElement = createElementWithClass('span', 'value'); | 740 var valueElement = createElementWithClass('span', 'value'); |
| 742 valueElement.setTextContentTruncatedIfNeeded(value.description || ''); | 741 valueElement.setTextContentTruncatedIfNeeded(value.description || ''); |
| 743 valueElement.classList.add('object-value-' + (value.subtype || value.type)); | 742 valueElement.classList.add('object-value-' + (value.subtype || value.type)); |
| 744 valueElement.title = value.description || ''; | 743 valueElement.title = value.description || ''; |
| 745 return valueElement; | 744 return valueElement; |
| 746 } | 745 } |
| 747 | 746 |
| 748 update() { | 747 update() { |
| 749 this.nameElement = Components.ObjectPropertiesSection.createNameElement(this
.property.name); | 748 this.nameElement = ObjectUI.ObjectPropertiesSection.createNameElement(this.p
roperty.name); |
| 750 if (!this.property.enumerable) | 749 if (!this.property.enumerable) |
| 751 this.nameElement.classList.add('object-properties-section-dimmed'); | 750 this.nameElement.classList.add('object-properties-section-dimmed'); |
| 752 if (this.property.synthetic) | 751 if (this.property.synthetic) |
| 753 this.nameElement.classList.add('synthetic-property'); | 752 this.nameElement.classList.add('synthetic-property'); |
| 754 | 753 |
| 755 this._updatePropertyPath(); | 754 this._updatePropertyPath(); |
| 756 this.nameElement.addEventListener('contextmenu', this._contextMenuFired.bind
(this, this.property), false); | 755 this.nameElement.addEventListener('contextmenu', this._contextMenuFired.bind
(this, this.property), false); |
| 757 | 756 |
| 758 var separatorElement = createElementWithClass('span', 'object-properties-sec
tion-separator'); | 757 var separatorElement = createElementWithClass('span', 'object-properties-sec
tion-separator'); |
| 759 separatorElement.textContent = ': '; | 758 separatorElement.textContent = ': '; |
| 760 | 759 |
| 761 if (this.property.value) { | 760 if (this.property.value) { |
| 762 var showPreview = this.property.name !== '__proto__'; | 761 var showPreview = this.property.name !== '__proto__'; |
| 763 this.valueElement = Components.ObjectPropertiesSection.createValueElementW
ithCustomSupport( | 762 this.valueElement = ObjectUI.ObjectPropertiesSection.createValueElementWit
hCustomSupport( |
| 764 this.property.value, this.property.wasThrown, showPreview, this.listIt
emElement, this._linkifier); | 763 this.property.value, this.property.wasThrown, showPreview, this.listIt
emElement, this._linkifier); |
| 765 this.valueElement.addEventListener('contextmenu', this._contextMenuFired.b
ind(this, this.property), false); | 764 this.valueElement.addEventListener('contextmenu', this._contextMenuFired.b
ind(this, this.property), false); |
| 766 } else if (this.property.getter) { | 765 } else if (this.property.getter) { |
| 767 this.valueElement = Components.ObjectPropertyTreeElement.createRemoteObjec
tAccessorPropertySpan( | 766 this.valueElement = ObjectUI.ObjectPropertyTreeElement.createRemoteObjectA
ccessorPropertySpan( |
| 768 this.property.parentObject, [this.property.name], this._onInvokeGetter
Click.bind(this)); | 767 this.property.parentObject, [this.property.name], this._onInvokeGetter
Click.bind(this)); |
| 769 } else { | 768 } else { |
| 770 this.valueElement = createElementWithClass('span', 'object-value-undefined
'); | 769 this.valueElement = createElementWithClass('span', 'object-value-undefined
'); |
| 771 this.valueElement.textContent = Common.UIString('<unreadable>'); | 770 this.valueElement.textContent = Common.UIString('<unreadable>'); |
| 772 this.valueElement.title = Common.UIString('No property getter'); | 771 this.valueElement.title = Common.UIString('No property getter'); |
| 773 } | 772 } |
| 774 | 773 |
| 775 var valueText = this.valueElement.textContent; | 774 var valueText = this.valueElement.textContent; |
| 776 if (this.property.value && valueText && !this.property.wasThrown) | 775 if (this.property.value && valueText && !this.property.wasThrown) |
| 777 this.expandedValueElement = this._createExpandedValueElement(this.property
.value); | 776 this.expandedValueElement = this._createExpandedValueElement(this.property
.value); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 824 text = '"' + text + '"'; | 823 text = '"' + text + '"'; |
| 825 | 824 |
| 826 this._editableDiv.setTextContentTruncatedIfNeeded(text, Common.UIString('<st
ring is too large to edit>')); | 825 this._editableDiv.setTextContentTruncatedIfNeeded(text, Common.UIString('<st
ring is too large to edit>')); |
| 827 var originalContent = this._editableDiv.textContent; | 826 var originalContent = this._editableDiv.textContent; |
| 828 | 827 |
| 829 // Lie about our children to prevent expanding on double click and to collap
se subproperties. | 828 // Lie about our children to prevent expanding on double click and to collap
se subproperties. |
| 830 this.setExpandable(false); | 829 this.setExpandable(false); |
| 831 this.listItemElement.classList.add('editing-sub-part'); | 830 this.listItemElement.classList.add('editing-sub-part'); |
| 832 this.valueElement.classList.add('hidden'); | 831 this.valueElement.classList.add('hidden'); |
| 833 | 832 |
| 834 this._prompt = new Components.ObjectPropertyPrompt(); | 833 this._prompt = new ObjectUI.ObjectPropertyPrompt(); |
| 835 | 834 |
| 836 var proxyElement = | 835 var proxyElement = |
| 837 this._prompt.attachAndStartEditing(this._editableDiv, this._editingCommi
tted.bind(this, originalContent)); | 836 this._prompt.attachAndStartEditing(this._editableDiv, this._editingCommi
tted.bind(this, originalContent)); |
| 838 this.listItemElement.getComponentSelection().selectAllChildren(this._editabl
eDiv); | 837 this.listItemElement.getComponentSelection().selectAllChildren(this._editabl
eDiv); |
| 839 proxyElement.addEventListener('keydown', this._promptKeyDown.bind(this, orig
inalContent), false); | 838 proxyElement.addEventListener('keydown', this._promptKeyDown.bind(this, orig
inalContent), false); |
| 840 } | 839 } |
| 841 | 840 |
| 842 _editingEnded() { | 841 _editingEnded() { |
| 843 this._prompt.detach(); | 842 this._prompt.detach(); |
| 844 delete this._prompt; | 843 delete this._prompt; |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 890 _applyExpression(expression) { | 889 _applyExpression(expression) { |
| 891 var property = SDK.RemoteObject.toCallArgument(this.property.symbol || this.
property.name); | 890 var property = SDK.RemoteObject.toCallArgument(this.property.symbol || this.
property.name); |
| 892 expression = expression.trim(); | 891 expression = expression.trim(); |
| 893 if (expression) | 892 if (expression) |
| 894 this.property.parentObject.setPropertyValue(property, expression, callback
.bind(this)); | 893 this.property.parentObject.setPropertyValue(property, expression, callback
.bind(this)); |
| 895 else | 894 else |
| 896 this.property.parentObject.deleteProperty(property, callback.bind(this)); | 895 this.property.parentObject.deleteProperty(property, callback.bind(this)); |
| 897 | 896 |
| 898 /** | 897 /** |
| 899 * @param {?Protocol.Error} error | 898 * @param {?Protocol.Error} error |
| 900 * @this {Components.ObjectPropertyTreeElement} | 899 * @this {ObjectUI.ObjectPropertyTreeElement} |
| 901 */ | 900 */ |
| 902 function callback(error) { | 901 function callback(error) { |
| 903 if (error) { | 902 if (error) { |
| 904 this.update(); | 903 this.update(); |
| 905 return; | 904 return; |
| 906 } | 905 } |
| 907 | 906 |
| 908 if (!expression) { | 907 if (!expression) { |
| 909 // The property was deleted, so remove this tree element. | 908 // The property was deleted, so remove this tree element. |
| 910 this.parent.removeChild(this); | 909 this.parent.removeChild(this); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 939 } else { | 938 } else { |
| 940 this.setExpandable(false); | 939 this.setExpandable(false); |
| 941 } | 940 } |
| 942 } | 941 } |
| 943 }; | 942 }; |
| 944 | 943 |
| 945 | 944 |
| 946 /** | 945 /** |
| 947 * @unrestricted | 946 * @unrestricted |
| 948 */ | 947 */ |
| 949 Components.ArrayGroupingTreeElement = class extends UI.TreeElement { | 948 ObjectUI.ArrayGroupingTreeElement = class extends UI.TreeElement { |
| 950 /** | 949 /** |
| 951 * @param {!SDK.RemoteObject} object | 950 * @param {!SDK.RemoteObject} object |
| 952 * @param {number} fromIndex | 951 * @param {number} fromIndex |
| 953 * @param {number} toIndex | 952 * @param {number} toIndex |
| 954 * @param {number} propertyCount | 953 * @param {number} propertyCount |
| 955 * @param {!Components.Linkifier=} linkifier | 954 * @param {!Components.Linkifier=} linkifier |
| 956 */ | 955 */ |
| 957 constructor(object, fromIndex, toIndex, propertyCount, linkifier) { | 956 constructor(object, fromIndex, toIndex, propertyCount, linkifier) { |
| 958 super(String.sprintf('[%d \u2026 %d]', fromIndex, toIndex), true); | 957 super(String.sprintf('[%d \u2026 %d]', fromIndex, toIndex), true); |
| 959 this.toggleOnClick = true; | 958 this.toggleOnClick = true; |
| 960 this.selectable = false; | 959 this.selectable = false; |
| 961 this._fromIndex = fromIndex; | 960 this._fromIndex = fromIndex; |
| 962 this._toIndex = toIndex; | 961 this._toIndex = toIndex; |
| 963 this._object = object; | 962 this._object = object; |
| 964 this._readOnly = true; | 963 this._readOnly = true; |
| 965 this._propertyCount = propertyCount; | 964 this._propertyCount = propertyCount; |
| 966 this._linkifier = linkifier; | 965 this._linkifier = linkifier; |
| 967 } | 966 } |
| 968 | 967 |
| 969 /** | 968 /** |
| 970 * @param {!UI.TreeElement} treeNode | 969 * @param {!UI.TreeElement} treeNode |
| 971 * @param {!SDK.RemoteObject} object | 970 * @param {!SDK.RemoteObject} object |
| 972 * @param {number} fromIndex | 971 * @param {number} fromIndex |
| 973 * @param {number} toIndex | 972 * @param {number} toIndex |
| 974 * @param {!Components.Linkifier=} linkifier | 973 * @param {!Components.Linkifier=} linkifier |
| 975 */ | 974 */ |
| 976 static _populateArray(treeNode, object, fromIndex, toIndex, linkifier) { | 975 static _populateArray(treeNode, object, fromIndex, toIndex, linkifier) { |
| 977 Components.ArrayGroupingTreeElement._populateRanges(treeNode, object, fromIn
dex, toIndex, true, linkifier); | 976 ObjectUI.ArrayGroupingTreeElement._populateRanges(treeNode, object, fromInde
x, toIndex, true, linkifier); |
| 978 } | 977 } |
| 979 | 978 |
| 980 /** | 979 /** |
| 981 * @param {!UI.TreeElement} treeNode | 980 * @param {!UI.TreeElement} treeNode |
| 982 * @param {!SDK.RemoteObject} object | 981 * @param {!SDK.RemoteObject} object |
| 983 * @param {number} fromIndex | 982 * @param {number} fromIndex |
| 984 * @param {number} toIndex | 983 * @param {number} toIndex |
| 985 * @param {boolean} topLevel | 984 * @param {boolean} topLevel |
| 986 * @param {!Components.Linkifier=} linkifier | 985 * @param {!Components.Linkifier=} linkifier |
| 987 * @this {Components.ArrayGroupingTreeElement} | 986 * @this {ObjectUI.ArrayGroupingTreeElement} |
| 988 */ | 987 */ |
| 989 static _populateRanges(treeNode, object, fromIndex, toIndex, topLevel, linkifi
er) { | 988 static _populateRanges(treeNode, object, fromIndex, toIndex, topLevel, linkifi
er) { |
| 990 object.callFunctionJSON( | 989 object.callFunctionJSON( |
| 991 packRanges, | 990 packRanges, |
| 992 [ | 991 [ |
| 993 {value: fromIndex}, {value: toIndex}, {value: Components.ArrayGrouping
TreeElement._bucketThreshold}, | 992 {value: fromIndex}, {value: toIndex}, {value: ObjectUI.ArrayGroupingTr
eeElement._bucketThreshold}, |
| 994 {value: Components.ArrayGroupingTreeElement._sparseIterationThreshold}
, | 993 {value: ObjectUI.ArrayGroupingTreeElement._sparseIterationThreshold}, |
| 995 {value: Components.ArrayGroupingTreeElement._getOwnPropertyNamesThresh
old} | 994 {value: ObjectUI.ArrayGroupingTreeElement._getOwnPropertyNamesThreshol
d} |
| 996 ], | 995 ], |
| 997 callback); | 996 callback); |
| 998 | 997 |
| 999 /** | 998 /** |
| 1000 * Note: must declare params as optional. | 999 * Note: must declare params as optional. |
| 1001 * @param {number=} fromIndex | 1000 * @param {number=} fromIndex |
| 1002 * @param {number=} toIndex | 1001 * @param {number=} toIndex |
| 1003 * @param {number=} bucketThreshold | 1002 * @param {number=} bucketThreshold |
| 1004 * @param {number=} sparseIterationThreshold | 1003 * @param {number=} sparseIterationThreshold |
| 1005 * @param {number=} getOwnPropertyNamesThreshold | 1004 * @param {number=} getOwnPropertyNamesThreshold |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1070 } | 1069 } |
| 1071 | 1070 |
| 1072 return {ranges: ranges, skipGetOwnPropertyNames: skipGetOwnPropertyNames}; | 1071 return {ranges: ranges, skipGetOwnPropertyNames: skipGetOwnPropertyNames}; |
| 1073 } | 1072 } |
| 1074 | 1073 |
| 1075 function callback(result) { | 1074 function callback(result) { |
| 1076 if (!result) | 1075 if (!result) |
| 1077 return; | 1076 return; |
| 1078 var ranges = /** @type {!Array.<!Array.<number>>} */ (result.ranges); | 1077 var ranges = /** @type {!Array.<!Array.<number>>} */ (result.ranges); |
| 1079 if (ranges.length === 1) { | 1078 if (ranges.length === 1) { |
| 1080 Components.ArrayGroupingTreeElement._populateAsFragment( | 1079 ObjectUI.ArrayGroupingTreeElement._populateAsFragment(treeNode, object,
ranges[0][0], ranges[0][1], linkifier); |
| 1081 treeNode, object, ranges[0][0], ranges[0][1], linkifier); | |
| 1082 } else { | 1080 } else { |
| 1083 for (var i = 0; i < ranges.length; ++i) { | 1081 for (var i = 0; i < ranges.length; ++i) { |
| 1084 var fromIndex = ranges[i][0]; | 1082 var fromIndex = ranges[i][0]; |
| 1085 var toIndex = ranges[i][1]; | 1083 var toIndex = ranges[i][1]; |
| 1086 var count = ranges[i][2]; | 1084 var count = ranges[i][2]; |
| 1087 if (fromIndex === toIndex) | 1085 if (fromIndex === toIndex) |
| 1088 Components.ArrayGroupingTreeElement._populateAsFragment(treeNode, ob
ject, fromIndex, toIndex, linkifier); | 1086 ObjectUI.ArrayGroupingTreeElement._populateAsFragment(treeNode, obje
ct, fromIndex, toIndex, linkifier); |
| 1089 else | 1087 else |
| 1090 treeNode.appendChild(new Components.ArrayGroupingTreeElement(object,
fromIndex, toIndex, count, linkifier)); | 1088 treeNode.appendChild(new ObjectUI.ArrayGroupingTreeElement(object, f
romIndex, toIndex, count, linkifier)); |
| 1091 } | 1089 } |
| 1092 } | 1090 } |
| 1093 if (topLevel) { | 1091 if (topLevel) { |
| 1094 Components.ArrayGroupingTreeElement._populateNonIndexProperties( | 1092 ObjectUI.ArrayGroupingTreeElement._populateNonIndexProperties( |
| 1095 treeNode, object, result.skipGetOwnPropertyNames, linkifier); | 1093 treeNode, object, result.skipGetOwnPropertyNames, linkifier); |
| 1096 } | 1094 } |
| 1097 } | 1095 } |
| 1098 } | 1096 } |
| 1099 | 1097 |
| 1100 /** | 1098 /** |
| 1101 * @param {!UI.TreeElement} treeNode | 1099 * @param {!UI.TreeElement} treeNode |
| 1102 * @param {!SDK.RemoteObject} object | 1100 * @param {!SDK.RemoteObject} object |
| 1103 * @param {number} fromIndex | 1101 * @param {number} fromIndex |
| 1104 * @param {number} toIndex | 1102 * @param {number} toIndex |
| 1105 * @param {!Components.Linkifier=} linkifier | 1103 * @param {!Components.Linkifier=} linkifier |
| 1106 * @this {Components.ArrayGroupingTreeElement} | 1104 * @this {ObjectUI.ArrayGroupingTreeElement} |
| 1107 */ | 1105 */ |
| 1108 static _populateAsFragment(treeNode, object, fromIndex, toIndex, linkifier) { | 1106 static _populateAsFragment(treeNode, object, fromIndex, toIndex, linkifier) { |
| 1109 object.callFunction( | 1107 object.callFunction( |
| 1110 buildArrayFragment, | 1108 buildArrayFragment, |
| 1111 [{value: fromIndex}, {value: toIndex}, {value: Components.ArrayGroupingT
reeElement._sparseIterationThreshold}], | 1109 [{value: fromIndex}, {value: toIndex}, {value: ObjectUI.ArrayGroupingTre
eElement._sparseIterationThreshold}], |
| 1112 processArrayFragment.bind(this)); | 1110 processArrayFragment.bind(this)); |
| 1113 | 1111 |
| 1114 /** | 1112 /** |
| 1115 * @suppressReceiverCheck | 1113 * @suppressReceiverCheck |
| 1116 * @this {Object} | 1114 * @this {Object} |
| 1117 * @param {number=} fromIndex // must declare optional | 1115 * @param {number=} fromIndex // must declare optional |
| 1118 * @param {number=} toIndex // must declare optional | 1116 * @param {number=} toIndex // must declare optional |
| 1119 * @param {number=} sparseIterationThreshold // must declare optional | 1117 * @param {number=} sparseIterationThreshold // must declare optional |
| 1120 */ | 1118 */ |
| 1121 function buildArrayFragment(fromIndex, toIndex, sparseIterationThreshold) { | 1119 function buildArrayFragment(fromIndex, toIndex, sparseIterationThreshold) { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1133 if (String(index) === name && fromIndex <= index && index <= toIndex) | 1131 if (String(index) === name && fromIndex <= index && index <= toIndex) |
| 1134 result[index] = this[index]; | 1132 result[index] = this[index]; |
| 1135 } | 1133 } |
| 1136 } | 1134 } |
| 1137 return result; | 1135 return result; |
| 1138 } | 1136 } |
| 1139 | 1137 |
| 1140 /** | 1138 /** |
| 1141 * @param {?SDK.RemoteObject} arrayFragment | 1139 * @param {?SDK.RemoteObject} arrayFragment |
| 1142 * @param {boolean=} wasThrown | 1140 * @param {boolean=} wasThrown |
| 1143 * @this {Components.ArrayGroupingTreeElement} | 1141 * @this {ObjectUI.ArrayGroupingTreeElement} |
| 1144 */ | 1142 */ |
| 1145 function processArrayFragment(arrayFragment, wasThrown) { | 1143 function processArrayFragment(arrayFragment, wasThrown) { |
| 1146 if (!arrayFragment || wasThrown) | 1144 if (!arrayFragment || wasThrown) |
| 1147 return; | 1145 return; |
| 1148 arrayFragment.getAllProperties( | 1146 arrayFragment.getAllProperties( |
| 1149 false, Runtime.experiments.isEnabled('objectPreviews'), processPropert
ies.bind(this)); | 1147 false, Runtime.experiments.isEnabled('objectPreviews'), processPropert
ies.bind(this)); |
| 1150 } | 1148 } |
| 1151 | 1149 |
| 1152 /** @this {Components.ArrayGroupingTreeElement} */ | 1150 /** @this {ObjectUI.ArrayGroupingTreeElement} */ |
| 1153 function processProperties(properties, internalProperties) { | 1151 function processProperties(properties, internalProperties) { |
| 1154 if (!properties) | 1152 if (!properties) |
| 1155 return; | 1153 return; |
| 1156 | 1154 |
| 1157 properties.sort(Components.ObjectPropertiesSection.CompareProperties); | 1155 properties.sort(ObjectUI.ObjectPropertiesSection.CompareProperties); |
| 1158 for (var i = 0; i < properties.length; ++i) { | 1156 for (var i = 0; i < properties.length; ++i) { |
| 1159 properties[i].parentObject = this._object; | 1157 properties[i].parentObject = this._object; |
| 1160 var childTreeElement = new Components.ObjectPropertyTreeElement(properti
es[i], linkifier); | 1158 var childTreeElement = new ObjectUI.ObjectPropertyTreeElement(properties
[i], linkifier); |
| 1161 childTreeElement._readOnly = true; | 1159 childTreeElement._readOnly = true; |
| 1162 treeNode.appendChild(childTreeElement); | 1160 treeNode.appendChild(childTreeElement); |
| 1163 } | 1161 } |
| 1164 } | 1162 } |
| 1165 } | 1163 } |
| 1166 | 1164 |
| 1167 /** | 1165 /** |
| 1168 * @param {!UI.TreeElement} treeNode | 1166 * @param {!UI.TreeElement} treeNode |
| 1169 * @param {!SDK.RemoteObject} object | 1167 * @param {!SDK.RemoteObject} object |
| 1170 * @param {boolean} skipGetOwnPropertyNames | 1168 * @param {boolean} skipGetOwnPropertyNames |
| 1171 * @param {!Components.Linkifier=} linkifier | 1169 * @param {!Components.Linkifier=} linkifier |
| 1172 * @this {Components.ArrayGroupingTreeElement} | 1170 * @this {ObjectUI.ArrayGroupingTreeElement} |
| 1173 */ | 1171 */ |
| 1174 static _populateNonIndexProperties(treeNode, object, skipGetOwnPropertyNames,
linkifier) { | 1172 static _populateNonIndexProperties(treeNode, object, skipGetOwnPropertyNames,
linkifier) { |
| 1175 object.callFunction(buildObjectFragment, [{value: skipGetOwnPropertyNames}],
processObjectFragment.bind(this)); | 1173 object.callFunction(buildObjectFragment, [{value: skipGetOwnPropertyNames}],
processObjectFragment.bind(this)); |
| 1176 | 1174 |
| 1177 /** | 1175 /** |
| 1178 * @param {boolean=} skipGetOwnPropertyNames | 1176 * @param {boolean=} skipGetOwnPropertyNames |
| 1179 * @suppressReceiverCheck | 1177 * @suppressReceiverCheck |
| 1180 * @this {Object} | 1178 * @this {Object} |
| 1181 */ | 1179 */ |
| 1182 function buildObjectFragment(skipGetOwnPropertyNames) { | 1180 function buildObjectFragment(skipGetOwnPropertyNames) { |
| 1183 var result = {__proto__: this.__proto__}; | 1181 var result = {__proto__: this.__proto__}; |
| 1184 if (skipGetOwnPropertyNames) | 1182 if (skipGetOwnPropertyNames) |
| 1185 return result; | 1183 return result; |
| 1186 var names = Object.getOwnPropertyNames(this); | 1184 var names = Object.getOwnPropertyNames(this); |
| 1187 for (var i = 0; i < names.length; ++i) { | 1185 for (var i = 0; i < names.length; ++i) { |
| 1188 var name = names[i]; | 1186 var name = names[i]; |
| 1189 // Array index check according to the ES5-15.4. | 1187 // Array index check according to the ES5-15.4. |
| 1190 if (String(name >>> 0) === name && name >>> 0 !== 0xffffffff) | 1188 if (String(name >>> 0) === name && name >>> 0 !== 0xffffffff) |
| 1191 continue; | 1189 continue; |
| 1192 var descriptor = Object.getOwnPropertyDescriptor(this, name); | 1190 var descriptor = Object.getOwnPropertyDescriptor(this, name); |
| 1193 if (descriptor) | 1191 if (descriptor) |
| 1194 Object.defineProperty(result, name, descriptor); | 1192 Object.defineProperty(result, name, descriptor); |
| 1195 } | 1193 } |
| 1196 return result; | 1194 return result; |
| 1197 } | 1195 } |
| 1198 | 1196 |
| 1199 /** | 1197 /** |
| 1200 * @param {?SDK.RemoteObject} arrayFragment | 1198 * @param {?SDK.RemoteObject} arrayFragment |
| 1201 * @param {boolean=} wasThrown | 1199 * @param {boolean=} wasThrown |
| 1202 * @this {Components.ArrayGroupingTreeElement} | 1200 * @this {ObjectUI.ArrayGroupingTreeElement} |
| 1203 */ | 1201 */ |
| 1204 function processObjectFragment(arrayFragment, wasThrown) { | 1202 function processObjectFragment(arrayFragment, wasThrown) { |
| 1205 if (!arrayFragment || wasThrown) | 1203 if (!arrayFragment || wasThrown) |
| 1206 return; | 1204 return; |
| 1207 arrayFragment.getOwnProperties(Runtime.experiments.isEnabled('objectPrevie
ws'), processProperties.bind(this)); | 1205 arrayFragment.getOwnProperties(Runtime.experiments.isEnabled('objectPrevie
ws'), processProperties.bind(this)); |
| 1208 } | 1206 } |
| 1209 | 1207 |
| 1210 /** | 1208 /** |
| 1211 * @param {?Array.<!SDK.RemoteObjectProperty>} properties | 1209 * @param {?Array.<!SDK.RemoteObjectProperty>} properties |
| 1212 * @param {?Array.<!SDK.RemoteObjectProperty>=} internalProperties | 1210 * @param {?Array.<!SDK.RemoteObjectProperty>=} internalProperties |
| 1213 * @this {Components.ArrayGroupingTreeElement} | 1211 * @this {ObjectUI.ArrayGroupingTreeElement} |
| 1214 */ | 1212 */ |
| 1215 function processProperties(properties, internalProperties) { | 1213 function processProperties(properties, internalProperties) { |
| 1216 if (!properties) | 1214 if (!properties) |
| 1217 return; | 1215 return; |
| 1218 properties.sort(Components.ObjectPropertiesSection.CompareProperties); | 1216 properties.sort(ObjectUI.ObjectPropertiesSection.CompareProperties); |
| 1219 for (var i = 0; i < properties.length; ++i) { | 1217 for (var i = 0; i < properties.length; ++i) { |
| 1220 properties[i].parentObject = this._object; | 1218 properties[i].parentObject = this._object; |
| 1221 var childTreeElement = new Components.ObjectPropertyTreeElement(properti
es[i], linkifier); | 1219 var childTreeElement = new ObjectUI.ObjectPropertyTreeElement(properties
[i], linkifier); |
| 1222 childTreeElement._readOnly = true; | 1220 childTreeElement._readOnly = true; |
| 1223 treeNode.appendChild(childTreeElement); | 1221 treeNode.appendChild(childTreeElement); |
| 1224 } | 1222 } |
| 1225 } | 1223 } |
| 1226 } | 1224 } |
| 1227 | 1225 |
| 1228 /** | 1226 /** |
| 1229 * @override | 1227 * @override |
| 1230 */ | 1228 */ |
| 1231 onpopulate() { | 1229 onpopulate() { |
| 1232 if (this._propertyCount >= Components.ArrayGroupingTreeElement._bucketThresh
old) { | 1230 if (this._propertyCount >= ObjectUI.ArrayGroupingTreeElement._bucketThreshol
d) { |
| 1233 Components.ArrayGroupingTreeElement._populateRanges( | 1231 ObjectUI.ArrayGroupingTreeElement._populateRanges( |
| 1234 this, this._object, this._fromIndex, this._toIndex, false, this._linki
fier); | 1232 this, this._object, this._fromIndex, this._toIndex, false, this._linki
fier); |
| 1235 return; | 1233 return; |
| 1236 } | 1234 } |
| 1237 Components.ArrayGroupingTreeElement._populateAsFragment( | 1235 ObjectUI.ArrayGroupingTreeElement._populateAsFragment( |
| 1238 this, this._object, this._fromIndex, this._toIndex, this._linkifier); | 1236 this, this._object, this._fromIndex, this._toIndex, this._linkifier); |
| 1239 } | 1237 } |
| 1240 | 1238 |
| 1241 /** | 1239 /** |
| 1242 * @override | 1240 * @override |
| 1243 */ | 1241 */ |
| 1244 onattach() { | 1242 onattach() { |
| 1245 this.listItemElement.classList.add('object-properties-section-name'); | 1243 this.listItemElement.classList.add('object-properties-section-name'); |
| 1246 } | 1244 } |
| 1247 }; | 1245 }; |
| 1248 | 1246 |
| 1249 Components.ArrayGroupingTreeElement._bucketThreshold = 100; | 1247 ObjectUI.ArrayGroupingTreeElement._bucketThreshold = 100; |
| 1250 Components.ArrayGroupingTreeElement._sparseIterationThreshold = 250000; | 1248 ObjectUI.ArrayGroupingTreeElement._sparseIterationThreshold = 250000; |
| 1251 Components.ArrayGroupingTreeElement._getOwnPropertyNamesThreshold = 500000; | 1249 ObjectUI.ArrayGroupingTreeElement._getOwnPropertyNamesThreshold = 500000; |
| 1252 | 1250 |
| 1253 | 1251 |
| 1254 /** | 1252 /** |
| 1255 * @unrestricted | 1253 * @unrestricted |
| 1256 */ | 1254 */ |
| 1257 Components.ObjectPropertyPrompt = class extends UI.TextPrompt { | 1255 ObjectUI.ObjectPropertyPrompt = class extends UI.TextPrompt { |
| 1258 constructor() { | 1256 constructor() { |
| 1259 super(); | 1257 super(); |
| 1260 this.initialize(Components.JavaScriptAutocomplete.completionsForTextInCurren
tContext); | 1258 this.initialize(ObjectUI.JavaScriptAutocomplete.completionsForTextInCurrentC
ontext); |
| 1261 } | 1259 } |
| 1262 }; | 1260 }; |
| 1263 | 1261 |
| 1264 /** | 1262 /** |
| 1265 * @unrestricted | 1263 * @unrestricted |
| 1266 */ | 1264 */ |
| 1267 Components.ObjectPropertiesSectionExpandController = class { | 1265 ObjectUI.ObjectPropertiesSectionExpandController = class { |
| 1268 constructor() { | 1266 constructor() { |
| 1269 /** @type {!Set.<string>} */ | 1267 /** @type {!Set.<string>} */ |
| 1270 this._expandedProperties = new Set(); | 1268 this._expandedProperties = new Set(); |
| 1271 } | 1269 } |
| 1272 | 1270 |
| 1273 /** | 1271 /** |
| 1274 * @param {string} id | 1272 * @param {string} id |
| 1275 * @param {!Components.ObjectPropertiesSection} section | 1273 * @param {!ObjectUI.ObjectPropertiesSection} section |
| 1276 */ | 1274 */ |
| 1277 watchSection(id, section) { | 1275 watchSection(id, section) { |
| 1278 section.addEventListener(UI.TreeOutline.Events.ElementAttached, this._elemen
tAttached, this); | 1276 section.addEventListener(UI.TreeOutline.Events.ElementAttached, this._elemen
tAttached, this); |
| 1279 section.addEventListener(UI.TreeOutline.Events.ElementExpanded, this._elemen
tExpanded, this); | 1277 section.addEventListener(UI.TreeOutline.Events.ElementExpanded, this._elemen
tExpanded, this); |
| 1280 section.addEventListener(UI.TreeOutline.Events.ElementCollapsed, this._eleme
ntCollapsed, this); | 1278 section.addEventListener(UI.TreeOutline.Events.ElementCollapsed, this._eleme
ntCollapsed, this); |
| 1281 section[Components.ObjectPropertiesSectionExpandController._treeOutlineId] =
id; | 1279 section[ObjectUI.ObjectPropertiesSectionExpandController._treeOutlineId] = i
d; |
| 1282 | 1280 |
| 1283 if (this._expandedProperties.has(id)) | 1281 if (this._expandedProperties.has(id)) |
| 1284 section.expand(); | 1282 section.expand(); |
| 1285 } | 1283 } |
| 1286 | 1284 |
| 1287 /** | 1285 /** |
| 1288 * @param {string} id | 1286 * @param {string} id |
| 1289 */ | 1287 */ |
| 1290 stopWatchSectionsWithId(id) { | 1288 stopWatchSectionsWithId(id) { |
| 1291 for (var property of this._expandedProperties) { | 1289 for (var property of this._expandedProperties) { |
| (...skipping 25 matching lines...) Expand all Loading... |
| 1317 _elementCollapsed(event) { | 1315 _elementCollapsed(event) { |
| 1318 var element = /** @type {!UI.TreeElement} */ (event.data); | 1316 var element = /** @type {!UI.TreeElement} */ (event.data); |
| 1319 this._expandedProperties.delete(this._propertyPath(element)); | 1317 this._expandedProperties.delete(this._propertyPath(element)); |
| 1320 } | 1318 } |
| 1321 | 1319 |
| 1322 /** | 1320 /** |
| 1323 * @param {!UI.TreeElement} treeElement | 1321 * @param {!UI.TreeElement} treeElement |
| 1324 * @return {string} | 1322 * @return {string} |
| 1325 */ | 1323 */ |
| 1326 _propertyPath(treeElement) { | 1324 _propertyPath(treeElement) { |
| 1327 var cachedPropertyPath = treeElement[Components.ObjectPropertiesSectionExpan
dController._cachedPathSymbol]; | 1325 var cachedPropertyPath = treeElement[ObjectUI.ObjectPropertiesSectionExpandC
ontroller._cachedPathSymbol]; |
| 1328 if (cachedPropertyPath) | 1326 if (cachedPropertyPath) |
| 1329 return cachedPropertyPath; | 1327 return cachedPropertyPath; |
| 1330 | 1328 |
| 1331 var current = treeElement; | 1329 var current = treeElement; |
| 1332 var rootElement = treeElement.treeOutline.objectTreeElement(); | 1330 var rootElement = treeElement.treeOutline.objectTreeElement(); |
| 1333 | 1331 |
| 1334 var result; | 1332 var result; |
| 1335 | 1333 |
| 1336 while (current !== rootElement) { | 1334 while (current !== rootElement) { |
| 1337 var currentName = ''; | 1335 var currentName = ''; |
| 1338 if (current.property) | 1336 if (current.property) |
| 1339 currentName = current.property.name; | 1337 currentName = current.property.name; |
| 1340 else | 1338 else |
| 1341 currentName = typeof current.title === 'string' ? current.title : curren
t.title.textContent; | 1339 currentName = typeof current.title === 'string' ? current.title : curren
t.title.textContent; |
| 1342 | 1340 |
| 1343 result = currentName + (result ? '.' + result : ''); | 1341 result = currentName + (result ? '.' + result : ''); |
| 1344 current = current.parent; | 1342 current = current.parent; |
| 1345 } | 1343 } |
| 1346 var treeOutlineId = treeElement.treeOutline[Components.ObjectPropertiesSecti
onExpandController._treeOutlineId]; | 1344 var treeOutlineId = treeElement.treeOutline[ObjectUI.ObjectPropertiesSection
ExpandController._treeOutlineId]; |
| 1347 result = treeOutlineId + (result ? ':' + result : ''); | 1345 result = treeOutlineId + (result ? ':' + result : ''); |
| 1348 treeElement[Components.ObjectPropertiesSectionExpandController._cachedPathSy
mbol] = result; | 1346 treeElement[ObjectUI.ObjectPropertiesSectionExpandController._cachedPathSymb
ol] = result; |
| 1349 return result; | 1347 return result; |
| 1350 } | 1348 } |
| 1351 }; | 1349 }; |
| 1352 | 1350 |
| 1353 Components.ObjectPropertiesSectionExpandController._cachedPathSymbol = Symbol('c
achedPath'); | 1351 ObjectUI.ObjectPropertiesSectionExpandController._cachedPathSymbol = Symbol('cac
hedPath'); |
| 1354 Components.ObjectPropertiesSectionExpandController._treeOutlineId = Symbol('tree
OutlineId'); | 1352 ObjectUI.ObjectPropertiesSectionExpandController._treeOutlineId = Symbol('treeOu
tlineId'); |
| OLD | NEW |