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

Unified Diff: tools/turbolizer/turbo-visualizer.js

Issue 2171543004: [turbolizer] Remember the last phase, search query, and pane expansions. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@t-p6
Patch Set: Fix bug in remembering pane state. Created 4 years, 5 months 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
« no previous file with comments | « tools/turbolizer/graph-view.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/turbolizer/turbo-visualizer.js
diff --git a/tools/turbolizer/turbo-visualizer.js b/tools/turbolizer/turbo-visualizer.js
index 96ab59d2f626593f093d8e844910cebc4df8a833..f39b5121656069a6e51059ff60c516e4a0d950d9 100644
--- a/tools/turbolizer/turbo-visualizer.js
+++ b/tools/turbolizer/turbo-visualizer.js
@@ -44,12 +44,23 @@ document.onload = (function(d3){
}
}
+ function getLastExpandedState(type, default_state) {
+ var state = window.sessionStorage.getItem("expandedState-"+type);
+ if (state === null) return default_state;
+ return state === 'true';
+ }
+
+ function setLastExpandedState(type, state) {
+ window.sessionStorage.setItem("expandedState-"+type, state);
+ }
+
function toggleSourceExpanded() {
setSourceExpanded(!sourceExpanded);
}
function setSourceExpanded(newState) {
sourceExpanded = newState;
+ setLastExpandedState("source", newState);
updatePanes();
if (newState) {
sourceCollapseClassList.add(COLLAPSE_PANE_BUTTON_VISIBLE);
@@ -70,6 +81,7 @@ document.onload = (function(d3){
function setDisassemblyExpanded(newState) {
disassemblyExpanded = newState;
+ setLastExpandedState("disassembly", newState);
updatePanes();
if (newState) {
disassemblyCollapseClassList.add(COLLAPSE_PANE_BUTTON_VISIBLE);
@@ -175,15 +187,33 @@ document.onload = (function(d3){
disassemblyView.setNodePositionMap(jsonObj.nodePositions);
disassemblyView.show(disassemblyPhase.data, null);
+ var initialPhaseIndex = +window.sessionStorage.getItem("lastSelectedPhase");
+ if (!(initialPhaseIndex in jsonObj.phases)) {
+ initialPhaseIndex = 0;
+ }
+
+ // We wish to show the remembered phase {lastSelectedPhase}, but
+ // this will crash if the first view we switch to is a
+ // ScheduleView. So we first switch to the first phase, which
+ // should never be a ScheduleView.
displayPhase(jsonObj.phases[0]);
+ displayPhase(jsonObj.phases[initialPhaseIndex]);
+ selectMenu.selectedIndex = initialPhaseIndex;
selectMenu.onchange = function(item) {
+ window.sessionStorage.setItem("lastSelectedPhase", selectMenu.selectedIndex);
displayPhase(jsonObj.phases[selectMenu.selectedIndex]);
}
fitPanesToParents();
+
+ d3.select("#search-input").attr("value", window.sessionStorage.getItem("lastSearch") || "");
+
}
catch(err) {
+ window.console.log("caught exception, clearing session storage just in case");
+ window.sessionStorage.clear(); // just in case
+ window.console.log("showing error");
window.alert("Invalid TurboFan JSON file\n" +
"error: " + err.message);
return;
@@ -204,8 +234,8 @@ document.onload = (function(d3){
initializeHandlers(graph);
- setSourceExpanded(true);
- setDisassemblyExpanded(false);
+ setSourceExpanded(getLastExpandedState("source", true));
+ setDisassemblyExpanded(getLastExpandedState("disassembly", false));
displayPhaseView(empty, null);
fitPanesToParents();
« no previous file with comments | « tools/turbolizer/graph-view.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698