Changeset 146900 in webkit
- Timestamp:
- Mar 26, 2013 10:09:46 AM (11 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r146899 r146900 1 2013-03-26 Peter Rybin <prybin@chromium.org> 2 3 Web Inspector: refactor code duplication: WebInspector.ObjectPropertyTreeElement.wrapPropertyAsElements 4 https://bugs.webkit.org/show_bug.cgi?id=113211 5 6 Reviewed by Yury Semikhatsky. 7 8 A new method WebInspector.ObjectPropertyTreeElement.wrapPropertyAsElements is added and used 9 from 2 sites. 10 11 * inspector/front-end/ObjectPropertiesSection.js: 12 (WebInspector.ObjectPropertiesSection.prototype.update.callback): 13 (WebInspector.ObjectPropertiesSection.prototype.update): 14 (WebInspector.ObjectPropertiesSection.prototype.updateProperties): 15 (.callback): 16 (WebInspector.ObjectPropertyTreeElement.populate): 17 (WebInspector.ObjectPropertyTreeElement.wrapPropertyAsElements): 18 * inspector/front-end/WatchExpressionsSidebarPane.js: 19 (WebInspector.WatchExpressionsSection.prototype.update.appendResult): 20 (WebInspector.WatchExpressionsSection.prototype.update): 21 1 22 2013-03-26 Christophe Dumez <ch.dumez@sisa.samsung.com> 2 23 -
trunk/Source/WebCore/inspector/front-end/ObjectPropertiesSection.js
r146759 r146900 85 85 if (!properties) 86 86 return; 87 this.updateProperties(properties );87 this.updateProperties(properties, internalProperties); 88 88 } 89 89 … … 94 94 }, 95 95 96 updateProperties: function(properties, rootTreeElementConstructor, rootPropertyComparer)96 updateProperties: function(properties, internalProperties, rootTreeElementConstructor, rootPropertyComparer) 97 97 { 98 98 if (!rootTreeElementConstructor) … … 102 102 rootPropertyComparer = WebInspector.ObjectPropertiesSection.CompareProperties; 103 103 104 if (this.extraProperties) 104 if (this.extraProperties) { 105 105 for (var i = 0; i < this.extraProperties.length; ++i) 106 106 properties.push(this.extraProperties[i]); 107 108 properties.sort(rootPropertyComparer); 107 } 109 108 110 109 this.propertiesTreeOutline.removeChildren(); 111 110 112 for (var i = 0; i < properties.length; ++i) { 113 if (this.skipProto && properties[i].name === "__proto__") 114 continue; 115 properties[i].parentObject = this.object; 116 } 117 111 WebInspector.ObjectPropertyTreeElement.populateWithProperties(this.propertiesTreeOutline, 112 properties, internalProperties, 113 rootTreeElementConstructor, rootPropertyComparer, 114 this.skipProto, this.object); 115 118 116 this.propertiesForTest = properties; 119 120 for (var i = 0; i < properties.length; ++i)121 this.propertiesTreeOutline.appendChild(new rootTreeElementConstructor(properties[i]));122 117 123 118 if (!this.propertiesTreeOutline.children.length) { … … 457 452 if (!properties) 458 453 return; 459 460 properties.sort(WebInspector.ObjectPropertiesSection.CompareProperties); 461 for (var i = 0; i < properties.length; ++i) { 462 if (treeElement.treeOutline.section.skipProto && properties[i].name === "__proto__") 463 continue; 464 properties[i].parentObject = value; 465 treeElement.appendChild(new treeElement.treeOutline.section.treeElementConstructor(properties[i])); 466 } 467 if (value.type === "function") { 468 // Whether function has TargetFunction internal property. 469 // This is a simple way to tell that the function is actually a bound function (we are not told). 470 // Bound function never has inner scope and doesn't need corresponding UI node. 471 var hasTargetFunction = false; 472 473 if (internalProperties) { 474 for (var i = 0; i < internalProperties.length; i++) { 475 if (internalProperties[i].name == "[[TargetFunction]]") { 476 hasTargetFunction = true; 477 break; 478 } 479 } 480 } 481 if (!hasTargetFunction) 482 treeElement.appendChild(new WebInspector.FunctionScopeMainTreeElement(value)); 483 } 454 if (!internalProperties) 455 internalProperties = []; 456 457 WebInspector.ObjectPropertyTreeElement.populateWithProperties(treeElement, properties, internalProperties, 458 treeElement.treeOutline.section.treeElementConstructor, WebInspector.ObjectPropertiesSection.CompareProperties, 459 treeElement.treeOutline.section.skipProto, value); 460 } 461 462 value.getOwnProperties(callback); 463 } 464 465 /** 466 * @param {!TreeElement|!TreeOutline} treeElement 467 * @param {Array.<!WebInspector.RemoteObjectProperty>} properties 468 * @param {?Array.<!WebInspector.RemoteObjectProperty>} internalProperties 469 * @param {function(new:TreeElement, WebInspector.RemoteObjectProperty)} treeElementConstructor 470 * @param {function (WebInspector.RemoteObjectProperty, WebInspector.RemoteObjectProperty): number} comparator 471 * @param {boolean} skipProto 472 * @param {?WebInspector.RemoteObject} value 473 */ 474 WebInspector.ObjectPropertyTreeElement.populateWithProperties = function(treeElement, properties, internalProperties, treeElementConstructor, comparator, skipProto, value) { 475 properties.sort(comparator); 476 477 for (var i = 0; i < properties.length; ++i) { 478 if (skipProto && properties[i].name === "__proto__") 479 continue; 480 properties[i].parentObject = value; 481 treeElement.appendChild(new treeElementConstructor(properties[i])); 482 } 483 if (value && value.type === "function") { 484 // Whether function has TargetFunction internal property. 485 // This is a simple way to tell that the function is actually a bound function (we are not told). 486 // Bound function never has inner scope and doesn't need corresponding UI node. 487 var hasTargetFunction = false; 488 484 489 if (internalProperties) { 485 490 for (var i = 0; i < internalProperties.length; i++) { 486 internalProperties[i].parentObject = value; 487 treeElement.appendChild(new treeElement.treeOutline.section.treeElementConstructor(internalProperties[i])); 488 } 489 } 490 } 491 492 value.getOwnProperties(callback); 491 if (internalProperties[i].name == "[[TargetFunction]]") { 492 hasTargetFunction = true; 493 break; 494 } 495 } 496 } 497 if (!hasTargetFunction) 498 treeElement.appendChild(new WebInspector.FunctionScopeMainTreeElement(value)); 499 } 500 if (internalProperties) { 501 for (var i = 0; i < internalProperties.length; i++) { 502 internalProperties[i].parentObject = value; 503 treeElement.appendChild(new treeElementConstructor(internalProperties[i])); 504 } 505 } 493 506 } 494 507 -
trunk/Source/WebCore/inspector/front-end/WatchExpressionsSidebarPane.js
r146220 r146900 161 161 162 162 if (properties.length == propertyCount) { 163 this.updateProperties(properties, WebInspector.WatchExpressionTreeElement, WebInspector.WatchExpressionsSection.CompareProperties);163 this.updateProperties(properties, [], WebInspector.WatchExpressionTreeElement, WebInspector.WatchExpressionsSection.CompareProperties); 164 164 165 165 // check to see if we just added a new watch expression,
Note: See TracChangeset
for help on using the changeset viewer.