Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(740)

Unified Diff: third_party/WebKit/Source/devtools/front_end/profiler/ProfileDataGrid.js

Issue 2466123002: DevTools: reformat front-end code to match chromium style. (Closed)
Patch Set: Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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

Powered by Google App Engine
This is Rietveld 408576698