• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.TopDownProfileDataGridNode = function(/*ProfileView*/ profileView, /*ProfileNode*/ profileNode, /*TopDownProfileDataGridTree*/ owningTree)
27{
28    var hasChildren = (profileNode.children && profileNode.children.length);
29
30    WebInspector.ProfileDataGridNode.call(this, profileView, profileNode, owningTree, hasChildren);
31
32    this._remainingChildren = profileNode.children;
33}
34
35WebInspector.TopDownProfileDataGridNode.prototype = {
36    _populate: function(event)
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.TopDownProfileDataGridNode(this.profileView, children[i], this.tree));
43
44        if (this.removeEventListener)
45            this.removeEventListener("populate", this._populate, this);
46
47        this._remainingChildren = null;
48    },
49
50    _exclude: function(aCallUID)
51    {
52        if (this._remainingChildren)
53            this._populate();
54
55        this._save();
56
57        var children = this.children;
58        var index = this.children.length;
59
60        while (index--)
61            children[index]._exclude(aCallUID);
62
63        var child = this.childrenByCallUID[aCallUID];
64
65        if (child)
66            this._merge(child, true);
67    }
68}
69
70WebInspector.TopDownProfileDataGridNode.prototype.__proto__ = WebInspector.ProfileDataGridNode.prototype;
71
72WebInspector.TopDownProfileDataGridTree = function(/*ProfileView*/ profileView, /*ProfileNode*/ profileNode)
73{
74    WebInspector.ProfileDataGridTree.call(this, profileView, profileNode);
75
76    this._remainingChildren = profileNode.children;
77
78    WebInspector.TopDownProfileDataGridNode.prototype._populate.call(this);
79}
80
81WebInspector.TopDownProfileDataGridTree.prototype = {
82    focus: function(/*ProfileDataGridNode*/ profileDataGrideNode)
83    {
84        if (!profileDataGrideNode)
85            return;
86
87        this._save();
88
89        this.children = [profileDataGrideNode];
90        this.totalTime = profileDataGrideNode.totalTime;
91    },
92
93    exclude: function(/*ProfileDataGridNode*/ profileDataGrideNode)
94    {
95        if (!profileDataGrideNode)
96            return;
97
98        this._save();
99
100        var excludedCallUID = profileDataGrideNode.callUID;
101
102        WebInspector.TopDownProfileDataGridNode.prototype._exclude.call(this, excludedCallUID);
103
104        if (this.lastComparator)
105            this.sort(this.lastComparator, true);
106    },
107
108    _merge: WebInspector.TopDownProfileDataGridNode.prototype._merge
109}
110
111WebInspector.TopDownProfileDataGridTree.prototype.__proto__ = WebInspector.ProfileDataGridTree.prototype;
112