OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 document.onload = (function(d3){ | 5 document.onload = (function(d3){ |
6 "use strict"; | 6 "use strict"; |
7 var jsonObj; | 7 var jsonObj; |
8 var sourceExpandClassList = document.getElementById(SOURCE_EXPAND_ID).classLis
t; | 8 var sourceExpandClassList = document.getElementById(SOURCE_EXPAND_ID).classLis
t; |
9 var sourceCollapseClassList = document.getElementById(SOURCE_COLLAPSE_ID).clas
sList; | 9 var sourceCollapseClassList = document.getElementById(SOURCE_COLLAPSE_ID).clas
sList; |
10 var sourceExpanded = sourceCollapseClassList.contains(COLLAPSE_PANE_BUTTON_VIS
IBLE); | 10 var sourceExpanded = sourceCollapseClassList.contains(COLLAPSE_PANE_BUTTON_VIS
IBLE); |
(...skipping 26 matching lines...) Expand all Loading... |
37 d3.select("#" + INTERMEDIATE_PANE_ID).style(WIDTH, "50%"); | 37 d3.select("#" + INTERMEDIATE_PANE_ID).style(WIDTH, "50%"); |
38 d3.select("#" + GENERATED_PANE_ID).style(WIDTH, "50%"); | 38 d3.select("#" + GENERATED_PANE_ID).style(WIDTH, "50%"); |
39 } else { | 39 } else { |
40 d3.select("#" + SOURCE_PANE_ID).style(WIDTH, "0%"); | 40 d3.select("#" + SOURCE_PANE_ID).style(WIDTH, "0%"); |
41 d3.select("#" + INTERMEDIATE_PANE_ID).style(WIDTH, "100%"); | 41 d3.select("#" + INTERMEDIATE_PANE_ID).style(WIDTH, "100%"); |
42 d3.select("#" + GENERATED_PANE_ID).style(WIDTH, "0%"); | 42 d3.select("#" + GENERATED_PANE_ID).style(WIDTH, "0%"); |
43 } | 43 } |
44 } | 44 } |
45 } | 45 } |
46 | 46 |
| 47 function getLastExpandedState(type, default_state) { |
| 48 var state = window.sessionStorage.getItem("expandedState-"+type); |
| 49 if (state === null) return default_state; |
| 50 return state === 'true'; |
| 51 } |
| 52 |
| 53 function setLastExpandedState(type, state) { |
| 54 window.sessionStorage.setItem("expandedState-"+type, state); |
| 55 } |
| 56 |
47 function toggleSourceExpanded() { | 57 function toggleSourceExpanded() { |
48 setSourceExpanded(!sourceExpanded); | 58 setSourceExpanded(!sourceExpanded); |
49 } | 59 } |
50 | 60 |
51 function setSourceExpanded(newState) { | 61 function setSourceExpanded(newState) { |
52 sourceExpanded = newState; | 62 sourceExpanded = newState; |
| 63 setLastExpandedState("source", newState); |
53 updatePanes(); | 64 updatePanes(); |
54 if (newState) { | 65 if (newState) { |
55 sourceCollapseClassList.add(COLLAPSE_PANE_BUTTON_VISIBLE); | 66 sourceCollapseClassList.add(COLLAPSE_PANE_BUTTON_VISIBLE); |
56 sourceCollapseClassList.remove(COLLAPSE_PANE_BUTTON_INVISIBLE); | 67 sourceCollapseClassList.remove(COLLAPSE_PANE_BUTTON_INVISIBLE); |
57 sourceExpandClassList.add(COLLAPSE_PANE_BUTTON_INVISIBLE); | 68 sourceExpandClassList.add(COLLAPSE_PANE_BUTTON_INVISIBLE); |
58 sourceExpandClassList.remove(COLLAPSE_PANE_BUTTON_VISIBLE); | 69 sourceExpandClassList.remove(COLLAPSE_PANE_BUTTON_VISIBLE); |
59 } else { | 70 } else { |
60 sourceCollapseClassList.add(COLLAPSE_PANE_BUTTON_INVISIBLE); | 71 sourceCollapseClassList.add(COLLAPSE_PANE_BUTTON_INVISIBLE); |
61 sourceCollapseClassList.remove(COLLAPSE_PANE_BUTTON_VISIBLE); | 72 sourceCollapseClassList.remove(COLLAPSE_PANE_BUTTON_VISIBLE); |
62 sourceExpandClassList.add(COLLAPSE_PANE_BUTTON_VISIBLE); | 73 sourceExpandClassList.add(COLLAPSE_PANE_BUTTON_VISIBLE); |
63 sourceExpandClassList.remove(COLLAPSE_PANE_BUTTON_INVISIBLE); | 74 sourceExpandClassList.remove(COLLAPSE_PANE_BUTTON_INVISIBLE); |
64 } | 75 } |
65 } | 76 } |
66 | 77 |
67 function toggleDisassemblyExpanded() { | 78 function toggleDisassemblyExpanded() { |
68 setDisassemblyExpanded(!disassemblyExpanded); | 79 setDisassemblyExpanded(!disassemblyExpanded); |
69 } | 80 } |
70 | 81 |
71 function setDisassemblyExpanded(newState) { | 82 function setDisassemblyExpanded(newState) { |
72 disassemblyExpanded = newState; | 83 disassemblyExpanded = newState; |
| 84 setLastExpandedState("disassembly", newState); |
73 updatePanes(); | 85 updatePanes(); |
74 if (newState) { | 86 if (newState) { |
75 disassemblyCollapseClassList.add(COLLAPSE_PANE_BUTTON_VISIBLE); | 87 disassemblyCollapseClassList.add(COLLAPSE_PANE_BUTTON_VISIBLE); |
76 disassemblyCollapseClassList.remove(COLLAPSE_PANE_BUTTON_INVISIBLE); | 88 disassemblyCollapseClassList.remove(COLLAPSE_PANE_BUTTON_INVISIBLE); |
77 disassemblyExpandClassList.add(COLLAPSE_PANE_BUTTON_INVISIBLE); | 89 disassemblyExpandClassList.add(COLLAPSE_PANE_BUTTON_INVISIBLE); |
78 disassemblyExpandClassList.remove(COLLAPSE_PANE_BUTTON_VISIBLE); | 90 disassemblyExpandClassList.remove(COLLAPSE_PANE_BUTTON_VISIBLE); |
79 } else { | 91 } else { |
80 disassemblyCollapseClassList.add(COLLAPSE_PANE_BUTTON_INVISIBLE); | 92 disassemblyCollapseClassList.add(COLLAPSE_PANE_BUTTON_INVISIBLE); |
81 disassemblyCollapseClassList.remove(COLLAPSE_PANE_BUTTON_VISIBLE); | 93 disassemblyCollapseClassList.remove(COLLAPSE_PANE_BUTTON_VISIBLE); |
82 disassemblyExpandClassList.add(COLLAPSE_PANE_BUTTON_VISIBLE); | 94 disassemblyExpandClassList.add(COLLAPSE_PANE_BUTTON_VISIBLE); |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 optionElement.text = jsonObj.phases[i].name; | 180 optionElement.text = jsonObj.phases[i].name; |
169 if (optionElement.text == 'disassembly') { | 181 if (optionElement.text == 'disassembly') { |
170 disassemblyPhase = jsonObj.phases[i]; | 182 disassemblyPhase = jsonObj.phases[i]; |
171 } else { | 183 } else { |
172 selectMenu.add(optionElement, null); | 184 selectMenu.add(optionElement, null); |
173 } | 185 } |
174 } | 186 } |
175 disassemblyView.setNodePositionMap(jsonObj.nodePositions); | 187 disassemblyView.setNodePositionMap(jsonObj.nodePositions); |
176 disassemblyView.show(disassemblyPhase.data, null); | 188 disassemblyView.show(disassemblyPhase.data, null); |
177 | 189 |
| 190 var initialPhaseIndex = +window.sessionStorage.getItem("lastSelected
Phase"); |
| 191 if (!(initialPhaseIndex in jsonObj.phases)) { |
| 192 initialPhaseIndex = 0; |
| 193 } |
| 194 |
| 195 // We wish to show the remembered phase {lastSelectedPhase}, but |
| 196 // this will crash if the first view we switch to is a |
| 197 // ScheduleView. So we first switch to the first phase, which |
| 198 // should never be a ScheduleView. |
178 displayPhase(jsonObj.phases[0]); | 199 displayPhase(jsonObj.phases[0]); |
| 200 displayPhase(jsonObj.phases[initialPhaseIndex]); |
| 201 selectMenu.selectedIndex = initialPhaseIndex; |
179 | 202 |
180 selectMenu.onchange = function(item) { | 203 selectMenu.onchange = function(item) { |
| 204 window.sessionStorage.setItem("lastSelectedPhase", selectMenu.sele
ctedIndex); |
181 displayPhase(jsonObj.phases[selectMenu.selectedIndex]); | 205 displayPhase(jsonObj.phases[selectMenu.selectedIndex]); |
182 } | 206 } |
183 | 207 |
184 fitPanesToParents(); | 208 fitPanesToParents(); |
| 209 |
| 210 d3.select("#search-input").attr("value", window.sessionStorage.getIt
em("lastSearch") || ""); |
| 211 |
185 } | 212 } |
186 catch(err) { | 213 catch(err) { |
| 214 window.console.log("caught exception, clearing session storage just
in case"); |
| 215 window.sessionStorage.clear(); // just in case |
| 216 window.console.log("showing error"); |
187 window.alert("Invalid TurboFan JSON file\n" + | 217 window.alert("Invalid TurboFan JSON file\n" + |
188 "error: " + err.message); | 218 "error: " + err.message); |
189 return; | 219 return; |
190 } | 220 } |
191 }; | 221 }; |
192 filereader.readAsText(uploadFile); | 222 filereader.readAsText(uploadFile); |
193 } else { | 223 } else { |
194 alert("Can't load graph"); | 224 alert("Can't load graph"); |
195 } | 225 } |
196 }); | 226 }); |
197 } | 227 } |
198 | 228 |
199 sourceView = new CodeView(SOURCE_PANE_ID, PR, "", 0, selectionBroker); | 229 sourceView = new CodeView(SOURCE_PANE_ID, PR, "", 0, selectionBroker); |
200 disassemblyView = new DisassemblyView(DISASSEMBLY_PANE_ID, selectionBroker); | 230 disassemblyView = new DisassemblyView(DISASSEMBLY_PANE_ID, selectionBroker); |
201 graph = new GraphView(d3, GRAPH_PANE_ID, [], [], selectionBroker); | 231 graph = new GraphView(d3, GRAPH_PANE_ID, [], [], selectionBroker); |
202 schedule = new ScheduleView(SCHEDULE_PANE_ID, selectionBroker); | 232 schedule = new ScheduleView(SCHEDULE_PANE_ID, selectionBroker); |
203 empty = new EmptyView(EMPTY_PANE_ID, selectionBroker); | 233 empty = new EmptyView(EMPTY_PANE_ID, selectionBroker); |
204 | 234 |
205 initializeHandlers(graph); | 235 initializeHandlers(graph); |
206 | 236 |
207 setSourceExpanded(true); | 237 setSourceExpanded(getLastExpandedState("source", true)); |
208 setDisassemblyExpanded(false); | 238 setDisassemblyExpanded(getLastExpandedState("disassembly", false)); |
209 | 239 |
210 displayPhaseView(empty, null); | 240 displayPhaseView(empty, null); |
211 fitPanesToParents(); | 241 fitPanesToParents(); |
212 })(window.d3); | 242 })(window.d3); |
OLD | NEW |