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

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: all done 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..2fb7fc6e23d68c4a3abf7a9bb04b841b4851b44f 100644
--- a/third_party/WebKit/Source/devtools/front_end/profiler/ProfileDataGrid.js
+++ b/third_party/WebKit/Source/devtools/front_end/profiler/ProfileDataGrid.js
@@ -22,17 +22,17 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-
/**
- * @constructor
- * @extends {WebInspector.DataGridNode}
- * @param {!WebInspector.ProfileNode} profileNode
- * @param {!WebInspector.ProfileDataGridTree} owningTree
- * @param {boolean} hasChildren
+ * @unrestricted
*/
-WebInspector.ProfileDataGridNode = function(profileNode, owningTree, hasChildren)
-{
- WebInspector.DataGridNode.call(this, null, hasChildren);
+WebInspector.ProfileDataGridNode = class extends WebInspector.DataGridNode {
+ /**
+ * @param {!WebInspector.ProfileNode} profileNode
+ * @param {!WebInspector.ProfileDataGridTree} owningTree
+ * @param {boolean} hasChildren
+ */
+ constructor(profileNode, owningTree, hasChildren) {
+ super(null, hasChildren);
this.profileNode = profileNode;
this.tree = owningTree;
@@ -44,233 +44,59 @@ WebInspector.ProfileDataGridNode = function(profileNode, owningTree, hasChildren
this.self = profileNode.self;
this.total = profileNode.total;
this.functionName = WebInspector.beautifyFunctionName(profileNode.functionName);
- this._deoptReason = profileNode.deoptReason || "";
+ this._deoptReason = profileNode.deoptReason || '';
this.url = profileNode.url;
-};
-
-WebInspector.ProfileDataGridNode.prototype = {
- /**
- * @override
- * @param {string} columnId
- * @return {!Element}
- */
- createCell: function(columnId)
- {
- var cell;
- switch (columnId) {
- case "self":
- cell = this._createValueCell(this.self, this.selfPercent);
- cell.classList.toggle("highlight", this._searchMatchedSelfColumn);
- break;
-
- case "total":
- cell = this._createValueCell(this.total, this.totalPercent);
- cell.classList.toggle("highlight", this._searchMatchedTotalColumn);
- break;
-
- case "function":
- cell = this.createTD(columnId);
- cell.classList.toggle("highlight", this._searchMatchedFunctionColumn);
- if (this._deoptReason) {
- cell.classList.add("not-optimized");
- cell.createChild("span", "profile-warn-marker").title = WebInspector.UIString("Not optimized: %s", this._deoptReason);
- }
- cell.createTextChild(this.functionName);
- if (this.profileNode.scriptId === "0")
- break;
- var urlElement = this.tree._formatter.linkifyNode(this);
- if (!urlElement)
- break;
- urlElement.style.maxWidth = "75%";
- cell.appendChild(urlElement);
- break;
-
- default:
- cell = WebInspector.DataGridNode.prototype.createCell.call(this, columnId);
- break;
+ }
+
+ /**
+ * @param {!Array<!Array<!WebInspector.ProfileDataGridNode>>} gridNodeGroups
+ * @param {function(!T, !T)} comparator
+ * @param {boolean} force
+ * @template T
+ */
+ static sort(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;
}
- return cell;
- },
- /**
- * @param {number} value
- * @param {number} percent
- * @return {!Element}
- */
- _createValueCell: function(value, percent)
- {
- var cell = createElementWithClass("td", "numeric-column");
- var div = cell.createChild("div", "profile-multiple-values");
- div.createChild("span").textContent = this.tree._formatter.formatValue(value, this);
- div.createChild("span", "percent-column").textContent = this.tree._formatter.formatPercent(percent, this);
- return cell;
- },
+ gridNode.lastComparator = comparator;
- /**
- * @param {function(!T, !T)} comparator
- * @param {boolean} force
- * @template T
- */
- sort: function(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;
- }
+ var children = gridNode.children;
+ var childCount = children.length;
- gridNode.lastComparator = comparator;
+ if (childCount) {
+ children.sort(comparator);
- var children = gridNode.children;
- var childCount = children.length;
+ for (var childIndex = 0; childIndex < childCount; ++childIndex)
+ children[childIndex].recalculateSiblings(childIndex);
- if (childCount) {
- children.sort(comparator);
-
- for (var childIndex = 0; childIndex < childCount; ++childIndex)
- children[childIndex].recalculateSiblings(childIndex);
-
- gridNodeGroups.push(children);
- }
- }
+ gridNodeGroups.push(children);
}
- },
-
- /**
- * @override
- * @param {!WebInspector.DataGridNode} profileDataGridNode
- * @param {number} index
- */
- insertChild: function(profileDataGridNode, index)
- {
- WebInspector.DataGridNode.prototype.insertChild.call(this, profileDataGridNode, index);
-
- this.childrenByCallUID.set(profileDataGridNode.callUID, /** @type {!WebInspector.ProfileDataGridNode} */ (profileDataGridNode));
- },
-
- /**
- * @override
- * @param {!WebInspector.DataGridNode} profileDataGridNode
- */
- removeChild: function(profileDataGridNode)
- {
- WebInspector.DataGridNode.prototype.removeChild.call(this, profileDataGridNode);
-
- this.childrenByCallUID.delete((/** @type {!WebInspector.ProfileDataGridNode} */ (profileDataGridNode)).callUID);
- },
-
- removeChildren: function()
- {
- WebInspector.DataGridNode.prototype.removeChildren.call(this);
-
- this.childrenByCallUID.clear();
- },
-
- /**
- * @param {!WebInspector.ProfileDataGridNode} node
- * @return {?WebInspector.ProfileDataGridNode}
- */
- findChild: function(node)
- {
- if (!node)
- return null;
- return this.childrenByCallUID.get(node.callUID);
- },
-
- get selfPercent()
- {
- return this.self / this.tree.total * 100.0;
- },
-
- get totalPercent()
- {
- return this.total / this.tree.total * 100.0;
- },
-
- populate: function()
- {
- WebInspector.ProfileDataGridNode.populate(this);
- },
-
- /**
- * @protected
- */
- populateChildren: function()
- {
- },
-
- // When focusing and collapsing we modify lots of nodes in the tree.
- // This allows us to restore them all to their original state when we revert.
-
- save: function()
- {
- if (this._savedChildren)
- return;
-
- this._savedSelf = this.self;
- this._savedTotal = this.total;
-
- this._savedChildren = this.children.slice();
- },
-
- /**
- * When focusing and collapsing we modify lots of nodes in the tree.
- * This allows us to restore them all to their original state when we revert.
- * @protected
- */
- restore: function()
- {
- if (!this._savedChildren)
- return;
-
- this.self = this._savedSelf;
- this.total = this._savedTotal;
-
- this.removeChildren();
-
- var children = this._savedChildren;
- var count = children.length;
-
- for (var index = 0; index < count; ++index) {
- children[index].restore();
- this.appendChild(children[index]);
- }
- },
-
- /**
- * @param {!WebInspector.ProfileDataGridNode} child
- * @param {boolean} shouldAbsorb
- */
- merge: function(child, shouldAbsorb)
- {
- WebInspector.ProfileDataGridNode.merge(this, child, shouldAbsorb);
- },
-
- __proto__: WebInspector.DataGridNode.prototype
-};
-
-/**
- * @param {!WebInspector.ProfileDataGridNode|!WebInspector.ProfileDataGridTree} container
- * @param {!WebInspector.ProfileDataGridNode} child
- * @param {boolean} shouldAbsorb
- */
-WebInspector.ProfileDataGridNode.merge = function(container, child, shouldAbsorb)
-{
+ }
+ }
+ }
+
+ /**
+ * @param {!WebInspector.ProfileDataGridNode|!WebInspector.ProfileDataGridTree} container
+ * @param {!WebInspector.ProfileDataGridNode} child
+ * @param {boolean} shouldAbsorb
+ */
+ static merge(container, child, shouldAbsorb) {
container.self += child.self;
if (!shouldAbsorb)
- container.total += child.total;
+ container.total += child.total;
var children = container.children.slice();
@@ -279,31 +105,30 @@ WebInspector.ProfileDataGridNode.merge = function(container, child, shouldAbsorb
var count = children.length;
for (var index = 0; index < count; ++index) {
- if (!shouldAbsorb || children[index] !== child)
- container.appendChild(children[index]);
+ if (!shouldAbsorb || children[index] !== child)
+ container.appendChild(children[index]);
}
children = child.children.slice();
count = children.length;
for (var index = 0; index < count; ++index) {
- var orphanedChild = children[index];
- var existingChild = container.childrenByCallUID.get(orphanedChild.callUID);
+ var orphanedChild = children[index];
+ var existingChild = container.childrenByCallUID.get(orphanedChild.callUID);
- if (existingChild)
- existingChild.merge(/** @type{!WebInspector.ProfileDataGridNode} */(orphanedChild), false);
- else
- container.appendChild(orphanedChild);
+ if (existingChild)
+ existingChild.merge(/** @type{!WebInspector.ProfileDataGridNode} */ (orphanedChild), false);
+ else
+ container.appendChild(orphanedChild);
}
-};
+ }
-/**
- * @param {!WebInspector.ProfileDataGridNode|!WebInspector.ProfileDataGridTree} container
- */
-WebInspector.ProfileDataGridNode.populate = function(container)
-{
+ /**
+ * @param {!WebInspector.ProfileDataGridNode|!WebInspector.ProfileDataGridTree} container
+ */
+ static populate(container) {
if (container._populated)
- return;
+ return;
container._populated = true;
container.populateChildren();
@@ -311,18 +136,193 @@ WebInspector.ProfileDataGridNode.populate = function(container)
var currentComparator = container.tree.lastComparator;
if (currentComparator)
- container.sort(currentComparator, true);
+ container.sort(currentComparator, true);
+ }
+
+ /**
+ * @override
+ * @param {string} columnId
+ * @return {!Element}
+ */
+ createCell(columnId) {
+ var cell;
+ switch (columnId) {
+ case 'self':
+ cell = this._createValueCell(this.self, this.selfPercent);
+ cell.classList.toggle('highlight', this._searchMatchedSelfColumn);
+ break;
+
+ case 'total':
+ cell = this._createValueCell(this.total, this.totalPercent);
+ cell.classList.toggle('highlight', this._searchMatchedTotalColumn);
+ break;
+
+ case 'function':
+ cell = this.createTD(columnId);
+ cell.classList.toggle('highlight', this._searchMatchedFunctionColumn);
+ if (this._deoptReason) {
+ cell.classList.add('not-optimized');
+ cell.createChild('span', 'profile-warn-marker').title =
+ WebInspector.UIString('Not optimized: %s', this._deoptReason);
+ }
+ cell.createTextChild(this.functionName);
+ if (this.profileNode.scriptId === '0')
+ break;
+ var urlElement = this.tree._formatter.linkifyNode(this);
+ if (!urlElement)
+ break;
+ urlElement.style.maxWidth = '75%';
+ cell.appendChild(urlElement);
+ break;
+
+ default:
+ cell = super.createCell(columnId);
+ break;
+ }
+ return cell;
+ }
+
+ /**
+ * @param {number} value
+ * @param {number} percent
+ * @return {!Element}
+ */
+ _createValueCell(value, percent) {
+ var cell = createElementWithClass('td', 'numeric-column');
+ var div = cell.createChild('div', 'profile-multiple-values');
+ div.createChild('span').textContent = this.tree._formatter.formatValue(value, this);
+ div.createChild('span', 'percent-column').textContent = this.tree._formatter.formatPercent(percent, this);
+ return cell;
+ }
+
+ /**
+ * @param {function(!T, !T)} comparator
+ * @param {boolean} force
+ * @template T
+ */
+ sort(comparator, force) {
+ return WebInspector.ProfileDataGridNode.sort([[this]], comparator, force);
+ }
+
+ /**
+ * @override
+ * @param {!WebInspector.DataGridNode} profileDataGridNode
+ * @param {number} index
+ */
+ insertChild(profileDataGridNode, index) {
+ super.insertChild(profileDataGridNode, index);
+
+ this.childrenByCallUID.set(
+ profileDataGridNode.callUID, /** @type {!WebInspector.ProfileDataGridNode} */ (profileDataGridNode));
+ }
+
+ /**
+ * @override
+ * @param {!WebInspector.DataGridNode} profileDataGridNode
+ */
+ removeChild(profileDataGridNode) {
+ super.removeChild(profileDataGridNode);
+
+ this.childrenByCallUID.delete((/** @type {!WebInspector.ProfileDataGridNode} */ (profileDataGridNode)).callUID);
+ }
+
+ /**
+ * @override
+ */
+ removeChildren() {
+ super.removeChildren();
+
+ this.childrenByCallUID.clear();
+ }
+
+ /**
+ * @param {!WebInspector.ProfileDataGridNode} node
+ * @return {?WebInspector.ProfileDataGridNode}
+ */
+ findChild(node) {
+ if (!node)
+ return null;
+ return this.childrenByCallUID.get(node.callUID);
+ }
+
+ get selfPercent() {
+ return this.self / this.tree.total * 100.0;
+ }
+
+ get totalPercent() {
+ return this.total / this.tree.total * 100.0;
+ }
+
+ /**
+ * @override
+ */
+ populate() {
+ WebInspector.ProfileDataGridNode.populate(this);
+ }
+
+ /**
+ * @protected
+ */
+ populateChildren() {
+ }
+
+ // When focusing and collapsing we modify lots of nodes in the tree.
+ // This allows us to restore them all to their original state when we revert.
+
+ save() {
+ if (this._savedChildren)
+ return;
+
+ this._savedSelf = this.self;
+ this._savedTotal = this.total;
+
+ this._savedChildren = this.children.slice();
+ }
+
+ /**
+ * When focusing and collapsing we modify lots of nodes in the tree.
+ * This allows us to restore them all to their original state when we revert.
+ * @protected
+ */
+ restore() {
+ if (!this._savedChildren)
+ return;
+
+ this.self = this._savedSelf;
+ this.total = this._savedTotal;
+
+ this.removeChildren();
+
+ var children = this._savedChildren;
+ var count = children.length;
+
+ for (var index = 0; index < count; ++index) {
+ children[index].restore();
+ this.appendChild(children[index]);
+ }
+ }
+
+ /**
+ * @param {!WebInspector.ProfileDataGridNode} child
+ * @param {boolean} shouldAbsorb
+ */
+ merge(child, shouldAbsorb) {
+ WebInspector.ProfileDataGridNode.merge(this, child, shouldAbsorb);
+ }
};
+
/**
- * @constructor
* @implements {WebInspector.Searchable}
- * @param {!WebInspector.ProfileDataGridNode.Formatter} formatter
- * @param {!WebInspector.SearchableView} searchableView
- * @param {number} total
+ * @unrestricted
*/
-WebInspector.ProfileDataGridTree = function(formatter, searchableView, total)
-{
+WebInspector.ProfileDataGridTree = class {
+ /**
+ * @param {!WebInspector.ProfileDataGridNode.Formatter} formatter
+ * @param {!WebInspector.SearchableView} searchableView
+ * @param {number} total
+ */
+ constructor(formatter, searchableView, total) {
this.tree = this;
this.children = [];
this._formatter = formatter;
@@ -330,326 +330,323 @@ WebInspector.ProfileDataGridTree = function(formatter, searchableView, total)
this.total = total;
this.lastComparator = null;
this.childrenByCallUID = new Map();
-};
+ }
+
+ /**
+ * @param {string} property
+ * @param {boolean} isAscending
+ * @return {function(!Object.<string, *>, !Object.<string, *>)}
+ */
+ static propertyComparator(property, isAscending) {
+ var comparator = WebInspector.ProfileDataGridTree.propertyComparators[(isAscending ? 1 : 0)][property];
-WebInspector.ProfileDataGridTree.prototype = {
- get expanded()
- {
- return true;
- },
+ if (!comparator) {
+ if (isAscending) {
+ comparator = function(lhs, rhs) {
+ if (lhs[property] < rhs[property])
+ return -1;
- appendChild: function(child)
- {
- this.insertChild(child, this.children.length);
- },
+ if (lhs[property] > rhs[property])
+ return 1;
- insertChild: function(child, index)
- {
- this.children.splice(index, 0, child);
- this.childrenByCallUID.set(child.callUID, child);
- },
+ return 0;
+ };
+ } else {
+ comparator = function(lhs, rhs) {
+ if (lhs[property] > rhs[property])
+ return -1;
- removeChildren: function()
- {
- this.children = [];
- this.childrenByCallUID.clear();
- },
+ if (lhs[property] < rhs[property])
+ return 1;
- populateChildren: function()
- {
- },
+ return 0;
+ };
+ }
- findChild: WebInspector.ProfileDataGridNode.prototype.findChild,
- sort: WebInspector.ProfileDataGridNode.prototype.sort,
+ WebInspector.ProfileDataGridTree.propertyComparators[(isAscending ? 1 : 0)][property] = comparator;
+ }
- /**
- * @protected
- */
- save: function()
- {
- if (this._savedChildren)
- return;
+ return comparator;
+ }
- this._savedTotal = this.total;
- this._savedChildren = this.children.slice();
- },
+ get expanded() {
+ return true;
+ }
- restore: function()
- {
- if (!this._savedChildren)
- return;
+ appendChild(child) {
+ this.insertChild(child, this.children.length);
+ }
- this.children = this._savedChildren;
- this.total = this._savedTotal;
+ insertChild(child, index) {
+ this.children.splice(index, 0, child);
+ this.childrenByCallUID.set(child.callUID, child);
+ }
- var children = this.children;
- var count = children.length;
+ removeChildren() {
+ this.children = [];
+ this.childrenByCallUID.clear();
+ }
+
+ populateChildren() {
+ }
+
+ /**
+ * @param {!WebInspector.ProfileDataGridNode} node
+ * @return {?WebInspector.ProfileDataGridNode}
+ */
+ findChild(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
+ */
+ save() {
+ if (this._savedChildren)
+ return;
+
+ this._savedTotal = this.total;
+ this._savedChildren = this.children.slice();
+ }
+
+ restore() {
+ if (!this._savedChildren)
+ return;
+
+ this.children = this._savedChildren;
+ this.total = this._savedTotal;
+
+ var children = this.children;
+ var count = children.length;
- for (var index = 0; index < count; ++index)
- children[index].restore();
+ for (var index = 0; index < count; ++index)
+ children[index].restore();
+
+ this._savedChildren = null;
+ }
+
+ /**
+ * @param {!WebInspector.SearchableView.SearchConfig} searchConfig
+ * @return {?function(!WebInspector.ProfileDataGridNode):boolean}
+ */
+ _matchFunction(searchConfig) {
+ var query = searchConfig.query.trim();
+ if (!query.length)
+ return null;
+
+ var greaterThan = (query.startsWith('>'));
+ var lessThan = (query.startsWith('<'));
+ var equalTo = (query.startsWith('=') || ((greaterThan || lessThan) && query.indexOf('=') === 1));
+ var percentUnits = (query.endsWith('%'));
+ var millisecondsUnits = (query.length > 2 && query.endsWith('ms'));
+ var secondsUnits = (!millisecondsUnits && query.endsWith('s'));
+
+ var queryNumber = parseFloat(query);
+ if (greaterThan || lessThan || equalTo) {
+ if (equalTo && (greaterThan || lessThan))
+ queryNumber = parseFloat(query.substring(2));
+ else
+ queryNumber = parseFloat(query.substring(1));
+ }
- this._savedChildren = null;
- },
+ var queryNumberMilliseconds = (secondsUnits ? (queryNumber * 1000) : queryNumber);
- /**
- * @param {!WebInspector.SearchableView.SearchConfig} searchConfig
- * @return {?function(!WebInspector.ProfileDataGridNode):boolean}
- */
- _matchFunction: function(searchConfig)
- {
- var query = searchConfig.query.trim();
- if (!query.length)
- return null;
-
- var greaterThan = (query.startsWith(">"));
- var lessThan = (query.startsWith("<"));
- var equalTo = (query.startsWith("=") || ((greaterThan || lessThan) && query.indexOf("=") === 1));
- var percentUnits = (query.endsWith("%"));
- var millisecondsUnits = (query.length > 2 && query.endsWith("ms"));
- var secondsUnits = (!millisecondsUnits && query.endsWith("s"));
-
- var queryNumber = parseFloat(query);
- if (greaterThan || lessThan || equalTo) {
- if (equalTo && (greaterThan || lessThan))
- queryNumber = parseFloat(query.substring(2));
- else
- queryNumber = parseFloat(query.substring(1));
- }
+ // Make equalTo implicitly true if it wasn't specified there is no other operator.
+ if (!isNaN(queryNumber) && !(greaterThan || lessThan))
+ equalTo = true;
- var queryNumberMilliseconds = (secondsUnits ? (queryNumber * 1000) : queryNumber);
-
- // Make equalTo implicitly true if it wasn't specified there is no other operator.
- if (!isNaN(queryNumber) && !(greaterThan || lessThan))
- equalTo = true;
-
- var matcher = createPlainTextSearchRegex(query, "i");
-
- /**
- * @param {!WebInspector.ProfileDataGridNode} profileDataGridNode
- * @return {boolean}
- */
- function matchesQuery(profileDataGridNode)
- {
- delete profileDataGridNode._searchMatchedSelfColumn;
- delete profileDataGridNode._searchMatchedTotalColumn;
- delete profileDataGridNode._searchMatchedFunctionColumn;
-
- if (percentUnits) {
- if (lessThan) {
- if (profileDataGridNode.selfPercent < queryNumber)
- profileDataGridNode._searchMatchedSelfColumn = true;
- if (profileDataGridNode.totalPercent < queryNumber)
- profileDataGridNode._searchMatchedTotalColumn = true;
- } else if (greaterThan) {
- if (profileDataGridNode.selfPercent > queryNumber)
- profileDataGridNode._searchMatchedSelfColumn = true;
- if (profileDataGridNode.totalPercent > queryNumber)
- profileDataGridNode._searchMatchedTotalColumn = true;
- }
-
- if (equalTo) {
- if (profileDataGridNode.selfPercent === queryNumber)
- profileDataGridNode._searchMatchedSelfColumn = true;
- if (profileDataGridNode.totalPercent === queryNumber)
- profileDataGridNode._searchMatchedTotalColumn = true;
- }
- } else if (millisecondsUnits || secondsUnits) {
- if (lessThan) {
- if (profileDataGridNode.self < queryNumberMilliseconds)
- profileDataGridNode._searchMatchedSelfColumn = true;
- if (profileDataGridNode.total < queryNumberMilliseconds)
- profileDataGridNode._searchMatchedTotalColumn = true;
- } else if (greaterThan) {
- if (profileDataGridNode.self > queryNumberMilliseconds)
- profileDataGridNode._searchMatchedSelfColumn = true;
- if (profileDataGridNode.total > queryNumberMilliseconds)
- profileDataGridNode._searchMatchedTotalColumn = true;
- }
-
- if (equalTo) {
- if (profileDataGridNode.self === queryNumberMilliseconds)
- profileDataGridNode._searchMatchedSelfColumn = true;
- if (profileDataGridNode.total === queryNumberMilliseconds)
- profileDataGridNode._searchMatchedTotalColumn = true;
- }
- }
-
- if (profileDataGridNode.functionName.match(matcher) || (profileDataGridNode.url && profileDataGridNode.url.match(matcher)))
- profileDataGridNode._searchMatchedFunctionColumn = true;
-
- if (profileDataGridNode._searchMatchedSelfColumn ||
- profileDataGridNode._searchMatchedTotalColumn ||
- profileDataGridNode._searchMatchedFunctionColumn) {
- profileDataGridNode.refresh();
- return true;
- }
-
- return false;
- }
- return matchesQuery;
- },
+ var matcher = createPlainTextSearchRegex(query, 'i');
/**
- * @override
- * @param {!WebInspector.SearchableView.SearchConfig} searchConfig
- * @param {boolean} shouldJump
- * @param {boolean=} jumpBackwards
+ * @param {!WebInspector.ProfileDataGridNode} profileDataGridNode
+ * @return {boolean}
*/
- performSearch: function(searchConfig, shouldJump, jumpBackwards)
- {
- this.searchCanceled();
- var matchesQuery = this._matchFunction(searchConfig);
- if (!matchesQuery)
- return;
-
- this._searchResults = [];
- for (var current = this.children[0]; current; current = current.traverseNextNode(false, null, false)) {
- if (matchesQuery(current))
- this._searchResults.push({ profileNode: current });
+ function matchesQuery(profileDataGridNode) {
+ delete profileDataGridNode._searchMatchedSelfColumn;
+ delete profileDataGridNode._searchMatchedTotalColumn;
+ delete profileDataGridNode._searchMatchedFunctionColumn;
+
+ if (percentUnits) {
+ if (lessThan) {
+ if (profileDataGridNode.selfPercent < queryNumber)
+ profileDataGridNode._searchMatchedSelfColumn = true;
+ if (profileDataGridNode.totalPercent < queryNumber)
+ profileDataGridNode._searchMatchedTotalColumn = true;
+ } else if (greaterThan) {
+ if (profileDataGridNode.selfPercent > queryNumber)
+ profileDataGridNode._searchMatchedSelfColumn = true;
+ if (profileDataGridNode.totalPercent > queryNumber)
+ profileDataGridNode._searchMatchedTotalColumn = true;
}
- this._searchResultIndex = jumpBackwards ? 0 : this._searchResults.length - 1;
- this._searchableView.updateSearchMatchesCount(this._searchResults.length);
- this._searchableView.updateCurrentMatchIndex(this._searchResultIndex);
- },
- /**
- * @override
- */
- searchCanceled: function()
- {
- if (this._searchResults) {
- for (var i = 0; i < this._searchResults.length; ++i) {
- var profileNode = this._searchResults[i].profileNode;
- delete profileNode._searchMatchedSelfColumn;
- delete profileNode._searchMatchedTotalColumn;
- delete profileNode._searchMatchedFunctionColumn;
- profileNode.refresh();
- }
+ if (equalTo) {
+ if (profileDataGridNode.selfPercent === queryNumber)
+ profileDataGridNode._searchMatchedSelfColumn = true;
+ if (profileDataGridNode.totalPercent === queryNumber)
+ profileDataGridNode._searchMatchedTotalColumn = true;
+ }
+ } else if (millisecondsUnits || secondsUnits) {
+ if (lessThan) {
+ if (profileDataGridNode.self < queryNumberMilliseconds)
+ profileDataGridNode._searchMatchedSelfColumn = true;
+ if (profileDataGridNode.total < queryNumberMilliseconds)
+ profileDataGridNode._searchMatchedTotalColumn = true;
+ } else if (greaterThan) {
+ if (profileDataGridNode.self > queryNumberMilliseconds)
+ profileDataGridNode._searchMatchedSelfColumn = true;
+ if (profileDataGridNode.total > queryNumberMilliseconds)
+ profileDataGridNode._searchMatchedTotalColumn = true;
}
- this._searchResults = [];
- this._searchResultIndex = -1;
- },
-
- /**
- * @override
- */
- jumpToNextSearchResult: function()
- {
- if (!this._searchResults || !this._searchResults.length)
- return;
- this._searchResultIndex = (this._searchResultIndex + 1) % this._searchResults.length;
- this._jumpToSearchResult(this._searchResultIndex);
- },
+ if (equalTo) {
+ if (profileDataGridNode.self === queryNumberMilliseconds)
+ profileDataGridNode._searchMatchedSelfColumn = true;
+ if (profileDataGridNode.total === queryNumberMilliseconds)
+ profileDataGridNode._searchMatchedTotalColumn = true;
+ }
+ }
- /**
- * @override
- */
- jumpToPreviousSearchResult: function()
- {
- if (!this._searchResults || !this._searchResults.length)
- return;
- this._searchResultIndex = (this._searchResultIndex - 1 + this._searchResults.length) % this._searchResults.length;
- this._jumpToSearchResult(this._searchResultIndex);
- },
+ if (profileDataGridNode.functionName.match(matcher) ||
+ (profileDataGridNode.url && profileDataGridNode.url.match(matcher)))
+ profileDataGridNode._searchMatchedFunctionColumn = true;
- /**
- * @override
- * @return {boolean}
- */
- supportsCaseSensitiveSearch: function()
- {
+ if (profileDataGridNode._searchMatchedSelfColumn || profileDataGridNode._searchMatchedTotalColumn ||
+ profileDataGridNode._searchMatchedFunctionColumn) {
+ profileDataGridNode.refresh();
return true;
- },
-
- /**
- * @override
- * @return {boolean}
- */
- supportsRegexSearch: function()
- {
- return false;
- },
+ }
- /**
- * @param {number} index
- */
- _jumpToSearchResult: function(index)
- {
- var searchResult = this._searchResults[index];
- if (!searchResult)
- return;
- var profileNode = searchResult.profileNode;
- profileNode.revealAndSelect();
- this._searchableView.updateCurrentMatchIndex(index);
+ return false;
+ }
+ return matchesQuery;
+ }
+
+ /**
+ * @override
+ * @param {!WebInspector.SearchableView.SearchConfig} searchConfig
+ * @param {boolean} shouldJump
+ * @param {boolean=} jumpBackwards
+ */
+ performSearch(searchConfig, shouldJump, jumpBackwards) {
+ this.searchCanceled();
+ var matchesQuery = this._matchFunction(searchConfig);
+ if (!matchesQuery)
+ return;
+
+ this._searchResults = [];
+ for (var current = this.children[0]; current; current = current.traverseNextNode(false, null, false)) {
+ if (matchesQuery(current))
+ this._searchResults.push({profileNode: current});
}
+ this._searchResultIndex = jumpBackwards ? 0 : this._searchResults.length - 1;
+ this._searchableView.updateSearchMatchesCount(this._searchResults.length);
+ this._searchableView.updateCurrentMatchIndex(this._searchResultIndex);
+ }
+
+ /**
+ * @override
+ */
+ searchCanceled() {
+ if (this._searchResults) {
+ for (var i = 0; i < this._searchResults.length; ++i) {
+ var profileNode = this._searchResults[i].profileNode;
+ delete profileNode._searchMatchedSelfColumn;
+ delete profileNode._searchMatchedTotalColumn;
+ delete profileNode._searchMatchedFunctionColumn;
+ profileNode.refresh();
+ }
+ }
+
+ this._searchResults = [];
+ this._searchResultIndex = -1;
+ }
+
+ /**
+ * @override
+ */
+ jumpToNextSearchResult() {
+ if (!this._searchResults || !this._searchResults.length)
+ return;
+ this._searchResultIndex = (this._searchResultIndex + 1) % this._searchResults.length;
+ this._jumpToSearchResult(this._searchResultIndex);
+ }
+
+ /**
+ * @override
+ */
+ jumpToPreviousSearchResult() {
+ if (!this._searchResults || !this._searchResults.length)
+ return;
+ this._searchResultIndex = (this._searchResultIndex - 1 + this._searchResults.length) % this._searchResults.length;
+ this._jumpToSearchResult(this._searchResultIndex);
+ }
+
+ /**
+ * @override
+ * @return {boolean}
+ */
+ supportsCaseSensitiveSearch() {
+ return true;
+ }
+
+ /**
+ * @override
+ * @return {boolean}
+ */
+ supportsRegexSearch() {
+ return false;
+ }
+
+ /**
+ * @param {number} index
+ */
+ _jumpToSearchResult(index) {
+ var searchResult = this._searchResults[index];
+ if (!searchResult)
+ return;
+ var profileNode = searchResult.profileNode;
+ profileNode.revealAndSelect();
+ this._searchableView.updateCurrentMatchIndex(index);
+ }
};
WebInspector.ProfileDataGridTree.propertyComparators = [{}, {}];
-/**
- * @param {string} property
- * @param {boolean} isAscending
- * @return {function(!Object.<string, *>, !Object.<string, *>)}
- */
-WebInspector.ProfileDataGridTree.propertyComparator = function(property, isAscending)
-{
- var comparator = WebInspector.ProfileDataGridTree.propertyComparators[(isAscending ? 1 : 0)][property];
-
- if (!comparator) {
- if (isAscending) {
- comparator = function(lhs, rhs)
- {
- if (lhs[property] < rhs[property])
- return -1;
-
- if (lhs[property] > rhs[property])
- return 1;
-
- return 0;
- };
- } else {
- comparator = function(lhs, rhs)
- {
- if (lhs[property] > rhs[property])
- return -1;
-
- if (lhs[property] < rhs[property])
- return 1;
-
- return 0;
- };
- }
-
- WebInspector.ProfileDataGridTree.propertyComparators[(isAscending ? 1 : 0)][property] = comparator;
- }
-
- return comparator;
-};
/**
* @interface
*/
-WebInspector.ProfileDataGridNode.Formatter = function() { };
+WebInspector.ProfileDataGridNode.Formatter = function() {};
WebInspector.ProfileDataGridNode.Formatter.prototype = {
- /**
- * @param {number} value
- * @param {!WebInspector.ProfileDataGridNode} node
- * @return {string}
- */
- formatValue: function(value, node) { },
-
- /**
- * @param {number} value
- * @param {!WebInspector.ProfileDataGridNode} node
- * @return {string}
- */
- formatPercent: function(value, node) { },
-
- /**
- * @param {!WebInspector.ProfileDataGridNode} node
- * @return {?Element}
- */
- linkifyNode: function(node) { }
+ /**
+ * @param {number} value
+ * @param {!WebInspector.ProfileDataGridNode} node
+ * @return {string}
+ */
+ formatValue: function(value, node) {},
+
+ /**
+ * @param {number} value
+ * @param {!WebInspector.ProfileDataGridNode} node
+ * @return {string}
+ */
+ formatPercent: function(value, node) {},
+
+ /**
+ * @param {!WebInspector.ProfileDataGridNode} node
+ * @return {?Element}
+ */
+ linkifyNode: function(node) {}
};

Powered by Google App Engine
This is Rietveld 408576698