Chromium Code Reviews| Index: tools/turbolizer/turbo-visualizer.js |
| diff --git a/tools/turbolizer/turbo-visualizer.js b/tools/turbolizer/turbo-visualizer.js |
| index 96ab59d2f626593f093d8e844910cebc4df8a833..6cbcf14abdd5e3670e2bcea65287941862f7e4b7 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 === undefined) 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); |
|
danno
2016/07/25 14:00:49
Here and below, why still pass the second boolean?
bgeron
2016/07/25 17:29:50
Oops, I forgot that there was a bug there! Should
|
| + setDisassemblyExpanded(getLastExpandedState("disassembly"), false); |
| displayPhaseView(empty, null); |
| fitPanesToParents(); |