OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 /** | 5 /** |
6 * @fileoverview Tools is a main class that wires all components of the | 6 * @fileoverview Tools is a main class that wires all components of the |
7 * DevTools frontend together. It is also responsible for overriding existing | 7 * DevTools frontend together. It is also responsible for overriding existing |
8 * WebInspector functionality while it is getting upstreamed into WebCore. | 8 * WebInspector functionality while it is getting upstreamed into WebCore. |
9 */ | 9 */ |
10 goog.provide('devtools.Tools'); | 10 goog.provide('devtools.Tools'); |
(...skipping 695 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
706 }; | 706 }; |
707 | 707 |
708 | 708 |
709 (function() { | 709 (function() { |
710 var oldShow = WebInspector.ScriptsPanel.prototype.show; | 710 var oldShow = WebInspector.ScriptsPanel.prototype.show; |
711 WebInspector.ScriptsPanel.prototype.show = function() { | 711 WebInspector.ScriptsPanel.prototype.show = function() { |
712 devtools.tools.getDebuggerAgent().initializeScriptsCache(); | 712 devtools.tools.getDebuggerAgent().initializeScriptsCache(); |
713 oldShow.call(this); | 713 oldShow.call(this); |
714 }; | 714 }; |
715 })(); | 715 })(); |
| 716 |
| 717 |
| 718 /** |
| 719 * We don't use WebKit's BottomUpProfileDataGridTree, instead using |
| 720 * our own (because BottomUpProfileDataGridTree's functionality is |
| 721 * implemented in profile_view.js for V8's Tick Processor). |
| 722 * |
| 723 * @param {WebInspector.ProfileView} profileView Profile view. |
| 724 * @param {devtools.profiler.ProfileView} profile Profile. |
| 725 */ |
| 726 WebInspector.BottomUpProfileDataGridTree = function(profileView, profile) { |
| 727 return WebInspector.buildProfileDataGridTree_( |
| 728 profileView, profile.heavyProfile); |
| 729 }; |
| 730 |
| 731 |
| 732 /** |
| 733 * We don't use WebKit's TopDownProfileDataGridTree, instead using |
| 734 * our own (because TopDownProfileDataGridTree's functionality is |
| 735 * implemented in profile_view.js for V8's Tick Processor). |
| 736 * |
| 737 * @param {WebInspector.ProfileView} profileView Profile view. |
| 738 * @param {devtools.profiler.ProfileView} profile Profile. |
| 739 */ |
| 740 WebInspector.TopDownProfileDataGridTree = function(profileView, profile) { |
| 741 return WebInspector.buildProfileDataGridTree_( |
| 742 profileView, profile.treeProfile); |
| 743 }; |
| 744 |
| 745 |
| 746 /** |
| 747 * A helper function, checks whether a profile node has visible children. |
| 748 * |
| 749 * @param {devtools.profiler.ProfileView.Node} profileNode Profile node. |
| 750 * @return {boolean} Whether a profile node has visible children. |
| 751 */ |
| 752 WebInspector.nodeHasChildren_ = function(profileNode) { |
| 753 var children = profileNode.children; |
| 754 for (var i = 0, n = children.length; i < n; ++i) { |
| 755 if (children[i].visible) { |
| 756 return true; |
| 757 } |
| 758 } |
| 759 return false; |
| 760 }; |
| 761 |
| 762 |
| 763 /** |
| 764 * Common code for populating a profiler grid node or a tree with |
| 765 * given profile nodes. |
| 766 * |
| 767 * @param {WebInspector.ProfileDataGridNode| |
| 768 * WebInspector.ProfileDataGridTree} viewNode Grid node or a tree. |
| 769 * @param {WebInspector.ProfileView} profileView Profile view. |
| 770 * @param {Array<devtools.profiler.ProfileView.Node>} children Profile nodes. |
| 771 * @param {WebInspector.ProfileDataGridTree} owningTree Grid tree. |
| 772 */ |
| 773 WebInspector.populateNode_ = function( |
| 774 viewNode, profileView, children, owningTree) { |
| 775 for (var i = 0, n = children.length; i < n; ++i) { |
| 776 var child = children[i]; |
| 777 if (child.visible) { |
| 778 viewNode.appendChild( |
| 779 new WebInspector.ProfileDataGridNode( |
| 780 profileView, child, owningTree, |
| 781 WebInspector.nodeHasChildren_(child))); |
| 782 } |
| 783 } |
| 784 }; |
| 785 |
| 786 |
| 787 /** |
| 788 * A helper function for building a profile grid tree. |
| 789 * |
| 790 * @param {WebInspector.ProfileView} profileview Profile view. |
| 791 * @param {devtools.profiler.ProfileView} profile Profile. |
| 792 * @return {WebInspector.ProfileDataGridTree} Profile grid tree. |
| 793 */ |
| 794 WebInspector.buildProfileDataGridTree_ = function(profileView, profile) { |
| 795 var children = profile.head.children; |
| 796 var dataGridTree = new WebInspector.ProfileDataGridTree( |
| 797 profileView, profile.head); |
| 798 WebInspector.populateNode_(dataGridTree, profileView, children, dataGridTree); |
| 799 return dataGridTree; |
| 800 }; |
| 801 |
| 802 |
| 803 /** |
| 804 * @override |
| 805 */ |
| 806 WebInspector.ProfileDataGridNode.prototype._populate = function(event) { |
| 807 var children = this.profileNode.children; |
| 808 WebInspector.populateNode_(this, this.profileView, children, this.tree); |
| 809 this.removeEventListener("populate", this._populate, this); |
| 810 }; |
| 811 |
| 812 |
| 813 // As columns in data grid can't be changed after initialization, |
| 814 // we need to intercept the constructor and modify columns upon creation. |
| 815 (function InterceptDataGridForProfiler() { |
| 816 var originalDataGrid = WebInspector.DataGrid; |
| 817 WebInspector.DataGrid = function(columns) { |
| 818 if (('average' in columns) && ('calls' in columns)) { |
| 819 delete columns['average']; |
| 820 delete columns['calls']; |
| 821 } |
| 822 return new originalDataGrid(columns); |
| 823 }; |
| 824 })(); |
OLD | NEW |