2 * Copyright (C) 2009 280 North Inc. All Rights Reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
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.
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.
28 * @extends {WebInspector.ProfileDataGridNode}
29 * @param {!ProfilerAgent.CPUProfileNode} profileNode
30 * @param {!WebInspector.TopDownProfileDataGridTree} owningTree
32 WebInspector.TopDownProfileDataGridNode = function(profileNode, owningTree)
34 var hasChildren = !!(profileNode.children && profileNode.children.length);
36 WebInspector.ProfileDataGridNode.call(this, profileNode, owningTree, hasChildren);
38 this._remainingChildren = profileNode.children;
42 WebInspector.TopDownProfileDataGridNode.prototype = {
43 _sharedPopulate: function()
45 var children = this._remainingChildren;
46 var childrenLength = children.length;
48 for (var i = 0; i < childrenLength; ++i)
49 this.appendChild(new WebInspector.TopDownProfileDataGridNode(children[i], this.tree));
51 this._remainingChildren = null;
54 _exclude: function(aCallUID)
56 if (this._remainingChildren)
61 var children = this.children;
62 var index = this.children.length;
65 children[index]._exclude(aCallUID);
67 var child = this.childrenByCallUID[aCallUID];
70 this._merge(child, true);
73 __proto__: WebInspector.ProfileDataGridNode.prototype
78 * @extends {WebInspector.ProfileDataGridTree}
79 * @param {!WebInspector.CPUProfileView} profileView
80 * @param {!ProfilerAgent.CPUProfileNode} rootProfileNode
82 WebInspector.TopDownProfileDataGridTree = function(profileView, rootProfileNode)
84 WebInspector.ProfileDataGridTree.call(this, profileView, rootProfileNode);
86 this._remainingChildren = rootProfileNode.children;
88 var any = /** @type {*} */(this);
89 var node = /** @type {!WebInspector.ProfileDataGridNode} */(any);
90 WebInspector.TopDownProfileDataGridNode.prototype.populate.call(node);
93 WebInspector.TopDownProfileDataGridTree.prototype = {
95 * @param {!WebInspector.ProfileDataGridNode} profileDataGridNode
97 focus: function(profileDataGridNode)
99 if (!profileDataGridNode)
103 profileDataGridNode.savePosition();
105 this.children = [profileDataGridNode];
106 this.totalTime = profileDataGridNode.totalTime;
110 * @param {!WebInspector.ProfileDataGridNode} profileDataGridNode
112 exclude: function(profileDataGridNode)
114 if (!profileDataGridNode)
119 var excludedCallUID = profileDataGridNode.callUID;
121 var any = /** @type {*} */(this);
122 var node = /** @type {!WebInspector.TopDownProfileDataGridNode} */(any);
123 WebInspector.TopDownProfileDataGridNode.prototype._exclude.call(node, excludedCallUID);
125 if (this.lastComparator)
126 this.sort(this.lastComparator, true);
131 if (!this._savedChildren)
134 this.children[0].restorePosition();
136 WebInspector.ProfileDataGridTree.prototype.restore.call(this);
139 _merge: WebInspector.TopDownProfileDataGridNode.prototype._merge,
141 _sharedPopulate: WebInspector.TopDownProfileDataGridNode.prototype._sharedPopulate,
143 __proto__: WebInspector.ProfileDataGridTree.prototype