Index: third_party/WebKit/Source/devtools/front_end/profiler/ProfileDataGrid.js |
diff --git a/third_party/WebKit/Source/devtools/front_end/profiler/ProfileDataGrid.js b/third_party/WebKit/Source/devtools/front_end/profiler/ProfileDataGrid.js |
index 92a3d9ee2bde26c3cb217e8ee413370fdb7d5822..cd54532f02bc8fb9852fbb4b53567754a006a3ca 100644 |
--- a/third_party/WebKit/Source/devtools/front_end/profiler/ProfileDataGrid.js |
+++ b/third_party/WebKit/Source/devtools/front_end/profiler/ProfileDataGrid.js |
@@ -111,40 +111,9 @@ WebInspector.ProfileDataGridNode.prototype = { |
* @param {boolean} force |
* @template T |
*/ |
- sort: function(comparator, force) |
+ sort(comparator, force) |
{ |
- var gridNodeGroups = [[this]]; |
- |
- for (var gridNodeGroupIndex = 0; gridNodeGroupIndex < gridNodeGroups.length; ++gridNodeGroupIndex) { |
- var gridNodes = gridNodeGroups[gridNodeGroupIndex]; |
- var count = gridNodes.length; |
- |
- for (var index = 0; index < count; ++index) { |
- var gridNode = gridNodes[index]; |
- |
- // If the grid node is collapsed, then don't sort children (save operation for later). |
- // If the grid node has the same sorting as previously, then there is no point in sorting it again. |
- if (!force && (!gridNode.expanded || gridNode.lastComparator === comparator)) { |
- if (gridNode.children.length) |
- gridNode.shouldRefreshChildren = true; |
- continue; |
- } |
- |
- gridNode.lastComparator = comparator; |
- |
- var children = gridNode.children; |
- var childCount = children.length; |
- |
- if (childCount) { |
- children.sort(comparator); |
- |
- for (var childIndex = 0; childIndex < childCount; ++childIndex) |
- children[childIndex].recalculateSiblings(childIndex); |
- |
- gridNodeGroups.push(children); |
- } |
- } |
- } |
+ return WebInspector.ProfileDataGridNode.sort([[this]], comparator, force); |
}, |
/** |
@@ -170,6 +139,9 @@ WebInspector.ProfileDataGridNode.prototype = { |
this.childrenByCallUID.delete((/** @type {!WebInspector.ProfileDataGridNode} */ (profileDataGridNode)).callUID); |
}, |
+ /** |
+ * @override |
+ */ |
removeChildren: function() |
{ |
WebInspector.DataGridNode.prototype.removeChildren.call(this); |
@@ -198,6 +170,9 @@ WebInspector.ProfileDataGridNode.prototype = { |
return this.total / this.tree.total * 100.0; |
}, |
+ /** |
+ * @override |
+ */ |
populate: function() |
{ |
WebInspector.ProfileDataGridNode.populate(this); |
@@ -261,6 +236,46 @@ WebInspector.ProfileDataGridNode.prototype = { |
}; |
/** |
+ * @param {!Array<!Array>} gridNodeGroups |
dgozman
2016/11/01 00:04:07
Array<!ProfileDataGridNode>
|
+ * @param {function(!T, !T)} comparator |
+ * @param {boolean} force |
+ * @template T |
+ */ |
+WebInspector.ProfileDataGridNode.sort = function(gridNodeGroups, comparator, force) |
+{ |
+ for (var gridNodeGroupIndex = 0; gridNodeGroupIndex < gridNodeGroups.length; ++gridNodeGroupIndex) { |
+ var gridNodes = gridNodeGroups[gridNodeGroupIndex]; |
+ var count = gridNodes.length; |
+ |
+ for (var index = 0; index < count; ++index) { |
+ var gridNode = gridNodes[index]; |
+ |
+ // If the grid node is collapsed, then don't sort children (save operation for later). |
+ // If the grid node has the same sorting as previously, then there is no point in sorting it again. |
+ if (!force && (!gridNode.expanded || gridNode.lastComparator === comparator)) { |
+ if (gridNode.children.length) |
+ gridNode.shouldRefreshChildren = true; |
+ continue; |
+ } |
+ |
+ gridNode.lastComparator = comparator; |
+ |
+ var children = gridNode.children; |
+ var childCount = children.length; |
+ |
+ if (childCount) { |
+ children.sort(comparator); |
+ |
+ for (var childIndex = 0; childIndex < childCount; ++childIndex) |
+ children[childIndex].recalculateSiblings(childIndex); |
+ |
+ gridNodeGroups.push(children); |
+ } |
+ } |
+ } |
+} |
+ |
+/** |
* @param {!WebInspector.ProfileDataGridNode|!WebInspector.ProfileDataGridTree} container |
* @param {!WebInspector.ProfileDataGridNode} child |
* @param {boolean} shouldAbsorb |
@@ -359,8 +374,26 @@ WebInspector.ProfileDataGridTree.prototype = { |
{ |
}, |
- findChild: WebInspector.ProfileDataGridNode.prototype.findChild, |
- sort: WebInspector.ProfileDataGridNode.prototype.sort, |
+ /** |
+ * @param {!WebInspector.ProfileDataGridNode} node |
+ * @return {?WebInspector.ProfileDataGridNode} |
+ */ |
+ findChild: function(node) |
+ { |
+ if (!node) |
+ return null; |
+ return this.childrenByCallUID.get(node.callUID); |
+ }, |
+ |
+ /** |
+ * @param {function(!T, !T)} comparator |
+ * @param {boolean} force |
+ * @template T |
+ */ |
+ sort(comparator, force) |
+ { |
+ return WebInspector.ProfileDataGridNode.sort([[this]], comparator, force); |
+ }, |
/** |
* @protected |