Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / Source / devtools / front_end / sources / SourcesPanel.js
blob380b268dce587311ab8275671ba59d8aee46765e
1 /*
2 * Copyright (C) 2008 Apple Inc. All Rights Reserved.
3 * Copyright (C) 2011 Google Inc. All rights reserved.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
14 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
18 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
19 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
20 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
21 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
22 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 /**
28 * @constructor
29 * @extends {WebInspector.Panel}
30 * @implements {WebInspector.ContextMenu.Provider}
31 * @param {!WebInspector.Workspace=} workspaceForTest
33 WebInspector.SourcesPanel = function(workspaceForTest)
35 WebInspector.Panel.call(this, "sources");
36 this.registerRequiredCSS("sources/sourcesPanel.css");
37 new WebInspector.DropTarget(this.element, [WebInspector.DropTarget.Types.Files], WebInspector.UIString("Drop workspace folder here"), this._handleDrop.bind(this));
39 this._workspace = workspaceForTest || WebInspector.workspace;
40 this._networkMapping = WebInspector.networkMapping;
42 this._debugToolbar = this._createDebugToolbar();
43 this._debugToolbarDrawer = this._createDebugToolbarDrawer();
45 const initialDebugSidebarWidth = 225;
46 this._splitWidget = new WebInspector.SplitWidget(true, true, "sourcesPanelSplitViewState", initialDebugSidebarWidth);
47 this._splitWidget.enableShowModeSaving();
48 this._splitWidget.show(this.element);
50 // Create scripts navigator
51 const initialNavigatorWidth = 225;
52 this.editorView = new WebInspector.SplitWidget(true, false, "sourcesPanelNavigatorSplitViewState", initialNavigatorWidth);
53 this.editorView.enableShowModeSaving();
54 this.editorView.element.tabIndex = 0;
55 this._splitWidget.setMainWidget(this.editorView);
57 this._navigator = new WebInspector.SourcesNavigator(this._workspace);
58 this._navigator.view.setMinimumSize(100, 25);
59 this.editorView.setSidebarWidget(this._navigator.view);
60 this._navigator.addEventListener(WebInspector.SourcesNavigator.Events.SourceSelected, this._sourceSelected, this);
61 this._navigator.addEventListener(WebInspector.SourcesNavigator.Events.SourceRenamed, this._sourceRenamed, this);
63 this._sourcesView = new WebInspector.SourcesView(this._workspace, this);
64 this._sourcesView.addEventListener(WebInspector.SourcesView.Events.EditorSelected, this._editorSelected.bind(this));
65 this._sourcesView.addEventListener(WebInspector.SourcesView.Events.EditorClosed, this._editorClosed.bind(this));
66 this._sourcesView.registerShortcuts(this.registerShortcuts.bind(this));
67 this.editorView.setMainWidget(this._sourcesView);
69 this.sidebarPanes = {};
70 this.sidebarPanes.threads = new WebInspector.ThreadsSidebarPane();
71 this.sidebarPanes.watchExpressions = new WebInspector.WatchExpressionsSidebarPane();
72 this.sidebarPanes.callstack = new WebInspector.CallStackSidebarPane();
73 this.sidebarPanes.callstack.addEventListener(WebInspector.CallStackSidebarPane.Events.CallFrameSelected, this._callFrameSelectedInSidebar.bind(this));
74 this.sidebarPanes.callstack.addEventListener(WebInspector.CallStackSidebarPane.Events.RevealHiddenCallFrames, this._hiddenCallFramesRevealedInSidebar.bind(this));
75 this.sidebarPanes.callstack.registerShortcuts(this.registerShortcuts.bind(this));
77 this.sidebarPanes.scopechain = new WebInspector.ScopeChainSidebarPane();
78 this.sidebarPanes.serviceWorkers = new WebInspector.ServiceWorkersSidebarPane();
79 this.sidebarPanes.jsBreakpoints = new WebInspector.JavaScriptBreakpointsSidebarPane(WebInspector.breakpointManager, this.showUISourceCode.bind(this));
80 this.sidebarPanes.domBreakpoints = WebInspector.domBreakpointsSidebarPane.createProxy(this);
81 this.sidebarPanes.xhrBreakpoints = new WebInspector.XHRBreakpointsSidebarPane();
82 this.sidebarPanes.eventListenerBreakpoints = new WebInspector.EventListenerBreakpointsSidebarPane();
83 this.sidebarPanes.objectEventListeners = new WebInspector.ObjectEventListenersSidebarPane();
84 if (Runtime.experiments.isEnabled("stepIntoAsync"))
85 this.sidebarPanes.asyncOperationBreakpoints = new WebInspector.AsyncOperationsSidebarPane();
87 this._lastSelectedTabSetting = WebInspector.settings.createLocalSetting("lastSelectedSourcesSidebarPaneTab", this.sidebarPanes.scopechain.title());
89 this._installDebuggerSidebarController();
91 WebInspector.moduleSetting("sidebarPosition").addChangeListener(this._updateSidebarPosition.bind(this));
92 this._updateSidebarPosition();
94 this._updateDebuggerButtons();
95 this._pauseOnExceptionEnabledChanged();
96 WebInspector.moduleSetting("pauseOnExceptionEnabled").addChangeListener(this._pauseOnExceptionEnabledChanged, this);
97 this._setTarget(WebInspector.context.flavor(WebInspector.Target));
98 WebInspector.breakpointManager.addEventListener(WebInspector.BreakpointManager.Events.BreakpointsActiveStateChanged, this._breakpointsActiveStateChanged, this);
99 WebInspector.context.addFlavorChangeListener(WebInspector.Target, this._onCurrentTargetChanged, this);
100 WebInspector.targetManager.addModelListener(WebInspector.DebuggerModel, WebInspector.DebuggerModel.Events.DebuggerWasEnabled, this._debuggerWasEnabled, this);
101 WebInspector.targetManager.addModelListener(WebInspector.DebuggerModel, WebInspector.DebuggerModel.Events.DebuggerWasDisabled, this._debuggerReset, this);
102 WebInspector.targetManager.addModelListener(WebInspector.DebuggerModel, WebInspector.DebuggerModel.Events.DebuggerPaused, this._debuggerPaused, this);
103 WebInspector.targetManager.addModelListener(WebInspector.DebuggerModel, WebInspector.DebuggerModel.Events.DebuggerResumed, this._debuggerResumed, this);
104 WebInspector.targetManager.addModelListener(WebInspector.DebuggerModel, WebInspector.DebuggerModel.Events.CallFrameSelected, this._callFrameSelected, this);
105 WebInspector.targetManager.addModelListener(WebInspector.DebuggerModel, WebInspector.DebuggerModel.Events.ConsoleCommandEvaluatedInSelectedCallFrame, this._consoleCommandEvaluatedInSelectedCallFrame, this);
106 WebInspector.targetManager.addModelListener(WebInspector.DebuggerModel, WebInspector.DebuggerModel.Events.GlobalObjectCleared, this._debuggerReset, this);
107 new WebInspector.WorkspaceMappingTip(this, this._workspace);
108 WebInspector.extensionServer.addEventListener(WebInspector.ExtensionServer.Events.SidebarPaneAdded, this._extensionSidebarPaneAdded, this);
109 WebInspector.DataSaverInfobar.maybeShowInPanel(this);
112 WebInspector.SourcesPanel.minToolbarWidth = 215;
114 WebInspector.SourcesPanel.prototype = {
116 * @param {?WebInspector.Target} target
118 _setTarget: function(target)
120 if (!target)
121 return;
122 var debuggerModel = WebInspector.DebuggerModel.fromTarget(target);
123 if (!debuggerModel)
124 return;
126 if (debuggerModel.isPaused()) {
127 this._showDebuggerPausedDetails(/** @type {!WebInspector.DebuggerPausedDetails} */ (debuggerModel.debuggerPausedDetails()));
128 var callFrame = debuggerModel.selectedCallFrame();
129 if (callFrame)
130 this._selectCallFrame(callFrame);
131 } else {
132 this._paused = false;
133 this._clearInterface();
134 this._toggleDebuggerSidebarButton.disabled = false;
139 * @param {!WebInspector.Event} event
141 _onCurrentTargetChanged: function(event)
143 var target = /** @type {?WebInspector.Target} */ (event.data);
144 this._setTarget(target);
148 * @override
149 * @return {!Element}
151 defaultFocusedElement: function()
153 return this._sourcesView.defaultFocusedElement();
157 * @return {boolean}
159 paused: function()
161 return this._paused;
164 wasShown: function()
166 WebInspector.context.setFlavor(WebInspector.SourcesPanel, this);
167 WebInspector.Panel.prototype.wasShown.call(this);
170 willHide: function()
172 WebInspector.Panel.prototype.willHide.call(this);
173 WebInspector.context.setFlavor(WebInspector.SourcesPanel, null);
176 onResize: function()
178 if (WebInspector.moduleSetting("sidebarPosition").get() === "auto")
179 this.element.window().requestAnimationFrame(this._updateSidebarPosition.bind(this)); // Do not force layout.
183 * @override
184 * @return {!WebInspector.SearchableView}
186 searchableView: function()
188 return this._sourcesView.searchableView();
191 _consoleCommandEvaluatedInSelectedCallFrame: function(event)
193 var debuggerModel = /** @type {!WebInspector.DebuggerModel} */ (event.target);
194 var target = debuggerModel.target();
195 if (WebInspector.context.flavor(WebInspector.Target) !== target)
196 return;
197 this.sidebarPanes.scopechain.update(debuggerModel.selectedCallFrame());
201 * @param {!WebInspector.Event} event
203 _debuggerPaused: function(event)
205 var details = /** @type {!WebInspector.DebuggerPausedDetails} */ (event.data);
206 if (!this._paused)
207 WebInspector.inspectorView.setCurrentPanel(this);
209 if (WebInspector.context.flavor(WebInspector.Target) === details.target())
210 this._showDebuggerPausedDetails(details);
211 else if (!this._paused)
212 WebInspector.context.setFlavor(WebInspector.Target, details.target());
216 * @param {!WebInspector.DebuggerPausedDetails} details
218 _showDebuggerPausedDetails: function(details)
220 this._paused = true;
221 this._updateDebuggerButtons();
223 this.sidebarPanes.callstack.update(details);
226 * @param {!Element} element
227 * @this {WebInspector.SourcesPanel}
229 function didCreateBreakpointHitStatusMessage(element)
231 this.sidebarPanes.callstack.setStatus(element);
235 * @param {!WebInspector.UILocation} uiLocation
236 * @this {WebInspector.SourcesPanel}
238 function didGetUILocation(uiLocation)
240 var breakpoint = WebInspector.breakpointManager.findBreakpointOnLine(uiLocation.uiSourceCode, uiLocation.lineNumber);
241 if (!breakpoint)
242 return;
243 this.sidebarPanes.jsBreakpoints.highlightBreakpoint(breakpoint);
244 this.sidebarPanes.callstack.setStatus(WebInspector.UIString("Paused on a JavaScript breakpoint."));
247 if (details.reason === WebInspector.DebuggerModel.BreakReason.DOM) {
248 WebInspector.domBreakpointsSidebarPane.highlightBreakpoint(details.auxData);
249 WebInspector.domBreakpointsSidebarPane.createBreakpointHitStatusMessage(details, didCreateBreakpointHitStatusMessage.bind(this));
250 } else if (details.reason === WebInspector.DebuggerModel.BreakReason.EventListener) {
251 var eventName = details.auxData["eventName"];
252 var targetName = details.auxData["targetName"];
253 this.sidebarPanes.eventListenerBreakpoints.highlightBreakpoint(eventName, targetName);
254 var eventNameForUI = WebInspector.EventListenerBreakpointsSidebarPane.eventNameForUI(eventName, details.auxData);
255 this.sidebarPanes.callstack.setStatus(WebInspector.UIString("Paused on a \"%s\" Event Listener.", eventNameForUI));
256 } else if (details.reason === WebInspector.DebuggerModel.BreakReason.XHR) {
257 this.sidebarPanes.xhrBreakpoints.highlightBreakpoint(details.auxData["breakpointURL"]);
258 this.sidebarPanes.callstack.setStatus(WebInspector.UIString("Paused on a XMLHttpRequest."));
259 } else if (details.reason === WebInspector.DebuggerModel.BreakReason.Exception) {
260 var description = details.auxData["description"] || "";
261 this.sidebarPanes.callstack.setStatus(WebInspector.UIString("Paused on exception: '%s'.", description.split("\n", 1)[0]));
262 } else if (details.reason === WebInspector.DebuggerModel.BreakReason.PromiseRejection) {
263 var description = details.auxData["description"] || "";
264 this.sidebarPanes.callstack.setStatus(WebInspector.UIString("Paused on promise rejection: '%s'.", description.split("\n", 1)[0]));
265 } else if (details.reason === WebInspector.DebuggerModel.BreakReason.Assert) {
266 this.sidebarPanes.callstack.setStatus(WebInspector.UIString("Paused on assertion."));
267 } else if (details.reason === WebInspector.DebuggerModel.BreakReason.CSPViolation) {
268 this.sidebarPanes.callstack.setStatus(WebInspector.UIString("Paused on a script blocked due to Content Security Policy directive: \"%s\".", details.auxData["directiveText"]));
269 } else if (details.reason === WebInspector.DebuggerModel.BreakReason.DebugCommand) {
270 this.sidebarPanes.callstack.setStatus(WebInspector.UIString("Paused on a debugged function."));
271 } else if (details.reason === WebInspector.DebuggerModel.BreakReason.AsyncOperation) {
272 if (Runtime.experiments.isEnabled("stepIntoAsync")) {
273 var operationId = details.auxData["operationId"];
274 var operation = this.sidebarPanes.asyncOperationBreakpoints.operationById(details.target(), operationId);
275 var description = (operation && operation.description) || WebInspector.UIString("<unknown>");
276 this.sidebarPanes.callstack.setStatus(WebInspector.UIString("Paused on a \"%s\" async operation.", description));
277 this.sidebarPanes.asyncOperationBreakpoints.highlightBreakpoint(operationId);
279 } else {
280 if (details.callFrames.length)
281 WebInspector.debuggerWorkspaceBinding.createCallFrameLiveLocation(details.callFrames[0], didGetUILocation.bind(this));
282 else
283 console.warn("ScriptsPanel paused, but callFrames.length is zero."); // TODO remove this once we understand this case better
286 this._splitWidget.showBoth(true);
287 this._toggleDebuggerSidebarButton.disabled = true;
288 window.focus();
289 InspectorFrontendHost.bringToFront();
293 * @param {!WebInspector.Event} event
295 _debuggerResumed: function(event)
297 var debuggerModel = /** @type {!WebInspector.DebuggerModel} */ (event.target);
298 var target = debuggerModel.target();
299 if (WebInspector.context.flavor(WebInspector.Target) !== target)
300 return;
301 this._paused = false;
302 this._clearInterface();
303 this._toggleDebuggerSidebarButton.disabled = false;
304 this._switchToPausedTargetTimeout = setTimeout(this._switchToPausedTarget.bind(this, debuggerModel), 500);
308 * @param {!WebInspector.Event} event
310 _debuggerWasEnabled: function(event)
312 var target = /** @type {!WebInspector.Target} */ (event.target.target());
313 if (WebInspector.context.flavor(WebInspector.Target) !== target)
314 return;
316 this._updateDebuggerButtons();
320 * @param {!WebInspector.Event} event
322 _debuggerReset: function(event)
324 this._debuggerResumed(event);
328 * @return {!WebInspector.Widget}
330 get visibleView()
332 return this._sourcesView.visibleView();
336 * @param {!WebInspector.UISourceCode} uiSourceCode
337 * @param {number=} lineNumber 0-based
338 * @param {number=} columnNumber
340 showUISourceCode: function(uiSourceCode, lineNumber, columnNumber)
342 this._showEditor();
343 this._sourcesView.showSourceLocation(uiSourceCode, lineNumber, columnNumber);
346 _showEditor: function()
348 WebInspector.inspectorView.setCurrentPanel(this);
352 * @param {!WebInspector.UILocation} uiLocation
354 showUILocation: function(uiLocation)
356 this.showUISourceCode(uiLocation.uiSourceCode, uiLocation.lineNumber, uiLocation.columnNumber);
360 * @param {!WebInspector.UISourceCode} uiSourceCode
362 _revealInNavigator: function(uiSourceCode)
364 this._navigator.revealUISourceCode(uiSourceCode);
368 * @param {boolean} ignoreExecutionLineEvents
370 setIgnoreExecutionLineEvents: function(ignoreExecutionLineEvents)
372 this._ignoreExecutionLineEvents = ignoreExecutionLineEvents;
376 * @param {!WebInspector.UILocation} uiLocation
378 _executionLineChanged: function(uiLocation)
380 this._sourcesView.clearCurrentExecutionLine();
381 this._sourcesView.setExecutionLocation(uiLocation);
382 if (this._ignoreExecutionLineEvents)
383 return;
384 this._sourcesView.showSourceLocation(uiLocation.uiSourceCode, uiLocation.lineNumber, uiLocation.columnNumber, undefined, true);
388 * @param {!WebInspector.Event} event
390 _callFrameSelected: function(event)
392 var callFrame = /** @type {?WebInspector.DebuggerModel.CallFrame} */ (event.data);
394 if (!callFrame || callFrame.target() !== WebInspector.context.flavor(WebInspector.Target))
395 return;
397 this._selectCallFrame(callFrame);
401 * @param {!WebInspector.DebuggerModel.CallFrame} callFrame
403 _selectCallFrame: function(callFrame)
405 this.sidebarPanes.scopechain.update(callFrame);
406 this.sidebarPanes.watchExpressions.refreshExpressions();
407 this.sidebarPanes.callstack.setSelectedCallFrame(callFrame);
408 WebInspector.debuggerWorkspaceBinding.createCallFrameLiveLocation(callFrame, this._executionLineChanged.bind(this));
412 * @param {!WebInspector.Event} event
414 _sourceSelected: function(event)
416 var uiSourceCode = /** @type {!WebInspector.UISourceCode} */ (event.data.uiSourceCode);
417 this._sourcesView.showSourceLocation(uiSourceCode, undefined, undefined, !event.data.focusSource)
421 * @param {!WebInspector.Event} event
423 _sourceRenamed: function(event)
425 var uiSourceCode = /** @type {!WebInspector.UISourceCode} */ (event.data);
426 this._sourcesView.sourceRenamed(uiSourceCode);
429 _pauseOnExceptionEnabledChanged: function()
431 var enabled = WebInspector.moduleSetting("pauseOnExceptionEnabled").get();
432 this._pauseOnExceptionButton.setToggled(enabled);
433 this._pauseOnExceptionButton.setTitle(WebInspector.UIString(enabled ? "Don't pause on exceptions" : "Pause on exceptions"));
434 this._debugToolbarDrawer.classList.toggle("expanded", enabled);
437 _updateDebuggerButtons: function()
439 var currentTarget = WebInspector.context.flavor(WebInspector.Target);
440 var currentDebuggerModel = WebInspector.DebuggerModel.fromTarget(currentTarget);
441 if (!currentDebuggerModel) {
442 this._pauseButton.setEnabled(false);
443 this._stepOverButton.setEnabled(false);
444 this._stepIntoButton.setEnabled(false);
445 this._stepOutButton.setEnabled(false);
446 } else if (this._paused) {
447 this._pauseButton.setTitle(WebInspector.UIString("Resume script execution"));
448 this._pauseButton.setToggled(true);
449 this._pauseButton.setLongClickOptionsEnabled((function() { return [ this._longResumeButton ]; }).bind(this));
451 this._pauseButton.setEnabled(true);
452 this._stepOverButton.setEnabled(true);
453 this._stepIntoButton.setEnabled(true);
454 this._stepOutButton.setEnabled(true);
455 } else {
456 this._pauseButton.setTitle(WebInspector.UIString("Pause script execution"));
457 this._pauseButton.setToggled(false);
458 this._pauseButton.setLongClickOptionsEnabled(null);
460 this._pauseButton.setEnabled(!currentDebuggerModel.isPausing());
461 this._stepOverButton.setEnabled(false);
462 this._stepIntoButton.setEnabled(false);
463 this._stepOutButton.setEnabled(false);
467 _clearInterface: function()
469 this.sidebarPanes.callstack.update(null);
470 this.sidebarPanes.scopechain.update(null);
471 this.sidebarPanes.jsBreakpoints.clearBreakpointHighlight();
472 WebInspector.domBreakpointsSidebarPane.clearBreakpointHighlight();
473 this.sidebarPanes.eventListenerBreakpoints.clearBreakpointHighlight();
474 this.sidebarPanes.xhrBreakpoints.clearBreakpointHighlight();
475 if (this.sidebarPanes.asyncOperationBreakpoints)
476 this.sidebarPanes.asyncOperationBreakpoints.clearBreakpointHighlight();
478 this._sourcesView.clearCurrentExecutionLine();
479 this._updateDebuggerButtons();
481 if (this._switchToPausedTargetTimeout)
482 clearTimeout(this._switchToPausedTargetTimeout);
486 * @param {!WebInspector.DebuggerModel} debuggerModel
488 _switchToPausedTarget: function(debuggerModel)
490 delete this._switchToPausedTargetTimeout;
491 if (this._paused)
492 return;
493 var target = WebInspector.context.flavor(WebInspector.Target);
494 if (debuggerModel.isPaused())
495 return;
496 var debuggerModels = WebInspector.DebuggerModel.instances();
497 for (var i = 0; i < debuggerModels.length; ++i) {
498 if (debuggerModels[i].isPaused()) {
499 WebInspector.context.setFlavor(WebInspector.Target, debuggerModels[i].target());
500 break;
505 _togglePauseOnExceptions: function()
507 WebInspector.moduleSetting("pauseOnExceptionEnabled").set(!this._pauseOnExceptionButton.toggled());
511 * @return {boolean}
513 _runSnippet: function()
515 var uiSourceCode = this._sourcesView.currentUISourceCode();
516 if (uiSourceCode.project().type() !== WebInspector.projectTypes.Snippets)
517 return false;
519 var currentExecutionContext = WebInspector.context.flavor(WebInspector.ExecutionContext);
520 if (!currentExecutionContext)
521 return false;
523 WebInspector.scriptSnippetModel.evaluateScriptSnippet(currentExecutionContext, uiSourceCode);
524 return true;
528 * @param {!WebInspector.Event} event
530 _editorSelected: function(event)
532 var uiSourceCode = /** @type {!WebInspector.UISourceCode} */ (event.data);
533 this._editorChanged(uiSourceCode);
537 * @param {!WebInspector.Event} event
539 _editorClosed: function(event)
541 var wasSelected = /** @type {boolean} */ (event.data.wasSelected);
542 if (wasSelected)
543 this._editorChanged(null);
547 * @param {?WebInspector.UISourceCode} uiSourceCode
549 _editorChanged: function(uiSourceCode)
551 var isSnippet = uiSourceCode && uiSourceCode.project().type() === WebInspector.projectTypes.Snippets;
552 this._runSnippetButton.element.classList.toggle("hidden", !isSnippet);
556 * @return {boolean}
558 togglePause: function()
560 var target = WebInspector.context.flavor(WebInspector.Target);
561 if (!target)
562 return true;
563 var debuggerModel = WebInspector.DebuggerModel.fromTarget(target);
564 if (!debuggerModel)
565 return true;
567 if (this._paused) {
568 this._paused = false;
569 debuggerModel.resume();
570 } else {
571 // Make sure pauses didn't stick skipped.
572 debuggerModel.pause();
575 this._clearInterface();
576 return true;
580 * @return {?WebInspector.DebuggerModel}
582 _prepareToResume: function()
584 if (!this._paused)
585 return null;
587 this._paused = false;
589 this._clearInterface();
590 var target = WebInspector.context.flavor(WebInspector.Target);
591 return target ? WebInspector.DebuggerModel.fromTarget(target) : null;
595 * @return {boolean}
597 _longResume: function()
599 var debuggerModel = this._prepareToResume();
600 if (!debuggerModel)
601 return true;
603 debuggerModel.skipAllPausesUntilReloadOrTimeout(500);
604 debuggerModel.resume();
605 return true;
609 * @return {boolean}
611 _stepOverClicked: function()
613 var debuggerModel = this._prepareToResume();
614 if (!debuggerModel)
615 return true;
617 debuggerModel.stepOver();
618 return true;
622 * @return {boolean}
624 _stepIntoClicked: function()
626 var debuggerModel = this._prepareToResume();
627 if (!debuggerModel)
628 return true;
630 debuggerModel.stepInto();
631 return true;
635 * @return {boolean}
637 _stepIntoAsyncClicked: function()
639 var debuggerModel = this._prepareToResume();
640 if (!debuggerModel)
641 return true;
643 debuggerModel.stepIntoAsync();
644 return true;
648 * @return {boolean}
650 _stepOutClicked: function()
652 var debuggerModel = this._prepareToResume();
653 if (!debuggerModel)
654 return true;
656 debuggerModel.stepOut();
657 return true;
661 * @param {!WebInspector.Event} event
663 _callFrameSelectedInSidebar: function(event)
665 var callFrame = /** @type {!WebInspector.DebuggerModel.CallFrame} */ (event.data);
666 callFrame.debuggerModel.setSelectedCallFrame(callFrame);
669 _hiddenCallFramesRevealedInSidebar: function()
671 if (Runtime.experiments.isEnabled("stepIntoAsync"))
672 this.sidebarPanes.asyncOperationBreakpoints.revealHiddenCallFrames(WebInspector.context.flavor(WebInspector.Target));
676 * @param {!WebInspector.UILocation} uiLocation
678 _continueToLocation: function(uiLocation)
680 var executionContext = WebInspector.context.flavor(WebInspector.ExecutionContext);
681 if (!executionContext)
682 return;
684 // Always use 0 column.
685 var rawLocation = WebInspector.debuggerWorkspaceBinding.uiLocationToRawLocation(executionContext.target(), uiLocation.uiSourceCode, uiLocation.lineNumber, 0);
686 if (!rawLocation)
687 return;
689 if (!this._prepareToResume())
690 return;
692 rawLocation.continueToLocation();
695 _toggleBreakpointsActive: function()
697 WebInspector.breakpointManager.setBreakpointsActive(!WebInspector.breakpointManager.breakpointsActive());
700 _breakpointsActiveStateChanged: function(event)
702 var active = event.data;
703 this._toggleBreakpointsButton.setToggled(!active);
704 this.sidebarPanes.jsBreakpoints.listElement.classList.toggle("breakpoints-list-deactivated", !active);
705 this._sourcesView.toggleBreakpointsActiveState(active);
706 if (active)
707 this._toggleBreakpointsButton.setTitle(WebInspector.UIString("Deactivate breakpoints"));
708 else
709 this._toggleBreakpointsButton.setTitle(WebInspector.UIString("Activate breakpoints"));
713 * @return {!WebInspector.Toolbar}
715 _createDebugToolbar: function()
717 var debugToolbar = new WebInspector.Toolbar();
718 debugToolbar.element.classList.add("scripts-debug-toolbar");
720 var title, handler;
722 // Run snippet.
723 title = WebInspector.UIString("Run snippet");
724 handler = this._runSnippet.bind(this);
725 this._runSnippetButton = this._createButtonAndRegisterShortcutsForAction("play-toolbar-item", title, "debugger.run-snippet");
726 debugToolbar.appendToolbarItem(this._runSnippetButton);
727 this._runSnippetButton.element.classList.add("hidden");
729 // Continue.
730 this._pauseButton = this._createButtonAndRegisterShortcutsForAction("pause-toolbar-item", "", "debugger.toggle-pause");
731 debugToolbar.appendToolbarItem(this._pauseButton);
733 // Long resume.
734 title = WebInspector.UIString("Resume with all pauses blocked for 500 ms");
735 this._longResumeButton = new WebInspector.ToolbarButton(title, "play-toolbar-item");
736 this._longResumeButton.addEventListener("click", this._longResume.bind(this), this);
738 // Step over.
739 title = WebInspector.UIString("Step over next function call");
740 this._stepOverButton = this._createButtonAndRegisterShortcutsForAction("step-over-toolbar-item", title, "debugger.step-over");
741 debugToolbar.appendToolbarItem(this._stepOverButton);
743 // Step into.
744 title = WebInspector.UIString("Step into next function call");
745 this._stepIntoButton = this._createButtonAndRegisterShortcutsForAction("step-in-toolbar-item", title, "debugger.step-into");
746 debugToolbar.appendToolbarItem(this._stepIntoButton);
748 // Step out.
749 title = WebInspector.UIString("Step out of current function");
750 this._stepOutButton = this._createButtonAndRegisterShortcutsForAction("step-out-toolbar-item", title, "debugger.step-out");
751 debugToolbar.appendToolbarItem(this._stepOutButton);
753 debugToolbar.appendSeparator();
755 // Toggle Breakpoints
756 this._toggleBreakpointsButton = WebInspector.ToolbarButton.createActionButton("debugger.toggle-breakpoints-active");
757 this._toggleBreakpointsButton.setToggled(false);
758 debugToolbar.appendToolbarItem(this._toggleBreakpointsButton);
760 // Pause on Exception
761 this._pauseOnExceptionButton = new WebInspector.ToolbarButton("", "pause-on-exceptions-toolbar-item");
762 this._pauseOnExceptionButton.addEventListener("click", this._togglePauseOnExceptions, this);
763 debugToolbar.appendToolbarItem(this._pauseOnExceptionButton);
765 debugToolbar.appendSeparator();
767 // Async operations
768 debugToolbar.appendToolbarItem(new WebInspector.ToolbarCheckbox(WebInspector.UIString("Async"), WebInspector.UIString("Capture async stack traces"), WebInspector.moduleSetting("enableAsyncStackTraces")));
770 return debugToolbar;
773 _createDebugToolbarDrawer: function()
775 var debugToolbarDrawer = createElementWithClass("div", "scripts-debug-toolbar-drawer");
777 var label = WebInspector.UIString("Pause On Caught Exceptions");
778 var setting = WebInspector.moduleSetting("pauseOnCaughtException");
779 debugToolbarDrawer.appendChild(WebInspector.SettingsUI.createSettingCheckbox(label, setting, true));
781 return debugToolbarDrawer;
785 * @param {string} buttonId
786 * @param {string} buttonTitle
787 * @param {string} actionId
788 * @return {!WebInspector.ToolbarButton}
790 _createButtonAndRegisterShortcutsForAction: function(buttonId, buttonTitle, actionId)
792 var button = new WebInspector.ToolbarButton(buttonTitle, buttonId);
793 button.setAction(actionId);
794 button._shortcuts = WebInspector.shortcutRegistry.shortcutDescriptorsForAction(actionId);
795 button.setTitle(buttonTitle);
796 return button;
799 addToWatch: function(expression)
801 this.sidebarPanes.watchExpressions.addExpression(expression);
804 _installDebuggerSidebarController: function()
806 this.editorView.displayShowHideSidebarButton("navigator");
807 this._toggleDebuggerSidebarButton = this._splitWidget.displayShowHideSidebarButton("debugger", "scripts-debugger-show-hide-button");
811 * @param {!WebInspector.UISourceCode} uiSourceCode
813 _showLocalHistory: function(uiSourceCode)
815 WebInspector.RevisionHistoryView.showHistory(uiSourceCode);
819 * @override
820 * @param {!Event} event
821 * @param {!WebInspector.ContextMenu} contextMenu
822 * @param {!Object} target
824 appendApplicableItems: function(event, contextMenu, target)
826 this._appendUISourceCodeItems(event, contextMenu, target);
827 this.appendUILocationItems(contextMenu, target);
828 this._appendRemoteObjectItems(contextMenu, target);
829 this._appendNetworkRequestItems(contextMenu, target);
832 _suggestReload: function()
834 if (window.confirm(WebInspector.UIString("It is recommended to restart inspector after making these changes. Would you like to restart it?")))
835 WebInspector.reload();
839 * @param {!WebInspector.UISourceCode} uiSourceCode
841 mapFileSystemToNetwork: function(uiSourceCode)
843 WebInspector.SelectUISourceCodeForProjectTypesDialog.show(uiSourceCode.name(), [WebInspector.projectTypes.Network, WebInspector.projectTypes.ContentScripts], mapFileSystemToNetwork.bind(this), this._sourcesView.element);
846 * @param {?WebInspector.UISourceCode} networkUISourceCode
847 * @this {WebInspector.SourcesPanel}
849 function mapFileSystemToNetwork(networkUISourceCode)
851 if (!networkUISourceCode)
852 return;
853 this._networkMapping.addMapping(networkUISourceCode, uiSourceCode, WebInspector.fileSystemWorkspaceBinding);
854 this._suggestReload();
859 * @param {!WebInspector.UISourceCode} networkUISourceCode
861 mapNetworkToFileSystem: function(networkUISourceCode)
863 WebInspector.SelectUISourceCodeForProjectTypesDialog.show(networkUISourceCode.name(), [WebInspector.projectTypes.FileSystem], mapNetworkToFileSystem.bind(this), this._sourcesView.element);
866 * @param {?WebInspector.UISourceCode} uiSourceCode
867 * @this {WebInspector.SourcesPanel}
869 function mapNetworkToFileSystem(uiSourceCode)
871 if (!uiSourceCode)
872 return;
873 this._networkMapping.addMapping(networkUISourceCode, uiSourceCode, WebInspector.fileSystemWorkspaceBinding);
874 this._suggestReload();
879 * @param {!WebInspector.UISourceCode} uiSourceCode
881 _removeNetworkMapping: function(uiSourceCode)
883 if (confirm(WebInspector.UIString("Are you sure you want to remove network mapping?"))) {
884 this._networkMapping.removeMapping(uiSourceCode);
885 this._suggestReload();
890 * @param {!WebInspector.ContextMenu} contextMenu
891 * @param {!WebInspector.UISourceCode} uiSourceCode
893 _appendUISourceCodeMappingItems: function(contextMenu, uiSourceCode)
895 WebInspector.NavigatorView.appendAddFolderItem(contextMenu);
896 if (uiSourceCode.project().type() === WebInspector.projectTypes.FileSystem) {
897 var hasMappings = !!this._networkMapping.networkURL(uiSourceCode);
898 if (!hasMappings)
899 contextMenu.appendItem(WebInspector.UIString.capitalize("Map to ^network ^resource\u2026"), this.mapFileSystemToNetwork.bind(this, uiSourceCode));
900 else
901 contextMenu.appendItem(WebInspector.UIString.capitalize("Remove ^network ^mapping"), this._removeNetworkMapping.bind(this, uiSourceCode));
905 * @param {!WebInspector.Project} project
907 function filterProject(project)
909 return project.type() === WebInspector.projectTypes.FileSystem;
912 if (uiSourceCode.project().type() === WebInspector.projectTypes.Network || uiSourceCode.project().type() === WebInspector.projectTypes.ContentScripts) {
913 if (!this._workspace.projects().filter(filterProject).length)
914 return;
915 var networkURL = this._networkMapping.networkURL(uiSourceCode);
916 if (this._networkMapping.uiSourceCodeForURLForAnyTarget(networkURL) === uiSourceCode)
917 contextMenu.appendItem(WebInspector.UIString.capitalize("Map to ^file ^system ^resource\u2026"), this.mapNetworkToFileSystem.bind(this, uiSourceCode));
922 * @param {!Event} event
923 * @param {!WebInspector.ContextMenu} contextMenu
924 * @param {!Object} target
926 _appendUISourceCodeItems: function(event, contextMenu, target)
928 if (!(target instanceof WebInspector.UISourceCode))
929 return;
931 var uiSourceCode = /** @type {!WebInspector.UISourceCode} */ (target);
932 var projectType = uiSourceCode.project().type();
934 if (projectType !== WebInspector.projectTypes.Debugger && !event.target.isSelfOrDescendant(this._navigator.view.element)) {
935 contextMenu.appendItem(WebInspector.UIString.capitalize("Reveal in ^navigator"), this._handleContextMenuReveal.bind(this, uiSourceCode));
936 contextMenu.appendSeparator();
938 this._appendUISourceCodeMappingItems(contextMenu, uiSourceCode);
939 if (projectType !== WebInspector.projectTypes.FileSystem)
940 contextMenu.appendItem(WebInspector.UIString.capitalize("Local ^modifications\u2026"), this._showLocalHistory.bind(this, uiSourceCode));
944 * @param {!WebInspector.ContextMenu} contextMenu
945 * @param {!Object} object
947 appendUILocationItems: function(contextMenu, object)
949 if (!(object instanceof WebInspector.UILocation))
950 return;
951 var uiLocation = /** @type {!WebInspector.UILocation} */ (object);
952 var uiSourceCode = uiLocation.uiSourceCode;
953 var projectType = uiSourceCode.project().type();
955 var contentType = uiSourceCode.contentType();
956 if (contentType === WebInspector.resourceTypes.Script || contentType === WebInspector.resourceTypes.Document) {
957 var target = WebInspector.context.flavor(WebInspector.Target);
958 var debuggerModel = WebInspector.DebuggerModel.fromTarget(target);
959 if (debuggerModel && debuggerModel.isPaused())
960 contextMenu.appendItem(WebInspector.UIString.capitalize("Continue to ^here"), this._continueToLocation.bind(this, uiLocation));
963 if ((contentType === WebInspector.resourceTypes.Script || contentType === WebInspector.resourceTypes.Document) && projectType !== WebInspector.projectTypes.Snippets) {
964 var networkURL = this._networkMapping.networkURL(uiSourceCode);
965 var url = projectType === WebInspector.projectTypes.Formatter ? uiSourceCode.originURL() : networkURL;
966 this.sidebarPanes.callstack.appendBlackboxURLContextMenuItems(contextMenu, url, projectType === WebInspector.projectTypes.ContentScripts);
971 * @param {!WebInspector.UISourceCode} uiSourceCode
973 _handleContextMenuReveal: function(uiSourceCode)
975 this.editorView.showBoth();
976 this._revealInNavigator(uiSourceCode);
980 * @param {!WebInspector.ContextMenu} contextMenu
981 * @param {!Object} target
983 _appendRemoteObjectItems: function(contextMenu, target)
985 if (!(target instanceof WebInspector.RemoteObject))
986 return;
987 var remoteObject = /** @type {!WebInspector.RemoteObject} */ (target);
988 contextMenu.appendItem(WebInspector.UIString.capitalize("Store as ^global ^variable"), this._saveToTempVariable.bind(this, remoteObject));
989 if (remoteObject.type === "function")
990 contextMenu.appendItem(WebInspector.UIString.capitalize("Show ^function ^definition"), this._showFunctionDefinition.bind(this, remoteObject));
991 if (remoteObject.subtype === "generator")
992 contextMenu.appendItem(WebInspector.UIString.capitalize("Show ^generator ^location"), this._showGeneratorLocation.bind(this, remoteObject));
996 * @param {!WebInspector.ContextMenu} contextMenu
997 * @param {!Object} target
999 _appendNetworkRequestItems: function(contextMenu, target)
1001 if (!(target instanceof WebInspector.NetworkRequest))
1002 return;
1003 var request = /** @type {!WebInspector.NetworkRequest} */ (target);
1004 var uiSourceCode = this._networkMapping.uiSourceCodeForURLForAnyTarget(request.url);
1005 if (!uiSourceCode)
1006 return;
1007 var openText = WebInspector.UIString.capitalize("Open in Sources ^panel");
1008 contextMenu.appendItem(openText, this.showUILocation.bind(this, uiSourceCode.uiLocation(0, 0)));
1012 * @param {!WebInspector.RemoteObject} remoteObject
1014 _saveToTempVariable: function(remoteObject)
1016 var currentExecutionContext = WebInspector.context.flavor(WebInspector.ExecutionContext);
1017 if (!currentExecutionContext)
1018 return;
1020 currentExecutionContext.globalObject("", false, false, didGetGlobalObject);
1022 * @param {?WebInspector.RemoteObject} global
1023 * @param {boolean=} wasThrown
1025 function didGetGlobalObject(global, wasThrown)
1028 * @suppressReceiverCheck
1029 * @this {Window}
1031 function remoteFunction(value)
1033 var prefix = "temp";
1034 var index = 1;
1035 while ((prefix + index) in this)
1036 ++index;
1037 var name = prefix + index;
1038 this[name] = value;
1039 return name;
1042 if (wasThrown || !global)
1043 failedToSave(global);
1044 else
1045 global.callFunction(remoteFunction, [WebInspector.RemoteObject.toCallArgument(remoteObject)], didSave.bind(null, global));
1049 * @param {!WebInspector.RemoteObject} global
1050 * @param {?WebInspector.RemoteObject} result
1051 * @param {boolean=} wasThrown
1053 function didSave(global, result, wasThrown)
1055 global.release();
1056 if (wasThrown || !result || result.type !== "string")
1057 failedToSave(result);
1058 else
1059 WebInspector.ConsoleModel.evaluateCommandInConsole(currentExecutionContext, result.value);
1063 * @param {?WebInspector.RemoteObject} result
1065 function failedToSave(result)
1067 var message = WebInspector.UIString("Failed to save to temp variable.");
1068 if (result) {
1069 message += " " + result.description;
1070 result.release();
1072 WebInspector.console.error(message);
1077 * @param {!WebInspector.RemoteObject} remoteObject
1079 _showFunctionDefinition: function(remoteObject)
1081 remoteObject.debuggerModel().functionDetails(remoteObject, this._didGetFunctionOrGeneratorObjectDetails.bind(this));
1085 * @param {!WebInspector.RemoteObject} remoteObject
1087 _showGeneratorLocation: function(remoteObject)
1089 remoteObject.debuggerModel().generatorObjectDetails(remoteObject, this._didGetFunctionOrGeneratorObjectDetails.bind(this));
1093 * @param {?{location: ?WebInspector.DebuggerModel.Location}} response
1095 _didGetFunctionOrGeneratorObjectDetails: function(response)
1097 if (!response || !response.location)
1098 return;
1100 var location = response.location;
1101 if (!location)
1102 return;
1104 var uiLocation = WebInspector.debuggerWorkspaceBinding.rawLocationToUILocation(location);
1105 if (uiLocation)
1106 this.showUILocation(uiLocation);
1109 showGoToSourceDialog: function()
1111 this._sourcesView.showOpenResourceDialog();
1114 _updateSidebarPosition: function()
1116 var vertically;
1117 var position = WebInspector.moduleSetting("sidebarPosition").get();
1118 if (position === "right")
1119 vertically = false;
1120 else if (position === "bottom")
1121 vertically = true;
1122 else
1123 vertically = WebInspector.inspectorView.element.offsetWidth < 680;
1125 if (this.sidebarPaneView && vertically === !this._splitWidget.isVertical())
1126 return;
1128 if (this.sidebarPaneView && this.sidebarPaneView.shouldHideOnDetach())
1129 return; // We can't reparent extension iframes.
1131 if (this.sidebarPaneView)
1132 this.sidebarPaneView.detach();
1134 this._splitWidget.setVertical(!vertically);
1135 this._splitWidget.element.classList.toggle("sources-split-view-vertical", vertically);
1137 if (!vertically)
1138 this._splitWidget.uninstallResizer(this._sourcesView.toolbarContainerElement());
1139 else
1140 this._splitWidget.installResizer(this._sourcesView.toolbarContainerElement());
1142 // Create vertical box with stack.
1143 var vbox = new WebInspector.VBox();
1144 vbox.element.appendChild(this._debugToolbarDrawer);
1145 vbox.setMinimumAndPreferredSizes(25, 25, WebInspector.SourcesPanel.minToolbarWidth, 100);
1146 var sidebarPaneStack = new WebInspector.SidebarPaneStack();
1147 sidebarPaneStack.element.classList.add("flex-auto");
1148 sidebarPaneStack.show(vbox.element);
1149 vbox.element.appendChild(this._debugToolbar.element);
1151 if (!vertically) {
1152 // Populate the only stack.
1153 for (var pane in this.sidebarPanes)
1154 sidebarPaneStack.addPane(this.sidebarPanes[pane]);
1155 this._extensionSidebarPanesContainer = sidebarPaneStack;
1156 this.sidebarPaneView = vbox;
1158 this.sidebarPanes.scopechain.expand();
1159 this.sidebarPanes.watchExpressions.expandIfNecessary();
1160 } else {
1161 var splitWidget = new WebInspector.SplitWidget(true, true, "sourcesPanelDebuggerSidebarSplitViewState", 0.5);
1162 splitWidget.setMainWidget(vbox);
1164 // Populate the left stack.
1165 sidebarPaneStack.addPane(this.sidebarPanes.threads);
1166 sidebarPaneStack.addPane(this.sidebarPanes.callstack);
1167 sidebarPaneStack.addPane(this.sidebarPanes.jsBreakpoints);
1168 sidebarPaneStack.addPane(this.sidebarPanes.domBreakpoints);
1169 sidebarPaneStack.addPane(this.sidebarPanes.xhrBreakpoints);
1170 sidebarPaneStack.addPane(this.sidebarPanes.eventListenerBreakpoints);
1171 sidebarPaneStack.addPane(this.sidebarPanes.objectEventListeners);
1172 if (Runtime.experiments.isEnabled("stepIntoAsync"))
1173 sidebarPaneStack.addPane(this.sidebarPanes.asyncOperationBreakpoints);
1175 var tabbedPane = new WebInspector.SidebarTabbedPane();
1176 splitWidget.setSidebarWidget(tabbedPane);
1177 tabbedPane.addPane(this.sidebarPanes.scopechain);
1178 tabbedPane.addPane(this.sidebarPanes.watchExpressions);
1179 if (this.sidebarPanes.serviceWorkers)
1180 tabbedPane.addPane(this.sidebarPanes.serviceWorkers);
1181 tabbedPane.selectTab(this._lastSelectedTabSetting.get());
1182 tabbedPane.addEventListener(WebInspector.TabbedPane.EventTypes.TabSelected, this._tabSelected, this);
1183 this._extensionSidebarPanesContainer = tabbedPane;
1184 this.sidebarPaneView = splitWidget;
1187 var extensionSidebarPanes = WebInspector.extensionServer.sidebarPanes();
1188 for (var i = 0; i < extensionSidebarPanes.length; ++i)
1189 this._addExtensionSidebarPane(extensionSidebarPanes[i]);
1191 this._splitWidget.setSidebarWidget(this.sidebarPaneView);
1192 this.sidebarPanes.threads.expand();
1193 this.sidebarPanes.jsBreakpoints.expand();
1194 this.sidebarPanes.callstack.expand();
1198 * @param {!WebInspector.Event} event
1200 _tabSelected: function(event)
1202 this._lastSelectedTabSetting.set(event.data.tabId);
1206 * @param {!WebInspector.Event} event
1208 _extensionSidebarPaneAdded: function(event)
1210 var pane = /** @type {!WebInspector.ExtensionSidebarPane} */ (event.data);
1211 this._addExtensionSidebarPane(pane);
1215 * @param {!WebInspector.ExtensionSidebarPane} pane
1217 _addExtensionSidebarPane: function(pane)
1219 if (pane.panelName() === this.name)
1220 this._extensionSidebarPanesContainer.addPane(pane);
1224 * @return {!WebInspector.SourcesView}
1226 sourcesView: function()
1228 return this._sourcesView;
1232 * @param {!DataTransfer} dataTransfer
1234 _handleDrop: function(dataTransfer)
1236 var items = dataTransfer.items;
1237 if (!items.length)
1238 return;
1239 var entry = items[0].webkitGetAsEntry();
1240 if (!entry.isDirectory)
1241 return;
1242 InspectorFrontendHost.upgradeDraggedFileSystemPermissions(entry.filesystem);
1245 __proto__: WebInspector.Panel.prototype
1249 * @constructor
1250 * @implements {WebInspector.ContextMenu.Provider}
1252 WebInspector.SourcesPanel.ContextMenuProvider = function()
1256 WebInspector.SourcesPanel.ContextMenuProvider.prototype = {
1258 * @override
1259 * @param {!Event} event
1260 * @param {!WebInspector.ContextMenu} contextMenu
1261 * @param {!Object} target
1263 appendApplicableItems: function(event, contextMenu, target)
1265 WebInspector.SourcesPanel.instance().appendApplicableItems(event, contextMenu, target);
1270 * @constructor
1271 * @implements {WebInspector.Revealer}
1273 WebInspector.SourcesPanel.UILocationRevealer = function()
1277 WebInspector.SourcesPanel.UILocationRevealer.prototype = {
1279 * @override
1280 * @param {!Object} uiLocation
1281 * @return {!Promise}
1283 reveal: function(uiLocation)
1285 if (!(uiLocation instanceof WebInspector.UILocation))
1286 return Promise.reject(new Error("Internal error: not a ui location"));
1287 WebInspector.SourcesPanel.instance().showUILocation(uiLocation);
1288 return Promise.resolve();
1293 * @constructor
1294 * @implements {WebInspector.Revealer}
1296 WebInspector.SourcesPanel.DebuggerLocationRevealer = function()
1300 WebInspector.SourcesPanel.DebuggerLocationRevealer.prototype = {
1302 * @override
1303 * @param {!Object} rawLocation
1304 * @return {!Promise}
1306 reveal: function(rawLocation)
1308 if (!(rawLocation instanceof WebInspector.DebuggerModel.Location))
1309 return Promise.reject(new Error("Internal error: not a debugger location"));
1310 WebInspector.SourcesPanel.instance().showUILocation(WebInspector.debuggerWorkspaceBinding.rawLocationToUILocation(rawLocation));
1311 return Promise.resolve();
1316 * @constructor
1317 * @implements {WebInspector.Revealer}
1319 WebInspector.SourcesPanel.UISourceCodeRevealer = function()
1323 WebInspector.SourcesPanel.UISourceCodeRevealer.prototype = {
1325 * @override
1326 * @param {!Object} uiSourceCode
1327 * @return {!Promise}
1329 reveal: function(uiSourceCode)
1331 if (!(uiSourceCode instanceof WebInspector.UISourceCode))
1332 return Promise.reject(new Error("Internal error: not a ui source code"));
1333 WebInspector.SourcesPanel.instance().showUISourceCode(uiSourceCode);
1334 return Promise.resolve();
1339 * @constructor
1340 * @implements {WebInspector.Revealer}
1342 WebInspector.SourcesPanel.DebuggerPausedDetailsRevealer = function()
1346 WebInspector.SourcesPanel.DebuggerPausedDetailsRevealer.prototype = {
1348 * @override
1349 * @param {!Object} object
1350 * @return {!Promise}
1352 reveal: function(object)
1354 WebInspector.inspectorView.setCurrentPanel(WebInspector.SourcesPanel.instance());
1355 return Promise.resolve();
1360 * @constructor
1361 * @implements {WebInspector.ActionDelegate}
1363 WebInspector.SourcesPanel.RevealingActionDelegate = function() {}
1365 WebInspector.SourcesPanel.RevealingActionDelegate.prototype = {
1367 * @override
1368 * @param {!WebInspector.Context} context
1369 * @param {string} actionId
1371 handleAction: function(context, actionId)
1373 var panel = WebInspector.SourcesPanel.instance();
1374 WebInspector.inspectorView.setCurrentPanel(panel);
1375 switch (actionId) {
1376 case "debugger.toggle-pause":
1377 panel.togglePause();
1378 break;
1379 case "sources.go-to-source":
1380 panel.showGoToSourceDialog();
1381 break;
1387 * @constructor
1388 * @implements {WebInspector.ActionDelegate}
1390 WebInspector.SourcesPanel.DebuggingActionDelegate = function()
1394 WebInspector.SourcesPanel.DebuggingActionDelegate.prototype = {
1396 * @override
1397 * @param {!WebInspector.Context} context
1398 * @param {string} actionId
1400 handleAction: function(context, actionId)
1402 var panel = WebInspector.SourcesPanel.instance();
1403 switch (actionId) {
1404 case "debugger.step-over":
1405 panel._stepOverClicked();
1406 break;
1407 case "debugger.step-into":
1408 panel._stepIntoClicked();
1409 break;
1410 case "debugger.step-into-async":
1411 panel._stepIntoAsyncClicked();
1412 break;
1413 case "debugger.step-out":
1414 panel._stepOutClicked();
1415 break;
1416 case "debugger.run-snippet":
1417 panel._runSnippet();
1418 break;
1419 case "debugger.toggle-breakpoints-active":
1420 panel._toggleBreakpointsActive();
1421 break;
1426 WebInspector.SourcesPanel.show = function()
1428 WebInspector.inspectorView.setCurrentPanel(WebInspector.SourcesPanel.instance());
1432 * @return {!WebInspector.SourcesPanel}
1434 WebInspector.SourcesPanel.instance = function()
1436 if (!WebInspector.SourcesPanel._instanceObject)
1437 WebInspector.SourcesPanel._instanceObject = new WebInspector.SourcesPanel();
1438 return WebInspector.SourcesPanel._instanceObject;
1442 * @constructor
1443 * @implements {WebInspector.PanelFactory}
1445 WebInspector.SourcesPanelFactory = function()
1449 WebInspector.SourcesPanelFactory.prototype = {
1451 * @override
1452 * @return {!WebInspector.Panel}
1454 createPanel: function()
1456 return WebInspector.SourcesPanel.instance();