📄 profileview.js
字号:
if (!this._searchResults || !this._searchResults.length) return; if (++this._currentSearchResultIndex >= this._searchResults.length) this._currentSearchResultIndex = 0; this._jumpToSearchResult(this._currentSearchResultIndex); }, jumpToPreviousSearchResult: function() { if (!this._searchResults || !this._searchResults.length) return; if (--this._currentSearchResultIndex < 0) this._currentSearchResultIndex = (this._searchResults.length - 1); this._jumpToSearchResult(this._currentSearchResultIndex); }, showingFirstSearchResult: function() { return (this._currentSearchResultIndex === 0); }, showingLastSearchResult: function() { return (this._searchResults && this._currentSearchResultIndex === (this._searchResults.length - 1)); }, _jumpToSearchResult: function(index) { var searchResult = this._searchResults[index]; if (!searchResult) return; var profileNode = this._searchResults[index].profileNode; if (!profileNode._dataGridNode && searchResult.ancestors) { var ancestors = searchResult.ancestors; for (var i = 0; i < ancestors.length; ++i) { var ancestorProfileNode = ancestors[i]; var gridNode = ancestorProfileNode._dataGridNode; if (gridNode) gridNode.expand(); } // No need to keep the ancestors around. delete searchResult.ancestors; } gridNode = profileNode._dataGridNode; if (!gridNode) return; gridNode.reveal(); gridNode.select(); }, _changeView: function(event) { if (!event || !this.profile) return; if (event.target.selectedIndex == 1 && this.view == "Heavy") { this._sortProfile(this.profile.treeProfile); this.profile = this.profile.treeProfile; this.view = "Tree"; } else if (event.target.selectedIndex == 0 && this.view == "Tree") { this._sortProfile(this.profile.heavyProfile); this.profile = this.profile.heavyProfile; this.view = "Heavy"; } if (!this.currentQuery || !this._searchFinishedCallback || !this._searchResults) return; // The current search needs to be performed again. First negate out previous match // count by calling the search finished callback with a negative number of matches. // Then perform the search again the with same query and callback. this._searchFinishedCallback(this, -this._searchResults.length); this.performSearch(this.currentQuery, this._searchFinishedCallback); }, _percentClicked: function(event) { var currentState = this.showSelfTimeAsPercent && this.showTotalTimeAsPercent; this.showSelfTimeAsPercent = !currentState; this.showTotalTimeAsPercent = !currentState; this.refreshShowAsPercents(); }, _updatePercentButton: function() { if (this.showSelfTimeAsPercent && this.showTotalTimeAsPercent) { this.percentButton.title = WebInspector.UIString("Show absolute total and self times."); this.percentButton.addStyleClass("toggled-on"); } else { this.percentButton.title = WebInspector.UIString("Show total and self times as percentages."); this.percentButton.removeStyleClass("toggled-on"); } }, _focusClicked: function(event) { if (!this.dataGrid.selectedNode || !this.dataGrid.selectedNode.profileNode) return; this.resetButton.removeStyleClass("hidden"); this.profile.focus(this.dataGrid.selectedNode.profileNode); this.refresh(); }, _excludeClicked: function(event) { if (!this.dataGrid.selectedNode || !this.dataGrid.selectedNode.profileNode) return; this.resetButton.removeStyleClass("hidden"); this.profile.exclude(this.dataGrid.selectedNode.profileNode); this.dataGrid.selectedNode.deselect(); this.refresh(); }, _resetClicked: function(event) { this.resetButton.addStyleClass("hidden"); this.profile.restoreAll(); this.refresh(); }, _dataGridNodeSelected: function(node) { this.focusButton.disabled = false; this.excludeButton.disabled = false; }, _dataGridNodeDeselected: function(node) { this.focusButton.disabled = true; this.excludeButton.disabled = true; }, _sortData: function(event) { this._sortProfile(this.profile); }, _sortProfile: function(profile) { if (!profile) return; var sortOrder = this.dataGrid.sortOrder; var sortColumnIdentifier = this.dataGrid.sortColumnIdentifier; var sortingFunctionName = "sort"; if (sortColumnIdentifier === "self") sortingFunctionName += "SelfTime"; else if (sortColumnIdentifier === "total") sortingFunctionName += "TotalTime"; else if (sortColumnIdentifier === "calls") sortingFunctionName += "Calls"; else if (sortColumnIdentifier === "function") sortingFunctionName += "FunctionName"; if (sortOrder === "ascending") sortingFunctionName += "Ascending"; else sortingFunctionName += "Descending"; if (!(sortingFunctionName in this.profile)) return; profile[sortingFunctionName](); if (profile === this.profile) this.refresh(); }, _mouseDownInDataGrid: function(event) { if (event.detail < 2) return; var cell = event.target.enclosingNodeOrSelfWithNodeName("td"); if (!cell || (!cell.hasStyleClass("total-column") && !cell.hasStyleClass("self-column"))) return; if (cell.hasStyleClass("total-column")) this.showTotalTimeAsPercent = !this.showTotalTimeAsPercent; else if (cell.hasStyleClass("self-column")) this.showSelfTimeAsPercent = !this.showSelfTimeAsPercent; this.refreshShowAsPercents(); event.preventDefault(); event.stopPropagation(); }}WebInspector.ProfileView.prototype.__proto__ = WebInspector.View.prototype;WebInspector.ProfileDataGridNode = function(profileView, profileNode){ this.profileView = profileView; this.profileNode = profileNode; profileNode._dataGridNode = this; // Find the first child that is visible. Since we don't want to claim // we have children if all the children are invisible. var hasChildren = false; var children = this.profileNode.children; var childrenLength = children.length; for (var i = 0; i < childrenLength; ++i) { if (children[i].visible) { hasChildren = true; break; } } WebInspector.DataGridNode.call(this, null, hasChildren); this.addEventListener("populate", this._populate, this); this.expanded = profileNode._expanded;}WebInspector.ProfileDataGridNode.prototype = { get data() { function formatMilliseconds(time) { return Number.secondsToString(time / 1000, WebInspector.UIString.bind(WebInspector), true); } var data = {}; data["function"] = this.profileNode.functionName; data["calls"] = this.profileNode.numberOfCalls; if (this.profileView.showSelfTimeAsPercent) data["self"] = WebInspector.UIString("%.2f%%", this.profileNode.selfPercent); else data["self"] = formatMilliseconds(this.profileNode.selfTime); if (this.profileView.showTotalTimeAsPercent) data["total"] = WebInspector.UIString("%.2f%%", this.profileNode.totalPercent); else data["total"] = formatMilliseconds(this.profileNode.totalTime); return data; }, createCell: function(columnIdentifier) { var cell = WebInspector.DataGridNode.prototype.createCell.call(this, columnIdentifier); if (columnIdentifier === "self" && this.profileNode._searchMatchedSelfColumn) cell.addStyleClass("highlight"); else if (columnIdentifier === "total" && this.profileNode._searchMatchedTotalColumn) cell.addStyleClass("highlight"); else if (columnIdentifier === "calls" && this.profileNode._searchMatchedCallsColumn) cell.addStyleClass("highlight"); if (columnIdentifier !== "function") return cell; if (this.profileNode._searchMatchedFunctionColumn) cell.addStyleClass("highlight"); if (this.profileNode.url) { var fileName = WebInspector.displayNameForURL(this.profileNode.url); var urlElement = document.createElement("a"); urlElement.className = "profile-node-file webkit-html-resource-link"; urlElement.href = this.profileNode.url; urlElement.lineNumber = this.profileNode.lineNumber; if (this.profileNode.lineNumber > 0) urlElement.textContent = fileName + ":" + this.profileNode.lineNumber; else urlElement.textContent = fileName; cell.insertBefore(urlElement, cell.firstChild); } return cell; }, select: function(supressSelectedEvent) { WebInspector.DataGridNode.prototype.select.call(this, supressSelectedEvent); this.profileView._dataGridNodeSelected(this); }, deselect: function(supressDeselectedEvent) { WebInspector.DataGridNode.prototype.deselect.call(this, supressDeselectedEvent); this.profileView._dataGridNodeDeselected(this); }, expand: function() { WebInspector.DataGridNode.prototype.expand.call(this); this.profileNode._expanded = true; }, collapse: function() { WebInspector.DataGridNode.prototype.collapse.call(this); this.profileNode._expanded = false; }, _populate: function(event) { var children = this.profileNode.children; var childrenLength = children.length; for (var i = 0; i < childrenLength; ++i) if (children[i].visible) this.appendChild(new WebInspector.ProfileDataGridNode(this.profileView, children[i])); this.removeEventListener("populate", this._populate, this); }}WebInspector.ProfileDataGridNode.prototype.__proto__ = WebInspector.DataGridNode.prototype;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -