1/* 2 * Copyright (C) 2009 280 North Inc. All Rights Reserved. 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions 6 * are met: 7 * 1. Redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer. 9 * 2. Redistributions in binary form must reproduce the above copyright 10 * notice, this list of conditions and the following disclaimer in the 11 * documentation and/or other materials provided with the distribution. 12 * 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 */ 25 26WebInspector.LegacyTopDownProfileDataGridNode = function(profileNode, owningTree) 27{ 28 var hasChildren = (profileNode.children && profileNode.children.length); 29 30 WebInspector.LegacyProfileDataGridNode.call(this, profileNode, owningTree, hasChildren); 31 32 this._remainingChildren = profileNode.children; 33} 34 35WebInspector.LegacyTopDownProfileDataGridNode.prototype = { 36 _sharedPopulate: function() 37 { 38 var children = this._remainingChildren; 39 var childrenLength = children.length; 40 41 for (var i = 0; i < childrenLength; ++i) 42 this.appendChild(new WebInspector.LegacyTopDownProfileDataGridNode(children[i], this.tree, false, this.showTimeAsPercent)); 43 44 this._remainingChildren = null; 45 }, 46 47 _exclude: function(aCallUID) 48 { 49 if (this._remainingChildren) 50 this._populate(); 51 52 this._save(); 53 54 var children = this.children; 55 var index = this.children.length; 56 57 while (index--) 58 children[index]._exclude(aCallUID); 59 60 var child = this.childrenByCallUID[aCallUID]; 61 62 if (child) 63 this._merge(child, true); 64 } 65} 66 67WebInspector.LegacyTopDownProfileDataGridNode.prototype.__proto__ = WebInspector.LegacyProfileDataGridNode.prototype; 68 69WebInspector.LegacyTopDownProfileDataGridTree = function(profileNode) 70{ 71 WebInspector.LegacyProfileDataGridTree.call(this, profileNode); 72 73 this._remainingChildren = profileNode.children; 74 75 WebInspector.LegacyTopDownProfileDataGridNode.prototype._populate.call(this); 76} 77 78WebInspector.LegacyTopDownProfileDataGridTree.prototype = { 79 focus: function(profileDataGrideNode) 80 { 81 if (!profileDataGrideNode) 82 return; 83 84 this._save(); 85 profileDataGrideNode.savePosition(); 86 87 this.children = [profileDataGrideNode]; 88 this.totalTime = profileDataGrideNode.totalTime; 89 }, 90 91 exclude: function(profileDataGrideNode) 92 { 93 if (!profileDataGrideNode) 94 return; 95 96 this._save(); 97 98 var excludedCallUID = profileDataGrideNode.callUID; 99 100 WebInspector.LegacyTopDownProfileDataGridNode.prototype._exclude.call(this, excludedCallUID); 101 102 if (this.lastComparator) 103 this.sort(this.lastComparator, true); 104 }, 105 106 restore: function() 107 { 108 if (!this._savedChildren) 109 return; 110 111 this.children[0].restorePosition(); 112 113 WebInspector.LegacyProfileDataGridTree.prototype.restore.call(this); 114 }, 115 116 _merge: WebInspector.LegacyTopDownProfileDataGridNode.prototype._merge, 117 118 _sharedPopulate: WebInspector.LegacyTopDownProfileDataGridNode.prototype._sharedPopulate 119} 120 121WebInspector.LegacyTopDownProfileDataGridTree.prototype.__proto__ = WebInspector.LegacyProfileDataGridTree.prototype; 122