OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. | 2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. |
3 * Copyright (C) 2011 Google Inc. All rights reserved. | 3 * Copyright (C) 2011 Google Inc. All rights reserved. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
7 * are met: | 7 * are met: |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 28 matching lines...) Expand all Loading... |
39 importScript("SourcesNavigator.js"); | 39 importScript("SourcesNavigator.js"); |
40 importScript("SourcesSearchScope.js"); | 40 importScript("SourcesSearchScope.js"); |
41 importScript("StyleSheetOutlineDialog.js"); | 41 importScript("StyleSheetOutlineDialog.js"); |
42 importScript("TabbedEditorContainer.js"); | 42 importScript("TabbedEditorContainer.js"); |
43 importScript("WatchExpressionsSidebarPane.js"); | 43 importScript("WatchExpressionsSidebarPane.js"); |
44 importScript("WorkersSidebarPane.js"); | 44 importScript("WorkersSidebarPane.js"); |
45 importScript("ThreadsToolbar.js"); | 45 importScript("ThreadsToolbar.js"); |
46 importScript("ScriptFormatterEditorAction.js"); | 46 importScript("ScriptFormatterEditorAction.js"); |
47 importScript("InplaceFormatterEditorAction.js"); | 47 importScript("InplaceFormatterEditorAction.js"); |
48 importScript("ScriptFormatter.js"); | 48 importScript("ScriptFormatter.js"); |
| 49 importScript("SourcesEditor.js"); |
49 | 50 |
50 /** | 51 /** |
51 * @constructor | 52 * @constructor |
52 * @implements {WebInspector.TabbedEditorContainerDelegate} | |
53 * @implements {WebInspector.ContextMenu.Provider} | 53 * @implements {WebInspector.ContextMenu.Provider} |
54 * @implements {WebInspector.Searchable} | |
55 * @implements {WebInspector.Replaceable} | |
56 * @extends {WebInspector.Panel} | 54 * @extends {WebInspector.Panel} |
57 * @param {!WebInspector.Workspace=} workspaceForTest | 55 * @param {!WebInspector.Workspace=} workspaceForTest |
58 */ | 56 */ |
59 WebInspector.SourcesPanel = function(workspaceForTest) | 57 WebInspector.SourcesPanel = function(workspaceForTest) |
60 { | 58 { |
61 WebInspector.Panel.call(this, "sources"); | 59 WebInspector.Panel.call(this, "sources"); |
62 this.registerRequiredCSS("sourcesPanel.css"); | 60 this.registerRequiredCSS("sourcesPanel.css"); |
63 this.registerRequiredCSS("textPrompt.css"); // Watch Expressions autocomplet
e. | 61 this.registerRequiredCSS("textPrompt.css"); // Watch Expressions autocomplet
e. |
64 | 62 |
65 WebInspector.settings.showEditorInDrawer = WebInspector.settings.createSetti
ng("showEditorInDrawer", true); | 63 WebInspector.settings.showEditorInDrawer = WebInspector.settings.createSetti
ng("showEditorInDrawer", true); |
(...skipping 19 matching lines...) Expand all Loading... |
85 this.editorView.enableShowModeSaving(); | 83 this.editorView.enableShowModeSaving(); |
86 this.editorView.element.id = "scripts-editor-split-view"; | 84 this.editorView.element.id = "scripts-editor-split-view"; |
87 this.editorView.element.tabIndex = 0; | 85 this.editorView.element.tabIndex = 0; |
88 | 86 |
89 this.editorView.setSidebarElementConstraints(Preferences.minSidebarWidth); | 87 this.editorView.setSidebarElementConstraints(Preferences.minSidebarWidth); |
90 this.editorView.setMainElementConstraints(50, 50); | 88 this.editorView.setMainElementConstraints(50, 50); |
91 this.editorView.show(this._splitView.mainElement()); | 89 this.editorView.show(this._splitView.mainElement()); |
92 | 90 |
93 this._navigator = new WebInspector.SourcesNavigator(this._workspace); | 91 this._navigator = new WebInspector.SourcesNavigator(this._workspace); |
94 this._navigator.view.show(this.editorView.sidebarElement()); | 92 this._navigator.view.show(this.editorView.sidebarElement()); |
95 | |
96 var tabbedEditorPlaceholderText = WebInspector.isMac() ? WebInspector.UIStri
ng("Hit Cmd+O to open a file") : WebInspector.UIString("Hit Ctrl+O to open a fil
e"); | |
97 | |
98 this._drawerEditorView = new WebInspector.SourcesPanel.DrawerEditorView(); | |
99 this.sourcesView = new WebInspector.SourcesView(); | |
100 this.sourcesView.show(this._drawerEditorView.element); | |
101 | |
102 this._searchableView = new WebInspector.SearchableView(this); | |
103 this._searchableView.setMinimalSearchQuerySize(0); | |
104 this._searchableView.show(this.sourcesView.element); | |
105 | |
106 this._editorContainer = new WebInspector.TabbedEditorContainer(this, "previo
uslyViewedFiles", tabbedEditorPlaceholderText); | |
107 this._editorContainer.show(this._searchableView.element); | |
108 | |
109 this._navigator.addEventListener(WebInspector.SourcesNavigator.Events.Source
Selected, this._sourceSelected, this); | 93 this._navigator.addEventListener(WebInspector.SourcesNavigator.Events.Source
Selected, this._sourceSelected, this); |
110 this._navigator.addEventListener(WebInspector.SourcesNavigator.Events.Source
Renamed, this._sourceRenamed, this); | 94 this._navigator.addEventListener(WebInspector.SourcesNavigator.Events.Source
Renamed, this._sourceRenamed, this); |
111 | 95 |
112 this._editorContainer.addEventListener(WebInspector.TabbedEditorContainer.Ev
ents.EditorSelected, this._editorSelected, this); | 96 this._sourcesEditor = new WebInspector.SourcesEditor(this._workspace, this); |
113 this._editorContainer.addEventListener(WebInspector.TabbedEditorContainer.Ev
ents.EditorClosed, this._editorClosed, this); | 97 this._sourcesEditor.addEventListener(WebInspector.SourcesEditor.Events.Edito
rSelected, this._editorSelected.bind(this)); |
| 98 this._sourcesEditor.addEventListener(WebInspector.SourcesEditor.Events.Edito
rClosed, this._editorClosed.bind(this)); |
| 99 this._sourcesEditor.registerShortcuts(this.registerShortcuts.bind(this)); |
| 100 |
| 101 this._drawerEditorView = new WebInspector.SourcesPanel.DrawerEditorView(); |
| 102 this._sourcesEditor.sourcesView().show(this._drawerEditorView.element); |
114 | 103 |
115 this._debugSidebarResizeWidgetElement = document.createElementWithClass("div
", "resizer-widget"); | 104 this._debugSidebarResizeWidgetElement = document.createElementWithClass("div
", "resizer-widget"); |
116 this._debugSidebarResizeWidgetElement.id = "scripts-debug-sidebar-resizer-wi
dget"; | 105 this._debugSidebarResizeWidgetElement.id = "scripts-debug-sidebar-resizer-wi
dget"; |
117 this._splitView.addEventListener(WebInspector.SplitView.Events.ShowModeChang
ed, this._updateDebugSidebarResizeWidget, this); | 106 this._splitView.addEventListener(WebInspector.SplitView.Events.ShowModeChang
ed, this._updateDebugSidebarResizeWidget, this); |
118 this._updateDebugSidebarResizeWidget(); | 107 this._updateDebugSidebarResizeWidget(); |
119 this._splitView.installResizer(this._debugSidebarResizeWidgetElement); | 108 this._splitView.installResizer(this._debugSidebarResizeWidgetElement); |
120 | 109 |
121 this.sidebarPanes = {}; | 110 this.sidebarPanes = {}; |
122 this.sidebarPanes.watchExpressions = new WebInspector.WatchExpressionsSideba
rPane(); | 111 this.sidebarPanes.watchExpressions = new WebInspector.WatchExpressionsSideba
rPane(); |
123 this.sidebarPanes.callstack = new WebInspector.CallStackSidebarPane(); | 112 this.sidebarPanes.callstack = new WebInspector.CallStackSidebarPane(); |
124 this.sidebarPanes.callstack.addEventListener(WebInspector.CallStackSidebarPa
ne.Events.CallFrameSelected, this._callFrameSelectedInSidebar.bind(this)); | 113 this.sidebarPanes.callstack.addEventListener(WebInspector.CallStackSidebarPa
ne.Events.CallFrameSelected, this._callFrameSelectedInSidebar.bind(this)); |
125 this.sidebarPanes.callstack.addEventListener(WebInspector.CallStackSidebarPa
ne.Events.CallFrameRestarted, this._callFrameRestartedInSidebar.bind(this)); | 114 this.sidebarPanes.callstack.addEventListener(WebInspector.CallStackSidebarPa
ne.Events.CallFrameRestarted, this._callFrameRestartedInSidebar.bind(this)); |
| 115 this.sidebarPanes.callstack.registerShortcuts(this.registerShortcuts.bind(th
is)); |
126 | 116 |
127 this.sidebarPanes.scopechain = new WebInspector.ScopeChainSidebarPane(); | 117 this.sidebarPanes.scopechain = new WebInspector.ScopeChainSidebarPane(); |
128 this.sidebarPanes.jsBreakpoints = new WebInspector.JavaScriptBreakpointsSide
barPane(WebInspector.debuggerModel, WebInspector.breakpointManager, this._showSo
urceLocation.bind(this)); | 118 this.sidebarPanes.jsBreakpoints = new WebInspector.JavaScriptBreakpointsSide
barPane(WebInspector.debuggerModel, WebInspector.breakpointManager, this.showUIS
ourceCode.bind(this)); |
129 this.sidebarPanes.domBreakpoints = WebInspector.domBreakpointsSidebarPane.cr
eateProxy(this); | 119 this.sidebarPanes.domBreakpoints = WebInspector.domBreakpointsSidebarPane.cr
eateProxy(this); |
130 this.sidebarPanes.xhrBreakpoints = new WebInspector.XHRBreakpointsSidebarPan
e(); | 120 this.sidebarPanes.xhrBreakpoints = new WebInspector.XHRBreakpointsSidebarPan
e(); |
131 this.sidebarPanes.eventListenerBreakpoints = new WebInspector.EventListenerB
reakpointsSidebarPane(); | 121 this.sidebarPanes.eventListenerBreakpoints = new WebInspector.EventListenerB
reakpointsSidebarPane(); |
132 | 122 |
133 if (Capabilities.isMainFrontend) | 123 if (Capabilities.isMainFrontend) |
134 this.sidebarPanes.workerList = new WebInspector.WorkersSidebarPane(); | 124 this.sidebarPanes.workerList = new WebInspector.WorkersSidebarPane(); |
135 | 125 |
136 this._historyManager = new WebInspector.EditingLocationHistoryManager(this,
this.currentSourceFrame.bind(this)); | |
137 this.registerShortcuts(WebInspector.ShortcutsScreen.SourcesPanelShortcuts.Ju
mpToPreviousLocation, this._onJumpToPreviousLocation.bind(this)); | |
138 this.registerShortcuts(WebInspector.ShortcutsScreen.SourcesPanelShortcuts.Ju
mpToNextLocation, this._onJumpToNextLocation.bind(this)); | |
139 this.registerShortcuts(WebInspector.ShortcutsScreen.SourcesPanelShortcuts.Cl
oseEditorTab, this._onCloseEditorTab.bind(this)); | |
140 | |
141 this.sidebarPanes.callstack.registerShortcuts(this.registerShortcuts.bind(th
is)); | |
142 this.registerShortcuts(WebInspector.ShortcutsScreen.SourcesPanelShortcuts.Go
ToLine, this._showGoToLineDialog.bind(this)); | |
143 this.registerShortcuts(WebInspector.ShortcutsScreen.SourcesPanelShortcuts.Go
ToMember, this._showOutlineDialog.bind(this)); | |
144 this.registerShortcuts(WebInspector.ShortcutsScreen.SourcesPanelShortcuts.To
ggleBreakpoint, this._toggleBreakpoint.bind(this)); | |
145 | |
146 this._extensionSidebarPanes = []; | 126 this._extensionSidebarPanes = []; |
147 | 127 |
148 this._scriptViewStatusBarItemsContainer = document.createElement("div"); | |
149 this._scriptViewStatusBarItemsContainer.className = "inline-block"; | |
150 | |
151 this._scriptViewStatusBarTextContainer = document.createElement("div"); | |
152 this._scriptViewStatusBarTextContainer.className = "hbox"; | |
153 | |
154 this._statusBarContainerElement = this.sourcesView.element.createChild("div"
, "sources-status-bar"); | |
155 | |
156 /** | |
157 * @this {WebInspector.SourcesPanel} | |
158 * @param {!WebInspector.SourcesPanel.EditorAction} EditorAction | |
159 */ | |
160 function appendButtonForExtension(EditorAction) | |
161 { | |
162 this._statusBarContainerElement.appendChild(EditorAction.button(this)); | |
163 } | |
164 var editorActions = /** @type {!Array.<!WebInspector.SourcesPanel.EditorActi
on>} */ (WebInspector.moduleManager.instances(WebInspector.SourcesPanel.EditorAc
tion)); | |
165 editorActions.forEach(appendButtonForExtension.bind(this)); | |
166 | |
167 this._statusBarContainerElement.appendChild(this._scriptViewStatusBarItemsCo
ntainer); | |
168 this._statusBarContainerElement.appendChild(this._scriptViewStatusBarTextCon
tainer); | |
169 | |
170 this._installDebuggerSidebarController(); | 128 this._installDebuggerSidebarController(); |
171 | 129 |
172 WebInspector.dockController.addEventListener(WebInspector.DockController.Eve
nts.DockSideChanged, this._dockSideChanged.bind(this)); | 130 WebInspector.dockController.addEventListener(WebInspector.DockController.Eve
nts.DockSideChanged, this._dockSideChanged.bind(this)); |
173 WebInspector.settings.splitVerticallyWhenDockedToRight.addChangeListener(thi
s._dockSideChanged.bind(this)); | 131 WebInspector.settings.splitVerticallyWhenDockedToRight.addChangeListener(thi
s._dockSideChanged.bind(this)); |
174 this._dockSideChanged(); | 132 this._dockSideChanged(); |
175 | 133 |
176 /** @type {!Map.<!WebInspector.UISourceCode, !WebInspector.SourceFrame>} */ | |
177 this._sourceFramesByUISourceCode = new Map(); | |
178 this._updateDebuggerButtons(); | 134 this._updateDebuggerButtons(); |
179 this._pauseOnExceptionEnabledChanged(); | 135 this._pauseOnExceptionEnabledChanged(); |
180 if (WebInspector.debuggerModel.isPaused()) | 136 if (WebInspector.debuggerModel.isPaused()) |
181 this._showDebuggerPausedDetails(); | 137 this._showDebuggerPausedDetails(); |
182 | 138 |
183 WebInspector.settings.pauseOnExceptionEnabled.addChangeListener(this._pauseO
nExceptionEnabledChanged, this); | 139 WebInspector.settings.pauseOnExceptionEnabled.addChangeListener(this._pauseO
nExceptionEnabledChanged, this); |
184 WebInspector.debuggerModel.addEventListener(WebInspector.DebuggerModel.Event
s.DebuggerWasEnabled, this._debuggerWasEnabled, this); | 140 WebInspector.debuggerModel.addEventListener(WebInspector.DebuggerModel.Event
s.DebuggerWasEnabled, this._debuggerWasEnabled, this); |
185 WebInspector.debuggerModel.addEventListener(WebInspector.DebuggerModel.Event
s.DebuggerWasDisabled, this._debuggerWasDisabled, this); | 141 WebInspector.debuggerModel.addEventListener(WebInspector.DebuggerModel.Event
s.DebuggerWasDisabled, this._debuggerWasDisabled, this); |
186 WebInspector.debuggerModel.addEventListener(WebInspector.DebuggerModel.Event
s.DebuggerPaused, this._debuggerPaused, this); | 142 WebInspector.debuggerModel.addEventListener(WebInspector.DebuggerModel.Event
s.DebuggerPaused, this._debuggerPaused, this); |
187 WebInspector.debuggerModel.addEventListener(WebInspector.DebuggerModel.Event
s.DebuggerResumed, this._debuggerResumed, this); | 143 WebInspector.debuggerModel.addEventListener(WebInspector.DebuggerModel.Event
s.DebuggerResumed, this._debuggerResumed, this); |
188 WebInspector.debuggerModel.addEventListener(WebInspector.DebuggerModel.Event
s.CallFrameSelected, this._callFrameSelected, this); | 144 WebInspector.debuggerModel.addEventListener(WebInspector.DebuggerModel.Event
s.CallFrameSelected, this._callFrameSelected, this); |
189 WebInspector.debuggerModel.addEventListener(WebInspector.DebuggerModel.Event
s.ConsoleCommandEvaluatedInSelectedCallFrame, this._consoleCommandEvaluatedInSel
ectedCallFrame, this); | 145 WebInspector.debuggerModel.addEventListener(WebInspector.DebuggerModel.Event
s.ConsoleCommandEvaluatedInSelectedCallFrame, this._consoleCommandEvaluatedInSel
ectedCallFrame, this); |
190 WebInspector.debuggerModel.addEventListener(WebInspector.DebuggerModel.Event
s.BreakpointsActiveStateChanged, this._breakpointsActiveStateChanged, this); | 146 WebInspector.debuggerModel.addEventListener(WebInspector.DebuggerModel.Event
s.BreakpointsActiveStateChanged, this._breakpointsActiveStateChanged, this); |
191 | |
192 WebInspector.startBatchUpdate(); | |
193 this._workspace.uiSourceCodes().forEach(this._addUISourceCode.bind(this)); | |
194 WebInspector.endBatchUpdate(); | |
195 | |
196 this._workspace.addEventListener(WebInspector.Workspace.Events.UISourceCodeA
dded, this._uiSourceCodeAdded, this); | |
197 this._workspace.addEventListener(WebInspector.Workspace.Events.UISourceCodeR
emoved, this._uiSourceCodeRemoved, this); | |
198 this._workspace.addEventListener(WebInspector.Workspace.Events.ProjectWillRe
set, this._projectWillReset.bind(this), this); | |
199 WebInspector.debuggerModel.addEventListener(WebInspector.DebuggerModel.Event
s.GlobalObjectCleared, this._debuggerReset, this); | 147 WebInspector.debuggerModel.addEventListener(WebInspector.DebuggerModel.Event
s.GlobalObjectCleared, this._debuggerReset, this); |
200 | |
201 function handleBeforeUnload(event) | |
202 { | |
203 if (event.returnValue) | |
204 return; | |
205 var unsavedSourceCodes = WebInspector.workspace.unsavedSourceCodes(); | |
206 if (!unsavedSourceCodes.length) | |
207 return; | |
208 | |
209 event.returnValue = WebInspector.UIString("DevTools have unsaved changes
that will be permanently lost."); | |
210 WebInspector.inspectorView.showPanel("sources"); | |
211 for (var i = 0; i < unsavedSourceCodes.length; ++i) | |
212 WebInspector.panels.sources.showUISourceCode(unsavedSourceCodes[i]); | |
213 } | |
214 window.addEventListener("beforeunload", handleBeforeUnload, true); | |
215 } | 148 } |
216 | 149 |
217 WebInspector.SourcesPanel.minToolbarWidth = 215; | 150 WebInspector.SourcesPanel.minToolbarWidth = 215; |
218 | 151 |
219 WebInspector.SourcesPanel.Events = { | |
220 EditorClosed: "EditorClosed", | |
221 EditorSelected: "EditorSelected", | |
222 } | |
223 | |
224 WebInspector.SourcesPanel.prototype = { | 152 WebInspector.SourcesPanel.prototype = { |
225 /** | 153 /** |
226 * @param {?Event=} event | |
227 */ | |
228 _onCloseEditorTab: function(event) | |
229 { | |
230 var uiSourceCode = this.currentUISourceCode(); | |
231 if (!uiSourceCode) | |
232 return false; | |
233 this._editorContainer.closeFile(uiSourceCode); | |
234 return true; | |
235 }, | |
236 | |
237 /** | |
238 * @param {?Event=} event | |
239 */ | |
240 _onJumpToPreviousLocation: function(event) | |
241 { | |
242 this._historyManager.rollback(); | |
243 return true; | |
244 }, | |
245 | |
246 /** | |
247 * @param {?Event=} event | |
248 */ | |
249 _onJumpToNextLocation: function(event) | |
250 { | |
251 this._historyManager.rollover(); | |
252 return true; | |
253 }, | |
254 | |
255 /** | |
256 * @return {!Element} | 154 * @return {!Element} |
257 */ | 155 */ |
258 defaultFocusedElement: function() | 156 defaultFocusedElement: function() |
259 { | 157 { |
260 return this._editorContainer.view.defaultFocusedElement() || this._navig
ator.view.defaultFocusedElement(); | 158 return this._sourcesEditor.defaultFocusedElement() || this._navigator.vi
ew.defaultFocusedElement(); |
261 }, | 159 }, |
262 | 160 |
263 get paused() | 161 get paused() |
264 { | 162 { |
265 return this._paused; | 163 return this._paused; |
266 }, | 164 }, |
267 | 165 |
268 /** | 166 /** |
269 * @return {!WebInspector.SourcesPanel.DrawerEditor} | 167 * @return {!WebInspector.SourcesPanel.DrawerEditor} |
270 */ | 168 */ |
271 _drawerEditor: function() | 169 _drawerEditor: function() |
272 { | 170 { |
273 var drawerEditorInstance = WebInspector.moduleManager.instance(WebInspec
tor.DrawerEditor); | 171 var drawerEditorInstance = WebInspector.moduleManager.instance(WebInspec
tor.DrawerEditor); |
274 console.assert(drawerEditorInstance instanceof WebInspector.SourcesPanel
.DrawerEditor, "WebInspector.DrawerEditor module instance does not use WebInspec
tor.SourcesPanel.DrawerEditor as an implementation. "); | 172 console.assert(drawerEditorInstance instanceof WebInspector.SourcesPanel
.DrawerEditor, "WebInspector.DrawerEditor module instance does not use WebInspec
tor.SourcesPanel.DrawerEditor as an implementation. "); |
275 return /** @type {!WebInspector.SourcesPanel.DrawerEditor} */ (drawerEdi
torInstance); | 173 return /** @type {!WebInspector.SourcesPanel.DrawerEditor} */ (drawerEdi
torInstance); |
276 }, | 174 }, |
277 | 175 |
278 wasShown: function() | 176 wasShown: function() |
279 { | 177 { |
280 this._drawerEditor()._panelWasShown(); | 178 this._drawerEditor()._panelWasShown(); |
281 this.sourcesView.show(this.editorView.mainElement()); | 179 this._sourcesEditor.sourcesView().show(this.editorView.mainElement()); |
282 WebInspector.Panel.prototype.wasShown.call(this); | 180 WebInspector.Panel.prototype.wasShown.call(this); |
283 }, | 181 }, |
284 | 182 |
285 willHide: function() | 183 willHide: function() |
286 { | 184 { |
287 WebInspector.Panel.prototype.willHide.call(this); | 185 WebInspector.Panel.prototype.willHide.call(this); |
288 this._drawerEditor()._panelWillHide(); | 186 this._drawerEditor()._panelWillHide(); |
289 this.sourcesView.show(this._drawerEditorView.element); | 187 this._sourcesEditor.sourcesView().show(this._drawerEditorView.element); |
290 }, | 188 }, |
291 | 189 |
292 /** | 190 /** |
293 * @return {!WebInspector.SearchableView} | 191 * @return {!WebInspector.SearchableView} |
294 */ | 192 */ |
295 searchableView: function() | 193 searchableView: function() |
296 { | 194 { |
297 return this._searchableView; | 195 return this._sourcesEditor.searchableView(); |
298 }, | |
299 | |
300 /** | |
301 * @param {!WebInspector.Event} event | |
302 */ | |
303 _uiSourceCodeAdded: function(event) | |
304 { | |
305 var uiSourceCode = /** @type {!WebInspector.UISourceCode} */ (event.data
); | |
306 this._addUISourceCode(uiSourceCode); | |
307 }, | |
308 | |
309 /** | |
310 * @param {!WebInspector.UISourceCode} uiSourceCode | |
311 */ | |
312 _addUISourceCode: function(uiSourceCode) | |
313 { | |
314 if (uiSourceCode.project().isServiceProject()) | |
315 return; | |
316 this._editorContainer.addUISourceCode(uiSourceCode); | |
317 // Replace debugger script-based uiSourceCode with a network-based one. | |
318 var currentUISourceCode = this._currentUISourceCode; | |
319 if (currentUISourceCode && currentUISourceCode.project().isServiceProjec
t() && currentUISourceCode !== uiSourceCode && currentUISourceCode.url === uiSou
rceCode.url) { | |
320 this._showFile(uiSourceCode); | |
321 this._editorContainer.removeUISourceCode(currentUISourceCode); | |
322 } | |
323 }, | |
324 | |
325 _uiSourceCodeRemoved: function(event) | |
326 { | |
327 var uiSourceCode = /** @type {!WebInspector.UISourceCode} */ (event.data
); | |
328 this._removeUISourceCodes([uiSourceCode]); | |
329 }, | |
330 | |
331 /** | |
332 * @param {!Array.<!WebInspector.UISourceCode>} uiSourceCodes | |
333 */ | |
334 _removeUISourceCodes: function(uiSourceCodes) | |
335 { | |
336 for (var i = 0; i < uiSourceCodes.length; ++i) { | |
337 this._removeSourceFrame(uiSourceCodes[i]); | |
338 this._historyManager.removeHistoryForSourceCode(uiSourceCodes[i]); | |
339 } | |
340 this._editorContainer.removeUISourceCodes(uiSourceCodes); | |
341 }, | 196 }, |
342 | 197 |
343 _consoleCommandEvaluatedInSelectedCallFrame: function(event) | 198 _consoleCommandEvaluatedInSelectedCallFrame: function(event) |
344 { | 199 { |
345 this.sidebarPanes.scopechain.update(WebInspector.debuggerModel.selectedC
allFrame()); | 200 this.sidebarPanes.scopechain.update(WebInspector.debuggerModel.selectedC
allFrame()); |
346 }, | 201 }, |
347 | 202 |
348 _debuggerPaused: function() | 203 _debuggerPaused: function() |
349 { | 204 { |
350 WebInspector.inspectorView.setCurrentPanel(this); | 205 WebInspector.inspectorView.setCurrentPanel(this); |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
435 this._debuggerReset(); | 290 this._debuggerReset(); |
436 }, | 291 }, |
437 | 292 |
438 _debuggerReset: function() | 293 _debuggerReset: function() |
439 { | 294 { |
440 this._debuggerResumed(); | 295 this._debuggerResumed(); |
441 this.sidebarPanes.watchExpressions.reset(); | 296 this.sidebarPanes.watchExpressions.reset(); |
442 delete this._skipExecutionLineRevealing; | 297 delete this._skipExecutionLineRevealing; |
443 }, | 298 }, |
444 | 299 |
445 _projectWillReset: function(event) | |
446 { | |
447 var project = event.data; | |
448 var uiSourceCodes = project.uiSourceCodes(); | |
449 this._removeUISourceCodes(uiSourceCodes); | |
450 if (project.type() === WebInspector.projectTypes.Network) | |
451 this._editorContainer.reset(); | |
452 }, | |
453 | |
454 /** | 300 /** |
455 * @return {!WebInspector.View} | 301 * @return {!WebInspector.View} |
456 */ | 302 */ |
457 get visibleView() | 303 get visibleView() |
458 { | 304 { |
459 return this._editorContainer.visibleView; | 305 return this._sourcesEditor.visibleView(); |
460 }, | 306 }, |
461 | 307 |
462 /** | 308 /** |
463 * @return {?WebInspector.SourceFrame} | |
464 */ | |
465 currentSourceFrame: function() | |
466 { | |
467 var view = this.visibleView; | |
468 if (!(view instanceof WebInspector.SourceFrame)) | |
469 return null; | |
470 return /** @type {!WebInspector.SourceFrame} */ (view); | |
471 }, | |
472 | |
473 _updateScriptViewStatusBarItems: function() | |
474 { | |
475 this._scriptViewStatusBarItemsContainer.removeChildren(); | |
476 this._scriptViewStatusBarTextContainer.removeChildren(); | |
477 var sourceFrame = this.currentSourceFrame(); | |
478 if (!sourceFrame) | |
479 return; | |
480 | |
481 var statusBarItems = sourceFrame.statusBarItems() || []; | |
482 for (var i = 0; i < statusBarItems.length; ++i) | |
483 this._scriptViewStatusBarItemsContainer.appendChild(statusBarItems[i
]); | |
484 var statusBarText = sourceFrame.statusBarText(); | |
485 if (statusBarText) | |
486 this._scriptViewStatusBarTextContainer.appendChild(statusBarText); | |
487 }, | |
488 | |
489 /** | |
490 * @param {!WebInspector.UISourceCode} uiSourceCode | 309 * @param {!WebInspector.UISourceCode} uiSourceCode |
491 * @param {number=} lineNumber | 310 * @param {number=} lineNumber |
492 * @param {number=} columnNumber | 311 * @param {number=} columnNumber |
493 * @param {boolean=} forceShowInPanel | 312 * @param {boolean=} forceShowInPanel |
494 */ | 313 */ |
495 showUISourceCode: function(uiSourceCode, lineNumber, columnNumber, forceShow
InPanel) | 314 showUISourceCode: function(uiSourceCode, lineNumber, columnNumber, forceShow
InPanel) |
496 { | 315 { |
497 this._showSourceLocation(uiSourceCode, lineNumber, columnNumber, forceSh
owInPanel); | 316 this._showEditor(forceShowInPanel); |
| 317 this._sourcesEditor.showSourceLocation(uiSourceCode, lineNumber, columnN
umber); |
498 }, | 318 }, |
499 | 319 |
500 /** | |
501 * @param {boolean=} forceShowInPanel | |
502 */ | |
503 _showEditor: function(forceShowInPanel) | 320 _showEditor: function(forceShowInPanel) |
504 { | 321 { |
505 if (this.sourcesView.isShowing()) | 322 if (this._sourcesEditor.sourcesView().isShowing()) |
506 return; | 323 return; |
507 | 324 |
508 if (this._shouldShowEditorInDrawer() && !forceShowInPanel) | 325 if (this._shouldShowEditorInDrawer() && !forceShowInPanel) |
509 this._drawerEditor()._show(); | 326 this._drawerEditor()._show(); |
510 else | 327 else |
511 WebInspector.inspectorView.showPanel("sources"); | 328 WebInspector.inspectorView.showPanel("sources"); |
512 }, | 329 }, |
513 | 330 |
514 /** | 331 /** |
515 * @return {?WebInspector.UISourceCode} | |
516 */ | |
517 currentUISourceCode: function() | |
518 { | |
519 return this._currentUISourceCode; | |
520 }, | |
521 | |
522 /** | |
523 * @param {!WebInspector.UILocation} uiLocation | 332 * @param {!WebInspector.UILocation} uiLocation |
524 * @param {boolean=} forceShowInPanel | 333 * @param {boolean=} forceShowInPanel |
525 */ | 334 */ |
526 showUILocation: function(uiLocation, forceShowInPanel) | 335 showUILocation: function(uiLocation, forceShowInPanel) |
527 { | 336 { |
528 this._showSourceLocation(uiLocation.uiSourceCode, uiLocation.lineNumber,
uiLocation.columnNumber, forceShowInPanel); | 337 this.showUISourceCode(uiLocation.uiSourceCode, uiLocation.lineNumber, ui
Location.columnNumber, forceShowInPanel); |
529 }, | 338 }, |
530 | 339 |
531 /** | 340 /** |
532 * @return {boolean} | 341 * @return {boolean} |
533 */ | 342 */ |
534 _shouldShowEditorInDrawer: function() | 343 _shouldShowEditorInDrawer: function() |
535 { | 344 { |
536 return WebInspector.experimentsSettings.showEditorInDrawer.isEnabled() &
& WebInspector.settings.showEditorInDrawer.get() && WebInspector.inspectorView.i
sDrawerEditorShown(); | 345 return WebInspector.experimentsSettings.showEditorInDrawer.isEnabled() &
& WebInspector.settings.showEditorInDrawer.get() && WebInspector.inspectorView.i
sDrawerEditorShown(); |
537 }, | 346 }, |
538 | 347 |
539 /** | 348 /** |
540 * @param {!WebInspector.UISourceCode} uiSourceCode | 349 * @param {!WebInspector.UISourceCode} uiSourceCode |
541 * @param {number=} lineNumber | |
542 * @param {number=} columnNumber | |
543 * @param {boolean=} forceShowInPanel | |
544 * @param {boolean=} omitFocus | |
545 * @param {boolean=} omitHighlight | |
546 */ | |
547 _showSourceLocation: function(uiSourceCode, lineNumber, columnNumber, forceS
howInPanel, omitFocus, omitHighlight) | |
548 { | |
549 this._showEditor(forceShowInPanel); | |
550 this._historyManager.updateCurrentState(); | |
551 var sourceFrame = this._showFile(uiSourceCode); | |
552 if (typeof lineNumber === "number") | |
553 sourceFrame.revealPosition(lineNumber, columnNumber, !omitHighlight)
; | |
554 this._historyManager.pushNewState(); | |
555 if (!omitFocus) | |
556 sourceFrame.focus(); | |
557 WebInspector.notifications.dispatchEventToListeners(WebInspector.UserMet
rics.UserAction, { | |
558 action: WebInspector.UserMetrics.UserActionNames.OpenSourceLink, | |
559 url: uiSourceCode.originURL(), | |
560 lineNumber: lineNumber | |
561 }); | |
562 }, | |
563 | |
564 /** | |
565 * @param {!WebInspector.UISourceCode} uiSourceCode | |
566 * @return {!WebInspector.SourceFrame} | |
567 */ | |
568 _showFile: function(uiSourceCode) | |
569 { | |
570 var sourceFrame = this._getOrCreateSourceFrame(uiSourceCode); | |
571 if (this._currentUISourceCode === uiSourceCode) | |
572 return sourceFrame; | |
573 | |
574 this._currentUISourceCode = uiSourceCode; | |
575 this._editorContainer.showFile(uiSourceCode); | |
576 this._updateScriptViewStatusBarItems(); | |
577 | |
578 if (this._currentUISourceCode.project().type() === WebInspector.projectT
ypes.Snippets) | |
579 this._runSnippetButton.element.classList.remove("hidden"); | |
580 else | |
581 this._runSnippetButton.element.classList.add("hidden"); | |
582 | |
583 return sourceFrame; | |
584 }, | |
585 | |
586 /** | |
587 * @param {!WebInspector.UISourceCode} uiSourceCode | |
588 * @return {!WebInspector.SourceFrame} | |
589 */ | |
590 _createSourceFrame: function(uiSourceCode) | |
591 { | |
592 var sourceFrame; | |
593 switch (uiSourceCode.contentType()) { | |
594 case WebInspector.resourceTypes.Script: | |
595 sourceFrame = new WebInspector.JavaScriptSourceFrame(this, uiSourceC
ode); | |
596 break; | |
597 case WebInspector.resourceTypes.Document: | |
598 sourceFrame = new WebInspector.JavaScriptSourceFrame(this, uiSourceC
ode); | |
599 break; | |
600 case WebInspector.resourceTypes.Stylesheet: | |
601 sourceFrame = new WebInspector.CSSSourceFrame(uiSourceCode); | |
602 break; | |
603 default: | |
604 sourceFrame = new WebInspector.UISourceCodeFrame(uiSourceCode); | |
605 break; | |
606 } | |
607 sourceFrame.setHighlighterType(uiSourceCode.highlighterType()); | |
608 this._sourceFramesByUISourceCode.put(uiSourceCode, sourceFrame); | |
609 this._historyManager.trackSourceFrameCursorJumps(sourceFrame); | |
610 return sourceFrame; | |
611 }, | |
612 | |
613 /** | |
614 * @param {!WebInspector.UISourceCode} uiSourceCode | |
615 * @return {!WebInspector.SourceFrame} | |
616 */ | |
617 _getOrCreateSourceFrame: function(uiSourceCode) | |
618 { | |
619 return this._sourceFramesByUISourceCode.get(uiSourceCode) || this._creat
eSourceFrame(uiSourceCode); | |
620 }, | |
621 | |
622 /** | |
623 * @param {!WebInspector.SourceFrame} sourceFrame | |
624 * @param {!WebInspector.UISourceCode} uiSourceCode | |
625 * @return {boolean} | |
626 */ | |
627 _sourceFrameMatchesUISourceCode: function(sourceFrame, uiSourceCode) | |
628 { | |
629 switch (uiSourceCode.contentType()) { | |
630 case WebInspector.resourceTypes.Script: | |
631 case WebInspector.resourceTypes.Document: | |
632 return sourceFrame instanceof WebInspector.JavaScriptSourceFrame; | |
633 case WebInspector.resourceTypes.Stylesheet: | |
634 return sourceFrame instanceof WebInspector.CSSSourceFrame; | |
635 default: | |
636 return !(sourceFrame instanceof WebInspector.JavaScriptSourceFrame); | |
637 } | |
638 }, | |
639 | |
640 /** | |
641 * @param {!WebInspector.UISourceCode} uiSourceCode | |
642 */ | |
643 _recreateSourceFrameIfNeeded: function(uiSourceCode) | |
644 { | |
645 var oldSourceFrame = this._sourceFramesByUISourceCode.get(uiSourceCode); | |
646 if (!oldSourceFrame) | |
647 return; | |
648 if (this._sourceFrameMatchesUISourceCode(oldSourceFrame, uiSourceCode))
{ | |
649 oldSourceFrame.setHighlighterType(uiSourceCode.highlighterType()); | |
650 } else { | |
651 this._editorContainer.removeUISourceCode(uiSourceCode); | |
652 this._removeSourceFrame(uiSourceCode); | |
653 } | |
654 }, | |
655 | |
656 /** | |
657 * @param {!WebInspector.UISourceCode} uiSourceCode | |
658 * @return {!WebInspector.SourceFrame} | |
659 */ | |
660 viewForFile: function(uiSourceCode) | |
661 { | |
662 return this._getOrCreateSourceFrame(uiSourceCode); | |
663 }, | |
664 | |
665 /** | |
666 * @param {!WebInspector.UISourceCode} uiSourceCode | |
667 */ | 350 */ |
668 _revealInNavigator: function(uiSourceCode) | 351 _revealInNavigator: function(uiSourceCode) |
669 { | 352 { |
670 this._navigator.revealUISourceCode(uiSourceCode); | 353 this._navigator.revealUISourceCode(uiSourceCode); |
671 }, | 354 }, |
672 | 355 |
673 /** | |
674 * @return {?WebInspector.UISourceCode} | |
675 */ | |
676 selectedUISourceCode: function() | |
677 { | |
678 return this._currentUISourceCode; | |
679 }, | |
680 | |
681 /** | |
682 * @param {!WebInspector.UISourceCode} uiSourceCode | |
683 */ | |
684 _removeSourceFrame: function(uiSourceCode) | |
685 { | |
686 var sourceFrame = this._sourceFramesByUISourceCode.get(uiSourceCode); | |
687 if (!sourceFrame) | |
688 return; | |
689 this._sourceFramesByUISourceCode.remove(uiSourceCode); | |
690 sourceFrame.dispose(); | |
691 }, | |
692 | |
693 _clearCurrentExecutionLine: function() | |
694 { | |
695 if (this._executionSourceFrame) | |
696 this._executionSourceFrame.clearExecutionLine(); | |
697 delete this._executionSourceFrame; | |
698 }, | |
699 | |
700 _setExecutionLine: function(uiLocation) | |
701 { | |
702 var sourceFrame = this._getOrCreateSourceFrame(uiLocation.uiSourceCode); | |
703 sourceFrame.setExecutionLine(uiLocation.lineNumber); | |
704 this._executionSourceFrame = sourceFrame; | |
705 }, | |
706 | |
707 _executionLineChanged: function(uiLocation) | 356 _executionLineChanged: function(uiLocation) |
708 { | 357 { |
709 this._historyManager.updateCurrentState(); | 358 this._sourcesEditor.clearCurrentExecutionLine(); |
710 this._clearCurrentExecutionLine(); | 359 this._sourcesEditor.setExecutionLine(uiLocation); |
711 this._setExecutionLine(uiLocation); | |
712 | |
713 var uiSourceCode = uiLocation.uiSourceCode; | |
714 var scriptFile = this._currentUISourceCode ? this._currentUISourceCode.s
criptFile() : null; | |
715 if (this._skipExecutionLineRevealing) | 360 if (this._skipExecutionLineRevealing) |
716 return; | 361 return; |
717 this._skipExecutionLineRevealing = true; | 362 this._skipExecutionLineRevealing = true; |
718 this._showSourceLocation(uiSourceCode, uiLocation.lineNumber, 0, undefin
ed, undefined, true); | 363 this._sourcesEditor.showSourceLocation(uiLocation.uiSourceCode, uiLocati
on.lineNumber, 0, undefined, true); |
719 }, | 364 }, |
720 | 365 |
721 _callFrameSelected: function(event) | 366 _callFrameSelected: function(event) |
722 { | 367 { |
723 var callFrame = event.data; | 368 var callFrame = event.data; |
724 | 369 |
725 if (!callFrame) | 370 if (!callFrame) |
726 return; | 371 return; |
727 | 372 |
728 this.sidebarPanes.scopechain.update(callFrame); | 373 this.sidebarPanes.scopechain.update(callFrame); |
729 this.sidebarPanes.watchExpressions.refreshExpressions(); | 374 this.sidebarPanes.watchExpressions.refreshExpressions(); |
730 this.sidebarPanes.callstack.setSelectedCallFrame(callFrame); | 375 this.sidebarPanes.callstack.setSelectedCallFrame(callFrame); |
731 callFrame.createLiveLocation(this._executionLineChanged.bind(this)); | 376 callFrame.createLiveLocation(this._executionLineChanged.bind(this)); |
732 }, | 377 }, |
733 | 378 |
734 _editorClosed: function(event) | |
735 { | |
736 var uiSourceCode = /** @type {!WebInspector.UISourceCode} */ (event.data
); | |
737 this._historyManager.removeHistoryForSourceCode(uiSourceCode); | |
738 | |
739 var wasSelected = false; | |
740 if (this._currentUISourceCode === uiSourceCode) { | |
741 delete this._currentUISourceCode; | |
742 wasSelected = true; | |
743 } | |
744 | |
745 // SourcesNavigator does not need to update on EditorClosed. | |
746 this._updateScriptViewStatusBarItems(); | |
747 this._searchableView.resetSearch(); | |
748 | |
749 var data = {}; | |
750 data.uiSourceCode = uiSourceCode; | |
751 data.wasSelected = wasSelected; | |
752 this.dispatchEventToListeners(WebInspector.SourcesPanel.Events.EditorClo
sed, data); | |
753 }, | |
754 | |
755 _editorSelected: function(event) | |
756 { | |
757 var uiSourceCode = /** @type {!WebInspector.UISourceCode} */ (event.data
.currentFile); | |
758 var shouldUseHistoryManager = uiSourceCode !== this._currentUISourceCode
&& event.data.userGesture; | |
759 if (shouldUseHistoryManager) | |
760 this._historyManager.updateCurrentState(); | |
761 var sourceFrame = this._showFile(uiSourceCode); | |
762 if (shouldUseHistoryManager) | |
763 this._historyManager.pushNewState(); | |
764 | |
765 this._searchableView.setReplaceable(!!sourceFrame && sourceFrame.canEdit
Source()); | |
766 this._searchableView.resetSearch(); | |
767 | |
768 this.dispatchEventToListeners(WebInspector.SourcesPanel.Events.EditorSel
ected, uiSourceCode); | |
769 }, | |
770 | |
771 /** | 379 /** |
772 * @param {!WebInspector.Event} event | 380 * @param {!WebInspector.Event} event |
773 */ | 381 */ |
774 _sourceSelected: function(event) | 382 _sourceSelected: function(event) |
775 { | 383 { |
776 var uiSourceCode = /** @type {!WebInspector.UISourceCode} */ (event.data
.uiSourceCode); | 384 var uiSourceCode = /** @type {!WebInspector.UISourceCode} */ (event.data
.uiSourceCode); |
777 this._showSourceLocation(uiSourceCode, undefined, undefined, undefined,
!event.data.focusSource) | 385 this._sourcesEditor.showSourceLocation(uiSourceCode, undefined, undefine
d, !event.data.focusSource) |
778 }, | 386 }, |
779 | 387 |
780 /** | 388 /** |
781 * @param {!WebInspector.Event} event | 389 * @param {!WebInspector.Event} event |
782 */ | 390 */ |
783 _sourceRenamed: function(event) | 391 _sourceRenamed: function(event) |
784 { | 392 { |
785 var uiSourceCode = /** @type {!WebInspector.UISourceCode} */ (event.data
); | 393 var uiSourceCode = /** @type {!WebInspector.UISourceCode} */ (event.data
); |
786 this._recreateSourceFrameIfNeeded(uiSourceCode); | 394 this._sourcesEditor.sourceRenamed(uiSourceCode); |
787 }, | 395 }, |
788 | 396 |
789 _pauseOnExceptionEnabledChanged: function() | 397 _pauseOnExceptionEnabledChanged: function() |
790 { | 398 { |
791 var enabled = WebInspector.settings.pauseOnExceptionEnabled.get(); | 399 var enabled = WebInspector.settings.pauseOnExceptionEnabled.get(); |
792 this._pauseOnExceptionButton.toggled = enabled; | 400 this._pauseOnExceptionButton.toggled = enabled; |
793 this._pauseOnExceptionButton.title = WebInspector.UIString(enabled ? "Do
n't pause on exceptions." : "Pause on exceptions."); | 401 this._pauseOnExceptionButton.title = WebInspector.UIString(enabled ? "Do
n't pause on exceptions." : "Pause on exceptions."); |
794 this._debugToolbarDrawer.classList.toggle("expanded", enabled); | 402 this._debugToolbarDrawer.classList.toggle("expanded", enabled); |
795 }, | 403 }, |
796 | 404 |
(...skipping 22 matching lines...) Expand all Loading... |
819 | 427 |
820 _clearInterface: function() | 428 _clearInterface: function() |
821 { | 429 { |
822 this.sidebarPanes.callstack.update(null, null); | 430 this.sidebarPanes.callstack.update(null, null); |
823 this.sidebarPanes.scopechain.update(null); | 431 this.sidebarPanes.scopechain.update(null); |
824 this.sidebarPanes.jsBreakpoints.clearBreakpointHighlight(); | 432 this.sidebarPanes.jsBreakpoints.clearBreakpointHighlight(); |
825 WebInspector.domBreakpointsSidebarPane.clearBreakpointHighlight(); | 433 WebInspector.domBreakpointsSidebarPane.clearBreakpointHighlight(); |
826 this.sidebarPanes.eventListenerBreakpoints.clearBreakpointHighlight(); | 434 this.sidebarPanes.eventListenerBreakpoints.clearBreakpointHighlight(); |
827 this.sidebarPanes.xhrBreakpoints.clearBreakpointHighlight(); | 435 this.sidebarPanes.xhrBreakpoints.clearBreakpointHighlight(); |
828 | 436 |
829 this._clearCurrentExecutionLine(); | 437 this._sourcesEditor.clearCurrentExecutionLine(); |
830 this._updateDebuggerButtons(); | 438 this._updateDebuggerButtons(); |
831 }, | 439 }, |
832 | 440 |
833 _togglePauseOnExceptions: function() | 441 _togglePauseOnExceptions: function() |
834 { | 442 { |
835 WebInspector.settings.pauseOnExceptionEnabled.set(!this._pauseOnExceptio
nButton.toggled); | 443 WebInspector.settings.pauseOnExceptionEnabled.set(!this._pauseOnExceptio
nButton.toggled); |
836 }, | 444 }, |
837 | 445 |
838 /** | 446 /** |
839 * @return {boolean} | 447 * @return {boolean} |
840 */ | 448 */ |
841 _runSnippet: function() | 449 _runSnippet: function() |
842 { | 450 { |
843 if (this._currentUISourceCode.project().type() !== WebInspector.projectT
ypes.Snippets) | 451 var uiSourceCode = this._sourcesEditor.currentUISourceCode(); |
| 452 if (uiSourceCode.project().type() !== WebInspector.projectTypes.Snippets
) |
844 return false; | 453 return false; |
845 WebInspector.scriptSnippetModel.evaluateScriptSnippet(this._currentUISou
rceCode); | 454 WebInspector.scriptSnippetModel.evaluateScriptSnippet(uiSourceCode); |
846 return true; | 455 return true; |
847 }, | 456 }, |
848 | 457 |
849 /** | 458 /** |
| 459 * @param {!WebInspector.Event} event |
| 460 */ |
| 461 _editorSelected: function(event) |
| 462 { |
| 463 var uiSourceCode = /** @type {!WebInspector.UISourceCode} */ (event.data
); |
| 464 this._editorChanged(uiSourceCode); |
| 465 }, |
| 466 |
| 467 /** |
| 468 * @param {!WebInspector.Event} event |
| 469 */ |
| 470 _editorClosed: function(event) |
| 471 { |
| 472 var wasSelected = /** @type {boolean} */ (event.data.wasSelected); |
| 473 if (wasSelected) |
| 474 this._editorChanged(null); |
| 475 }, |
| 476 |
| 477 /** |
| 478 * @param {?WebInspector.UISourceCode} uiSourceCode |
| 479 */ |
| 480 _editorChanged: function(uiSourceCode) |
| 481 { |
| 482 var isSnippet = uiSourceCode && uiSourceCode.project().type() === WebIns
pector.projectTypes.Snippets; |
| 483 this._runSnippetButton.element.classList.toggle("hidden", !isSnippet); |
| 484 }, |
| 485 |
| 486 /** |
850 * @return {boolean} | 487 * @return {boolean} |
851 */ | 488 */ |
852 _togglePause: function() | 489 _togglePause: function() |
853 { | 490 { |
854 if (this._paused) { | 491 if (this._paused) { |
855 delete this._skipExecutionLineRevealing; | 492 delete this._skipExecutionLineRevealing; |
856 this._paused = false; | 493 this._paused = false; |
857 this._waitingToPause = false; | 494 this._waitingToPause = false; |
858 WebInspector.debuggerModel.resume(); | 495 WebInspector.debuggerModel.resume(); |
859 } else { | 496 } else { |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
963 | 600 |
964 _toggleBreakpointsClicked: function(event) | 601 _toggleBreakpointsClicked: function(event) |
965 { | 602 { |
966 WebInspector.debuggerModel.setBreakpointsActive(!WebInspector.debuggerMo
del.breakpointsActive()); | 603 WebInspector.debuggerModel.setBreakpointsActive(!WebInspector.debuggerMo
del.breakpointsActive()); |
967 }, | 604 }, |
968 | 605 |
969 _breakpointsActiveStateChanged: function(event) | 606 _breakpointsActiveStateChanged: function(event) |
970 { | 607 { |
971 var active = event.data; | 608 var active = event.data; |
972 this._toggleBreakpointsButton.toggled = !active; | 609 this._toggleBreakpointsButton.toggled = !active; |
973 if (active) { | 610 this.sidebarPanes.jsBreakpoints.listElement.classList.toggle("breakpoint
s-list-deactivated", !active); |
| 611 this._sourcesEditor.toggleBreakpointsActiveState(active); |
| 612 if (active) |
974 this._toggleBreakpointsButton.title = WebInspector.UIString("Deactiv
ate breakpoints."); | 613 this._toggleBreakpointsButton.title = WebInspector.UIString("Deactiv
ate breakpoints."); |
975 this._editorContainer.view.element.classList.remove("breakpoints-dea
ctivated"); | 614 else |
976 this.sidebarPanes.jsBreakpoints.listElement.classList.remove("breakp
oints-list-deactivated"); | |
977 } else { | |
978 this._toggleBreakpointsButton.title = WebInspector.UIString("Activat
e breakpoints."); | 615 this._toggleBreakpointsButton.title = WebInspector.UIString("Activat
e breakpoints."); |
979 this._editorContainer.view.element.classList.add("breakpoints-deacti
vated"); | |
980 this.sidebarPanes.jsBreakpoints.listElement.classList.add("breakpoin
ts-list-deactivated"); | |
981 } | |
982 }, | 616 }, |
983 | 617 |
984 _createDebugToolbar: function() | 618 _createDebugToolbar: function() |
985 { | 619 { |
986 var debugToolbar = document.createElement("div"); | 620 var debugToolbar = document.createElement("div"); |
987 debugToolbar.className = "scripts-debug-toolbar"; | 621 debugToolbar.className = "scripts-debug-toolbar"; |
988 | 622 |
989 var title, handler; | 623 var title, handler; |
990 var platformSpecificModifier = WebInspector.KeyboardShortcut.Modifiers.C
trlOrMeta; | 624 var platformSpecificModifier = WebInspector.KeyboardShortcut.Modifiers.C
trlOrMeta; |
991 | 625 |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1073 _createButtonAndRegisterShortcuts: function(buttonId, buttonTitle, handler,
shortcuts) | 707 _createButtonAndRegisterShortcuts: function(buttonId, buttonTitle, handler,
shortcuts) |
1074 { | 708 { |
1075 var button = new WebInspector.StatusBarButton(buttonTitle, buttonId); | 709 var button = new WebInspector.StatusBarButton(buttonTitle, buttonId); |
1076 button.element.addEventListener("click", handler, false); | 710 button.element.addEventListener("click", handler, false); |
1077 button.shortcuts = shortcuts; | 711 button.shortcuts = shortcuts; |
1078 this._updateButtonTitle(button, buttonTitle); | 712 this._updateButtonTitle(button, buttonTitle); |
1079 this.registerShortcuts(shortcuts, handler); | 713 this.registerShortcuts(shortcuts, handler); |
1080 return button; | 714 return button; |
1081 }, | 715 }, |
1082 | 716 |
1083 searchCanceled: function() | |
1084 { | |
1085 if (this._searchView) | |
1086 this._searchView.searchCanceled(); | |
1087 | |
1088 delete this._searchView; | |
1089 delete this._searchQuery; | |
1090 }, | |
1091 | |
1092 /** | |
1093 * @param {string} query | |
1094 * @param {boolean} shouldJump | |
1095 */ | |
1096 performSearch: function(query, shouldJump) | |
1097 { | |
1098 this._searchableView.updateSearchMatchesCount(0); | |
1099 | |
1100 var sourceFrame = this.currentSourceFrame(); | |
1101 if (!sourceFrame) | |
1102 return; | |
1103 | |
1104 this._searchView = sourceFrame; | |
1105 this._searchQuery = query; | |
1106 | |
1107 /** | |
1108 * @param {!WebInspector.View} view | |
1109 * @param {number} searchMatches | |
1110 * @this {WebInspector.SourcesPanel} | |
1111 */ | |
1112 function finishedCallback(view, searchMatches) | |
1113 { | |
1114 if (!searchMatches) | |
1115 return; | |
1116 | |
1117 this._searchableView.updateSearchMatchesCount(searchMatches); | |
1118 } | |
1119 | |
1120 /** | |
1121 * @param {number} currentMatchIndex | |
1122 * @this {WebInspector.SourcesPanel} | |
1123 */ | |
1124 function currentMatchChanged(currentMatchIndex) | |
1125 { | |
1126 this._searchableView.updateCurrentMatchIndex(currentMatchIndex); | |
1127 } | |
1128 | |
1129 /** | |
1130 * @this {WebInspector.SourcesPanel} | |
1131 */ | |
1132 function searchResultsChanged() | |
1133 { | |
1134 this._searchableView.cancelSearch(); | |
1135 } | |
1136 | |
1137 this._searchView.performSearch(query, shouldJump, finishedCallback.bind(
this), currentMatchChanged.bind(this), searchResultsChanged.bind(this)); | |
1138 }, | |
1139 | |
1140 jumpToNextSearchResult: function() | |
1141 { | |
1142 if (!this._searchView) | |
1143 return; | |
1144 | |
1145 if (this._searchView !== this.currentSourceFrame()) { | |
1146 this.performSearch(this._searchQuery, true); | |
1147 return; | |
1148 } | |
1149 | |
1150 this._searchView.jumpToNextSearchResult(); | |
1151 }, | |
1152 | |
1153 jumpToPreviousSearchResult: function() | |
1154 { | |
1155 if (!this._searchView) | |
1156 return; | |
1157 | |
1158 if (this._searchView !== this.currentSourceFrame()) { | |
1159 this.performSearch(this._searchQuery, true); | |
1160 if (this._searchView) | |
1161 this._searchView.jumpToLastSearchResult(); | |
1162 return; | |
1163 } | |
1164 | |
1165 this._searchView.jumpToPreviousSearchResult(); | |
1166 }, | |
1167 | |
1168 /** | |
1169 * @param {string} text | |
1170 */ | |
1171 replaceSelectionWith: function(text) | |
1172 { | |
1173 var sourceFrame = this.currentSourceFrame(); | |
1174 if (!sourceFrame) { | |
1175 console.assert(sourceFrame); | |
1176 return; | |
1177 } | |
1178 sourceFrame.replaceSelectionWith(text); | |
1179 }, | |
1180 | |
1181 /** | |
1182 * @param {string} query | |
1183 * @param {string} text | |
1184 */ | |
1185 replaceAllWith: function(query, text) | |
1186 { | |
1187 var sourceFrame = this.currentSourceFrame(); | |
1188 if (!sourceFrame) { | |
1189 console.assert(sourceFrame); | |
1190 return; | |
1191 } | |
1192 sourceFrame.replaceAllWith(query, text); | |
1193 }, | |
1194 | |
1195 addToWatch: function(expression) | 717 addToWatch: function(expression) |
1196 { | 718 { |
1197 this.sidebarPanes.watchExpressions.addExpression(expression); | 719 this.sidebarPanes.watchExpressions.addExpression(expression); |
1198 }, | 720 }, |
1199 | 721 |
1200 /** | |
1201 * @return {boolean} | |
1202 */ | |
1203 _toggleBreakpoint: function() | |
1204 { | |
1205 var sourceFrame = this.currentSourceFrame(); | |
1206 if (!sourceFrame) | |
1207 return false; | |
1208 | |
1209 if (sourceFrame instanceof WebInspector.JavaScriptSourceFrame) { | |
1210 var javaScriptSourceFrame = /** @type {!WebInspector.JavaScriptSourc
eFrame} */ (sourceFrame); | |
1211 javaScriptSourceFrame.toggleBreakpointOnCurrentLine(); | |
1212 return true; | |
1213 } | |
1214 return false; | |
1215 }, | |
1216 | |
1217 /** | |
1218 * @param {?Event=} event | |
1219 * @return {boolean} | |
1220 */ | |
1221 _showOutlineDialog: function(event) | |
1222 { | |
1223 var uiSourceCode = this._editorContainer.currentFile(); | |
1224 if (!uiSourceCode) | |
1225 return false; | |
1226 | |
1227 switch (uiSourceCode.contentType()) { | |
1228 case WebInspector.resourceTypes.Document: | |
1229 case WebInspector.resourceTypes.Script: | |
1230 WebInspector.JavaScriptOutlineDialog.show(this.visibleView, uiSource
Code, this.showUISourceCode.bind(this, uiSourceCode)); | |
1231 return true; | |
1232 case WebInspector.resourceTypes.Stylesheet: | |
1233 WebInspector.StyleSheetOutlineDialog.show(this.visibleView, uiSource
Code, this.showUISourceCode.bind(this, uiSourceCode)); | |
1234 return true; | |
1235 } | |
1236 return false; | |
1237 }, | |
1238 | |
1239 _installDebuggerSidebarController: function() | 722 _installDebuggerSidebarController: function() |
1240 { | 723 { |
1241 this._toggleNavigatorSidebarButton = this.editorView.createShowHideSideb
arButton("navigator", "scripts-navigator-show-hide-button"); | 724 this._toggleNavigatorSidebarButton = this.editorView.createShowHideSideb
arButton("navigator", "scripts-navigator-show-hide-button"); |
1242 this.editorView.mainElement().appendChild(this._toggleNavigatorSidebarBu
tton.element); | 725 this.editorView.mainElement().appendChild(this._toggleNavigatorSidebarBu
tton.element); |
1243 | 726 |
1244 this._toggleDebuggerSidebarButton = this._splitView.createShowHideSideba
rButton("debugger", "scripts-debugger-show-hide-button"); | 727 this._toggleDebuggerSidebarButton = this._splitView.createShowHideSideba
rButton("debugger", "scripts-debugger-show-hide-button"); |
1245 | 728 |
1246 this._splitView.mainElement().appendChild(this._toggleDebuggerSidebarBut
ton.element); | 729 this._splitView.mainElement().appendChild(this._toggleDebuggerSidebarBut
ton.element); |
1247 this._splitView.mainElement().appendChild(this._debugSidebarResizeWidget
Element); | 730 this._splitView.mainElement().appendChild(this._debugSidebarResizeWidget
Element); |
1248 }, | 731 }, |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1416 * @this {WebInspector.SourcesPanel} | 899 * @this {WebInspector.SourcesPanel} |
1417 */ | 900 */ |
1418 function revealFunction() | 901 function revealFunction() |
1419 { | 902 { |
1420 DebuggerAgent.getFunctionDetails(remoteObject.objectId, didGetDetail
s.bind(this)); | 903 DebuggerAgent.getFunctionDetails(remoteObject.objectId, didGetDetail
s.bind(this)); |
1421 } | 904 } |
1422 | 905 |
1423 contextMenu.appendItem(WebInspector.UIString(WebInspector.useLowerCaseMe
nuTitles() ? "Show function definition" : "Show Function Definition"), revealFun
ction.bind(this)); | 906 contextMenu.appendItem(WebInspector.UIString(WebInspector.useLowerCaseMe
nuTitles() ? "Show function definition" : "Show Function Definition"), revealFun
ction.bind(this)); |
1424 }, | 907 }, |
1425 | 908 |
1426 /** | |
1427 * @param {string=} query | |
1428 */ | |
1429 _showOpenResourceDialog: function(query) | |
1430 { | |
1431 var uiSourceCodes = this._editorContainer.historyUISourceCodes(); | |
1432 /** @type {!Map.<!WebInspector.UISourceCode, number>} */ | |
1433 var defaultScores = new Map(); | |
1434 for (var i = 1; i < uiSourceCodes.length; ++i) // Skip current element | |
1435 defaultScores.put(uiSourceCodes[i], uiSourceCodes.length - i); | |
1436 WebInspector.OpenResourceDialog.show(this, this.editorView.mainElement()
, query, defaultScores); | |
1437 }, | |
1438 | |
1439 /** | |
1440 * @param {?Event=} event | |
1441 * @return {boolean} | |
1442 */ | |
1443 _showGoToLineDialog: function(event) | |
1444 { | |
1445 this._showOpenResourceDialog(":"); | |
1446 return true; | |
1447 }, | |
1448 | |
1449 showGoToSourceDialog: function() | 909 showGoToSourceDialog: function() |
1450 { | 910 { |
1451 this._showOpenResourceDialog(); | 911 this._sourcesEditor.showOpenResourceDialog(); |
1452 }, | 912 }, |
1453 | 913 |
1454 _dockSideChanged: function() | 914 _dockSideChanged: function() |
1455 { | 915 { |
1456 var vertically = WebInspector.dockController.isVertical() && WebInspecto
r.settings.splitVerticallyWhenDockedToRight.get(); | 916 var vertically = WebInspector.dockController.isVertical() && WebInspecto
r.settings.splitVerticallyWhenDockedToRight.get(); |
1457 this._splitVertically(vertically); | 917 this._splitVertically(vertically); |
1458 }, | 918 }, |
1459 | 919 |
1460 /** | 920 /** |
1461 * @param {boolean} vertically | 921 * @param {boolean} vertically |
1462 */ | 922 */ |
1463 _splitVertically: function(vertically) | 923 _splitVertically: function(vertically) |
1464 { | 924 { |
1465 if (this.sidebarPaneView && vertically === !this._splitView.isVertical()
) | 925 if (this.sidebarPaneView && vertically === !this._splitView.isVertical()
) |
1466 return; | 926 return; |
1467 | 927 |
1468 if (this.sidebarPaneView) | 928 if (this.sidebarPaneView) |
1469 this.sidebarPaneView.detach(); | 929 this.sidebarPaneView.detach(); |
1470 | 930 |
1471 this._splitView.setVertical(!vertically); | 931 this._splitView.setVertical(!vertically); |
1472 | 932 |
1473 if (!vertically) | 933 if (!vertically) |
1474 this._splitView.uninstallResizer(this._statusBarContainerElement); | 934 this._splitView.uninstallResizer(this._sourcesEditor.statusBarContai
nerElement()); |
1475 else | 935 else |
1476 this._splitView.installResizer(this._statusBarContainerElement); | 936 this._splitView.installResizer(this._sourcesEditor.statusBarContaine
rElement()); |
1477 | 937 |
1478 // Create vertical box with stack. | 938 // Create vertical box with stack. |
1479 var vbox = new WebInspector.VBox(); | 939 var vbox = new WebInspector.VBox(); |
1480 vbox.element.appendChild(this._debugToolbarDrawer); | 940 vbox.element.appendChild(this._debugToolbarDrawer); |
1481 vbox.element.appendChild(this.debugToolbar); | 941 vbox.element.appendChild(this.debugToolbar); |
1482 vbox.element.appendChild(this.threadsToolbar.element); | 942 vbox.element.appendChild(this.threadsToolbar.element); |
1483 var sidebarPaneStack = new WebInspector.SidebarPaneStack(); | 943 var sidebarPaneStack = new WebInspector.SidebarPaneStack(); |
1484 sidebarPaneStack.element.classList.add("flex-auto"); | 944 sidebarPaneStack.element.classList.add("flex-auto"); |
1485 sidebarPaneStack.show(vbox.element); | 945 sidebarPaneStack.show(vbox.element); |
1486 | 946 |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1531 * @param {!WebInspector.SidebarPane} pane | 991 * @param {!WebInspector.SidebarPane} pane |
1532 */ | 992 */ |
1533 addExtensionSidebarPane: function(id, pane) | 993 addExtensionSidebarPane: function(id, pane) |
1534 { | 994 { |
1535 this._extensionSidebarPanes.push(pane); | 995 this._extensionSidebarPanes.push(pane); |
1536 this._extensionSidebarPanesContainer.addPane(pane); | 996 this._extensionSidebarPanesContainer.addPane(pane); |
1537 this.setHideOnDetach(); | 997 this.setHideOnDetach(); |
1538 }, | 998 }, |
1539 | 999 |
1540 /** | 1000 /** |
1541 * @return {!WebInspector.TabbedEditorContainer} | 1001 * @return {!WebInspector.SourcesEditor} |
1542 */ | 1002 */ |
1543 get tabbedEditorContainer() | 1003 sourcesEditor: function() |
1544 { | 1004 { |
1545 return this._editorContainer; | 1005 return this._sourcesEditor; |
1546 }, | 1006 }, |
1547 | 1007 |
1548 __proto__: WebInspector.Panel.prototype | 1008 __proto__: WebInspector.Panel.prototype |
1549 } | 1009 } |
1550 | 1010 |
1551 /** | 1011 /** |
1552 * @constructor | 1012 * @constructor |
1553 * @extends {WebInspector.VBox} | |
1554 */ | |
1555 WebInspector.SourcesView = function() | |
1556 { | |
1557 WebInspector.VBox.call(this); | |
1558 this.registerRequiredCSS("sourcesView.css"); | |
1559 this.element.id = "sources-panel-sources-view"; | |
1560 this.element.addEventListener("dragenter", this._onDragEnter.bind(this), tru
e); | |
1561 this.element.addEventListener("dragover", this._onDragOver.bind(this), true)
; | |
1562 } | |
1563 | |
1564 WebInspector.SourcesView.dragAndDropFilesType = "Files"; | |
1565 | |
1566 WebInspector.SourcesView.prototype = { | |
1567 _onDragEnter: function (event) | |
1568 { | |
1569 if (event.dataTransfer.types.indexOf(WebInspector.SourcesView.dragAndDro
pFilesType) === -1) | |
1570 return; | |
1571 event.consume(true); | |
1572 }, | |
1573 | |
1574 _onDragOver: function (event) | |
1575 { | |
1576 if (event.dataTransfer.types.indexOf(WebInspector.SourcesView.dragAndDro
pFilesType) === -1) | |
1577 return; | |
1578 event.consume(true); | |
1579 if (this._dragMaskElement) | |
1580 return; | |
1581 this._dragMaskElement = this.element.createChild("div", "fill drag-mask"
); | |
1582 this._dragMaskElement.addEventListener("drop", this._onDrop.bind(this),
true); | |
1583 this._dragMaskElement.addEventListener("dragleave", this._onDragLeave.bi
nd(this), true); | |
1584 }, | |
1585 | |
1586 _onDrop: function (event) | |
1587 { | |
1588 event.consume(true); | |
1589 this._removeMask(); | |
1590 var items = /** @type {!Array.<!DataTransferItem>} */ (event.dataTransfe
r.items); | |
1591 if (!items.length) | |
1592 return; | |
1593 var entry = items[0].webkitGetAsEntry(); | |
1594 if (!entry.isDirectory) | |
1595 return; | |
1596 InspectorFrontendHost.upgradeDraggedFileSystemPermissions(entry.filesyst
em); | |
1597 }, | |
1598 | |
1599 _onDragLeave: function (event) | |
1600 { | |
1601 event.consume(true); | |
1602 this._removeMask(); | |
1603 }, | |
1604 | |
1605 _removeMask: function () | |
1606 { | |
1607 this._dragMaskElement.remove(); | |
1608 delete this._dragMaskElement; | |
1609 }, | |
1610 | |
1611 __proto__: WebInspector.VBox.prototype | |
1612 } | |
1613 | |
1614 /** | |
1615 * @constructor | |
1616 * @implements {WebInspector.DrawerEditor} | 1013 * @implements {WebInspector.DrawerEditor} |
1617 */ | 1014 */ |
1618 WebInspector.SourcesPanel.DrawerEditor = function() | 1015 WebInspector.SourcesPanel.DrawerEditor = function() |
1619 { | 1016 { |
1620 this._panel = WebInspector.inspectorView.panel("sources"); | 1017 this._panel = WebInspector.inspectorView.panel("sources"); |
1621 } | 1018 } |
1622 | 1019 |
1623 WebInspector.SourcesPanel.DrawerEditor.prototype = { | 1020 WebInspector.SourcesPanel.DrawerEditor.prototype = { |
1624 /** | 1021 /** |
1625 * @return {!WebInspector.View} | 1022 * @return {!WebInspector.View} |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1701 WebInspector.SourcesPanel.UILocationRevealer.prototype = { | 1098 WebInspector.SourcesPanel.UILocationRevealer.prototype = { |
1702 /** | 1099 /** |
1703 * @param {!Object} uiLocation | 1100 * @param {!Object} uiLocation |
1704 */ | 1101 */ |
1705 reveal: function(uiLocation) | 1102 reveal: function(uiLocation) |
1706 { | 1103 { |
1707 if (uiLocation instanceof WebInspector.UILocation) | 1104 if (uiLocation instanceof WebInspector.UILocation) |
1708 /** @type {!WebInspector.SourcesPanel} */ (WebInspector.inspectorVie
w.panel("sources")).showUILocation(uiLocation); | 1105 /** @type {!WebInspector.SourcesPanel} */ (WebInspector.inspectorVie
w.panel("sources")).showUILocation(uiLocation); |
1709 } | 1106 } |
1710 } | 1107 } |
1711 | |
1712 /** | |
1713 * @interface | |
1714 */ | |
1715 WebInspector.SourcesPanel.EditorAction = function() | |
1716 { | |
1717 } | |
1718 | |
1719 WebInspector.SourcesPanel.EditorAction.prototype = { | |
1720 /** | |
1721 * @param {!WebInspector.SourcesPanel} panel | |
1722 * @return {!Element} | |
1723 */ | |
1724 button: function(panel) { } | |
1725 } | |
OLD | NEW |