Changeset 124876 in webkit
- Timestamp:
- Aug 7, 2012 4:28:24 AM (12 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r124872 r124876 1 2012-08-07 Peter Rybin <peter.rybin@gmail.com> 2 3 Web Inspector: display function scope in UI 4 https://bugs.webkit.org/show_bug.cgi?id=90631 5 6 Reviewed by Yury Semikhatsky. 7 8 Two new tree element types added: function scope group node and scope node. 9 Scope node is only used to represent closure and catch scopes. Scopes that 10 have a real object beneath are represented as a property node. 11 A method that reads properties from RemoteObject and populate tree element 12 is factored out from RemoteObjectTreeElement for reuse. 13 14 * inspector/front-end/ObjectPropertiesSection.js: 15 (WebInspector.ObjectPropertyTreeElement.prototype.onpopulate): 16 (WebInspector.ObjectPropertyTreeElement.Populate.callback): 17 (WebInspector.ObjectPropertyTreeElement.Populate): 18 (WebInspector.FunctionScopeMainTreeElement): 19 (WebInspector.FunctionScopeMainTreeElement.prototype.onpopulate.didGetDetails): 20 (WebInspector.FunctionScopeMainTreeElement.prototype.onpopulate): 21 (WebInspector.FunctionScopeMainTreeElement.prototype.onattach): 22 (WebInspector.FunctionScopeMainTreeElement.prototype.update): 23 (WebInspector.ScopeTreeElement): 24 (WebInspector.ScopeTreeElement.prototype.onpopulate): 25 (WebInspector.ScopeTreeElement.prototype.onattach): 26 (WebInspector.ScopeTreeElement.prototype.update): 27 * inspector/front-end/RemoteObject.js: 28 (WebInspector.RemoteObjectProperty.fromScopeValue): 29 30 1 31 2012-08-07 Vineet Chaudhary <rgf748@motorola.com> 2 32 -
trunk/Source/WebCore/inspector/front-end/ObjectPropertiesSection.js
r123616 r124876 227 227 onpopulate: function() 228 228 { 229 if (this.children.length && !this.shouldRefreshChildren) 230 return; 231 232 if (this.property.value.arrayLength() > WebInspector.ObjectPropertiesSection._arrayLoadThreshold) { 233 this.removeChildren(); 234 WebInspector.ArrayGroupingTreeElement._populateArray(this, this.property.value, 0, this.property.value.arrayLength() - 1); 235 return; 236 } 237 238 function callback(properties) 239 { 240 this.removeChildren(); 241 if (!properties) 242 return; 243 244 properties.sort(WebInspector.ObjectPropertiesSection.CompareProperties); 245 for (var i = 0; i < properties.length; ++i) { 246 if (this.treeOutline.section.skipProto && properties[i].name === "__proto__") 247 continue; 248 properties[i].parentObject = this.property.value; 249 this.appendChild(new this.treeOutline.section.treeElementConstructor(properties[i])); 250 } 251 } 252 253 this.property.value.getOwnProperties(callback.bind(this)); 229 return WebInspector.ObjectPropertyTreeElement.populate(this, this.property.value); 254 230 }, 255 231 … … 306 282 307 283 this.valueElement.title = description || ""; 308 284 309 285 this.listItemElement.removeChildren(); 310 286 … … 469 445 } 470 446 447 /** 448 * @param {TreeElement} treeElement 449 * @param {WebInspector.RemoteObject} value 450 */ 451 WebInspector.ObjectPropertyTreeElement.populate = function(treeElement, value) { 452 if (treeElement.children.length && !treeElement.shouldRefreshChildren) 453 return; 454 455 if (value.arrayLength() > WebInspector.ObjectPropertiesSection._arrayLoadThreshold) { 456 treeElement.removeChildren(); 457 WebInspector.ArrayGroupingTreeElement._populateArray(treeElement, value, 0, value.arrayLength() - 1); 458 return; 459 } 460 461 function callback(properties) 462 { 463 treeElement.removeChildren(); 464 if (!properties) 465 return; 466 467 properties.sort(WebInspector.ObjectPropertiesSection.CompareProperties); 468 for (var i = 0; i < properties.length; ++i) { 469 if (treeElement.treeOutline.section.skipProto && properties[i].name === "__proto__") 470 continue; 471 properties[i].parentObject = value; 472 treeElement.appendChild(new treeElement.treeOutline.section.treeElementConstructor(properties[i])); 473 } 474 if (value.type === "function") 475 treeElement.appendChild(new WebInspector.FunctionScopeMainTreeElement(value)); 476 } 477 478 value.getOwnProperties(callback); 479 } 480 471 481 WebInspector.ObjectPropertyTreeElement.prototype.__proto__ = TreeElement.prototype; 482 483 /** 484 * @constructor 485 * @extends {TreeElement} 486 * @param {WebInspector.RemoteObject} remoteObject 487 */ 488 WebInspector.FunctionScopeMainTreeElement = function(remoteObject) 489 { 490 TreeElement.call(this, "<function scope>", null, false); 491 this.toggleOnClick = true; 492 this.selectable = false; 493 this._remoteObject = remoteObject; 494 this.hasChildren = true; 495 } 496 497 WebInspector.FunctionScopeMainTreeElement.prototype = { 498 onpopulate: function() 499 { 500 if (this.children.length && !this.shouldRefreshChildren) 501 return; 502 503 function didGetDetails(error, response) 504 { 505 if (error) { 506 console.error(error); 507 return; 508 } 509 this.removeChildren(); 510 511 var scopeChain = response.scopeChain; 512 for (var i = 0; i < scopeChain.length; ++i) { 513 var scope = scopeChain[i]; 514 var title = null; 515 var isTrueObject; 516 517 switch (scope.type) { 518 case "local": 519 // Not really expecting this scope type here. 520 title = WebInspector.UIString("Local"); 521 isTrueObject = false; 522 break; 523 case "closure": 524 title = WebInspector.UIString("Closure"); 525 isTrueObject = false; 526 break; 527 case "catch": 528 title = WebInspector.UIString("Catch"); 529 isTrueObject = false; 530 break; 531 case "with": 532 title = WebInspector.UIString("With Block"); 533 isTrueObject = true; 534 break; 535 case "global": 536 title = WebInspector.UIString("Global"); 537 isTrueObject = true; 538 break; 539 } 540 541 var remoteObject = WebInspector.RemoteObject.fromPayload(scope.object); 542 if (isTrueObject) { 543 var property = WebInspector.RemoteObjectProperty.fromScopeValue(title, remoteObject); 544 property.parentObject = null; 545 this.appendChild(new this.treeOutline.section.treeElementConstructor(property)); 546 } else { 547 var scopeTreeElement = new WebInspector.ScopeTreeElement(title, null, remoteObject); 548 this.appendChild(scopeTreeElement); 549 } 550 } 551 552 } 553 DebuggerAgent.getFunctionDetails(this._remoteObject.objectId, didGetDetails.bind(this)); 554 555 } 556 }; 557 558 WebInspector.FunctionScopeMainTreeElement.prototype.__proto__ = TreeElement.prototype; 559 560 /** 561 * @constructor 562 * @extends {TreeElement} 563 * @param {WebInspector.RemoteObject} remoteObject 564 */ 565 WebInspector.ScopeTreeElement = function(title, subtitle, remoteObject) 566 { 567 // TODO: use subtitle parameter. 568 TreeElement.call(this, title, null, false); 569 this.toggleOnClick = true; 570 this.selectable = false; 571 this._remoteObject = remoteObject; 572 this.hasChildren = true; 573 } 574 575 WebInspector.ScopeTreeElement.prototype = { 576 onpopulate: function() 577 { 578 return WebInspector.ObjectPropertyTreeElement.populate(this, this._remoteObject); 579 } 580 }; 581 582 WebInspector.ScopeTreeElement.prototype.__proto__ = TreeElement.prototype; 472 583 473 584 /** … … 680 791 if (this._populated) 681 792 return; 682 793 683 794 this._populated = true; 684 795 -
trunk/Source/WebCore/inspector/front-end/RemoteObject.js
r121896 r124876 337 337 * @constructor 338 338 * @param {string} name 339 * @param {WebInspector.RemoteObject} value 339 * @param {WebInspector.RemoteObject} value 340 340 * @param {Object=} descriptor 341 341 */ … … 358 358 { 359 359 return new WebInspector.RemoteObjectProperty(name, WebInspector.RemoteObject.fromPrimitiveValue(value)); 360 } 361 362 /** 363 * @param {string} name 364 * @param {WebInspector.RemoteObject} value 365 * @return {WebInspector.RemoteObjectProperty} 366 */ 367 WebInspector.RemoteObjectProperty.fromScopeValue = function(name, value) 368 { 369 var result = new WebInspector.RemoteObjectProperty(name, value); 370 result.writable = false; 371 return result; 360 372 } 361 373
Note: See TracChangeset
for help on using the changeset viewer.