Home | History | Annotate | Download | only in front-end
      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 
     26 WebInspector.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 
     35 WebInspector.TopDownProfileDataGridNode.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.TopDownProfileDataGridNode(this.profileView, children[i], this.tree));
     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 
     67 WebInspector.TopDownProfileDataGridNode.prototype.__proto__ = WebInspector.ProfileDataGridNode.prototype;
     68 
     69 WebInspector.TopDownProfileDataGridTree = function(/*ProfileView*/ profileView, /*ProfileNode*/ profileNode)
     70 {
     71     WebInspector.ProfileDataGridTree.call(this, profileView, profileNode);
     72 
     73     this._remainingChildren = profileNode.children;
     74 
     75     WebInspector.TopDownProfileDataGridNode.prototype._populate.call(this);
     76 }
     77 
     78 WebInspector.TopDownProfileDataGridTree.prototype = {
     79     focus: function(/*ProfileDataGridNode*/ 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(/*ProfileDataGridNode*/ profileDataGrideNode)
     92     {
     93         if (!profileDataGrideNode)
     94             return;
     95 
     96         this._save();
     97 
     98         var excludedCallUID = profileDataGrideNode.callUID;
     99 
    100         WebInspector.TopDownProfileDataGridNode.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.ProfileDataGridTree.prototype.restore.call(this);
    114     },
    115 
    116     _merge: WebInspector.TopDownProfileDataGridNode.prototype._merge,
    117 
    118     _sharedPopulate: WebInspector.TopDownProfileDataGridNode.prototype._sharedPopulate
    119 }
    120 
    121 WebInspector.TopDownProfileDataGridTree.prototype.__proto__ = WebInspector.ProfileDataGridTree.prototype;
    122