Upstream version 7.35.144.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / Source / devtools / front_end / SourcesPanel.js
1 /*
2  * Copyright (C) 2008 Apple Inc. All Rights Reserved.
3  * Copyright (C) 2011 Google Inc. All rights reserved.
4  *
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.
13  *
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.
25  */
26
27 importScript("BreakpointsSidebarPane.js");
28 importScript("CallStackSidebarPane.js");
29 importScript("SimpleHistoryManager.js");
30 importScript("EditingLocationHistoryManager.js");
31 importScript("FilePathScoreFunction.js");
32 importScript("FilteredItemSelectionDialog.js");
33 importScript("UISourceCodeFrame.js");
34 importScript("JavaScriptSourceFrame.js");
35 importScript("CSSSourceFrame.js");
36 importScript("NavigatorView.js");
37 importScript("RevisionHistoryView.js");
38 importScript("ScopeChainSidebarPane.js");
39 importScript("SourcesNavigator.js");
40 importScript("SourcesSearchScope.js");
41 importScript("StyleSheetOutlineDialog.js");
42 importScript("TabbedEditorContainer.js");
43 importScript("WatchExpressionsSidebarPane.js");
44 importScript("WorkersSidebarPane.js");
45 importScript("ThreadsToolbar.js");
46 importScript("ScriptFormatterEditorAction.js");
47 importScript("InplaceFormatterEditorAction.js");
48 importScript("ScriptFormatter.js");
49 importScript("SourcesView.js");
50
51 /**
52  * @constructor
53  * @implements {WebInspector.ContextMenu.Provider}
54  * @extends {WebInspector.Panel}
55  * @param {!WebInspector.Workspace=} workspaceForTest
56  */
57 WebInspector.SourcesPanel = function(workspaceForTest)
58 {
59     WebInspector.Panel.call(this, "sources");
60     this.registerRequiredCSS("sourcesPanel.css");
61     this.registerRequiredCSS("textPrompt.css"); // Watch Expressions autocomplete.
62     new WebInspector.UpgradeFileSystemDropTarget(this.element);
63
64     WebInspector.settings.showEditorInDrawer = WebInspector.settings.createSetting("showEditorInDrawer", true);
65
66     this._workspace = workspaceForTest || WebInspector.workspace;
67
68     var helpSection = WebInspector.shortcutsScreen.section(WebInspector.UIString("Sources Panel"));
69     this.debugToolbar = this._createDebugToolbar();
70     this._debugToolbarDrawer = this._createDebugToolbarDrawer();
71     this.threadsToolbar = new WebInspector.ThreadsToolbar();
72
73     const initialDebugSidebarWidth = 225;
74     this._splitView = new WebInspector.SplitView(true, true, "sourcesPanelSplitViewState", initialDebugSidebarWidth);
75     this._splitView.enableShowModeSaving();
76     this._splitView.show(this.element);
77
78     // Create scripts navigator
79     const initialNavigatorWidth = 225;
80     this.editorView = new WebInspector.SplitView(true, false, "sourcesPanelNavigatorSplitViewState", initialNavigatorWidth);
81     this.editorView.enableShowModeSaving();
82     this.editorView.element.id = "scripts-editor-split-view";
83     this.editorView.element.tabIndex = 0;
84     this.editorView.show(this._splitView.mainElement());
85
86     this._navigator = new WebInspector.SourcesNavigator(this._workspace);
87     this._navigator.view.setMinimumSize(Preferences.minSidebarWidth, 25);
88     this._navigator.view.show(this.editorView.sidebarElement());
89     this._navigator.addEventListener(WebInspector.SourcesNavigator.Events.SourceSelected, this._sourceSelected, this);
90     this._navigator.addEventListener(WebInspector.SourcesNavigator.Events.SourceRenamed, this._sourceRenamed, this);
91
92     this._sourcesView = new WebInspector.SourcesView(this._workspace, this);
93     this._sourcesView.addEventListener(WebInspector.SourcesView.Events.EditorSelected, this._editorSelected.bind(this));
94     this._sourcesView.addEventListener(WebInspector.SourcesView.Events.EditorClosed, this._editorClosed.bind(this));
95     this._sourcesView.registerShortcuts(this.registerShortcuts.bind(this));
96
97     this._drawerEditorView = new WebInspector.SourcesPanel.DrawerEditorView();
98     this._sourcesView.show(this._drawerEditorView.element);
99
100     this._debugSidebarResizeWidgetElement = document.createElementWithClass("div", "resizer-widget");
101     this._debugSidebarResizeWidgetElement.id = "scripts-debug-sidebar-resizer-widget";
102     this._splitView.addEventListener(WebInspector.SplitView.Events.ShowModeChanged, this._updateDebugSidebarResizeWidget, this);
103     this._updateDebugSidebarResizeWidget();
104     this._splitView.installResizer(this._debugSidebarResizeWidgetElement);
105
106     this.sidebarPanes = {};
107     this.sidebarPanes.watchExpressions = new WebInspector.WatchExpressionsSidebarPane();
108     this.sidebarPanes.callstack = new WebInspector.CallStackSidebarPane();
109     this.sidebarPanes.callstack.addEventListener(WebInspector.CallStackSidebarPane.Events.CallFrameSelected, this._callFrameSelectedInSidebar.bind(this));
110     this.sidebarPanes.callstack.addEventListener(WebInspector.CallStackSidebarPane.Events.CallFrameRestarted, this._callFrameRestartedInSidebar.bind(this));
111     this.sidebarPanes.callstack.registerShortcuts(this.registerShortcuts.bind(this));
112
113     this.sidebarPanes.scopechain = new WebInspector.ScopeChainSidebarPane();
114     this.sidebarPanes.jsBreakpoints = new WebInspector.JavaScriptBreakpointsSidebarPane(WebInspector.debuggerModel, WebInspector.breakpointManager, this.showUISourceCode.bind(this));
115     this.sidebarPanes.domBreakpoints = WebInspector.domBreakpointsSidebarPane.createProxy(this);
116     this.sidebarPanes.xhrBreakpoints = new WebInspector.XHRBreakpointsSidebarPane();
117     this.sidebarPanes.eventListenerBreakpoints = new WebInspector.EventListenerBreakpointsSidebarPane();
118
119     if (Capabilities.isMainFrontend)
120         this.sidebarPanes.workerList = new WebInspector.WorkersSidebarPane();
121
122     this._extensionSidebarPanes = [];
123
124     this._installDebuggerSidebarController();
125
126     WebInspector.dockController.addEventListener(WebInspector.DockController.Events.DockSideChanged, this._dockSideChanged.bind(this));
127     WebInspector.settings.splitVerticallyWhenDockedToRight.addChangeListener(this._dockSideChanged.bind(this));
128     this._dockSideChanged();
129
130     this._updateDebuggerButtons();
131     this._pauseOnExceptionEnabledChanged();
132     if (WebInspector.debuggerModel.isPaused())
133         this._showDebuggerPausedDetails();
134
135     WebInspector.settings.pauseOnExceptionEnabled.addChangeListener(this._pauseOnExceptionEnabledChanged, this);
136     WebInspector.debuggerModel.addEventListener(WebInspector.DebuggerModel.Events.DebuggerWasEnabled, this._debuggerWasEnabled, this);
137     WebInspector.debuggerModel.addEventListener(WebInspector.DebuggerModel.Events.DebuggerWasDisabled, this._debuggerWasDisabled, this);
138     WebInspector.debuggerModel.addEventListener(WebInspector.DebuggerModel.Events.DebuggerPaused, this._debuggerPaused, this);
139     WebInspector.debuggerModel.addEventListener(WebInspector.DebuggerModel.Events.DebuggerResumed, this._debuggerResumed, this);
140     WebInspector.debuggerModel.addEventListener(WebInspector.DebuggerModel.Events.CallFrameSelected, this._callFrameSelected, this);
141     WebInspector.debuggerModel.addEventListener(WebInspector.DebuggerModel.Events.ConsoleCommandEvaluatedInSelectedCallFrame, this._consoleCommandEvaluatedInSelectedCallFrame, this);
142     WebInspector.debuggerModel.addEventListener(WebInspector.DebuggerModel.Events.BreakpointsActiveStateChanged, this._breakpointsActiveStateChanged, this);
143     WebInspector.debuggerModel.addEventListener(WebInspector.DebuggerModel.Events.GlobalObjectCleared, this._debuggerReset, this);
144 }
145
146 WebInspector.SourcesPanel.minToolbarWidth = 215;
147
148 WebInspector.SourcesPanel.prototype = {
149     /**
150      * @return {!Element}
151      */
152     defaultFocusedElement: function()
153     {
154         return this._sourcesView.defaultFocusedElement() || this._navigator.view.defaultFocusedElement();
155     },
156
157     get paused()
158     {
159         return this._paused;
160     },
161
162     /**
163      * @return {!WebInspector.SourcesPanel.DrawerEditor}
164      */
165     _drawerEditor: function()
166     {
167         var drawerEditorInstance = WebInspector.moduleManager.instance(WebInspector.DrawerEditor);
168         console.assert(drawerEditorInstance instanceof WebInspector.SourcesPanel.DrawerEditor, "WebInspector.DrawerEditor module instance does not use WebInspector.SourcesPanel.DrawerEditor as an implementation. ");
169         return /** @type {!WebInspector.SourcesPanel.DrawerEditor} */ (drawerEditorInstance);
170     },
171
172     wasShown: function()
173     {
174         this._drawerEditor()._panelWasShown();
175         this._sourcesView.show(this.editorView.mainElement());
176         WebInspector.Panel.prototype.wasShown.call(this);
177     },
178
179     willHide: function()
180     {
181         WebInspector.Panel.prototype.willHide.call(this);
182         this._drawerEditor()._panelWillHide();
183         this._sourcesView.show(this._drawerEditorView.element);
184     },
185
186     /**
187      * @return {!WebInspector.SearchableView}
188      */
189     searchableView: function()
190     {
191         return this._sourcesView.searchableView();
192     },
193
194     _consoleCommandEvaluatedInSelectedCallFrame: function(event)
195     {
196         this.sidebarPanes.scopechain.update(WebInspector.debuggerModel.selectedCallFrame());
197     },
198
199     _debuggerPaused: function()
200     {
201         WebInspector.inspectorView.setCurrentPanel(this);
202         this._showDebuggerPausedDetails();
203     },
204
205     _showDebuggerPausedDetails: function()
206     {
207         var details = WebInspector.debuggerModel.debuggerPausedDetails();
208
209         this._paused = true;
210         this._waitingToPause = false;
211
212         this._updateDebuggerButtons();
213
214         this.sidebarPanes.callstack.update(details.callFrames, details.asyncStackTrace);
215
216         /**
217          * @param {!Element} element
218          * @this {WebInspector.SourcesPanel}
219          */
220         function didCreateBreakpointHitStatusMessage(element)
221         {
222             this.sidebarPanes.callstack.setStatus(element);
223         }
224
225         /**
226          * @param {!WebInspector.UILocation} uiLocation
227          * @this {WebInspector.SourcesPanel}
228          */
229         function didGetUILocation(uiLocation)
230         {
231             var breakpoint = WebInspector.breakpointManager.findBreakpointOnLine(uiLocation.uiSourceCode, uiLocation.lineNumber);
232             if (!breakpoint)
233                 return;
234             this.sidebarPanes.jsBreakpoints.highlightBreakpoint(breakpoint);
235             this.sidebarPanes.callstack.setStatus(WebInspector.UIString("Paused on a JavaScript breakpoint."));
236         }
237
238         if (details.reason === WebInspector.DebuggerModel.BreakReason.DOM) {
239             WebInspector.domBreakpointsSidebarPane.highlightBreakpoint(details.auxData);
240             WebInspector.domBreakpointsSidebarPane.createBreakpointHitStatusMessage(details.auxData, didCreateBreakpointHitStatusMessage.bind(this));
241         } else if (details.reason === WebInspector.DebuggerModel.BreakReason.EventListener) {
242             var eventName = details.auxData.eventName;
243             this.sidebarPanes.eventListenerBreakpoints.highlightBreakpoint(details.auxData.eventName);
244             var eventNameForUI = WebInspector.EventListenerBreakpointsSidebarPane.eventNameForUI(eventName, details.auxData);
245             this.sidebarPanes.callstack.setStatus(WebInspector.UIString("Paused on a \"%s\" Event Listener.", eventNameForUI));
246         } else if (details.reason === WebInspector.DebuggerModel.BreakReason.XHR) {
247             this.sidebarPanes.xhrBreakpoints.highlightBreakpoint(details.auxData["breakpointURL"]);
248             this.sidebarPanes.callstack.setStatus(WebInspector.UIString("Paused on a XMLHttpRequest."));
249         } else if (details.reason === WebInspector.DebuggerModel.BreakReason.Exception)
250             this.sidebarPanes.callstack.setStatus(WebInspector.UIString("Paused on exception: '%s'.", details.auxData.description));
251         else if (details.reason === WebInspector.DebuggerModel.BreakReason.Assert)
252             this.sidebarPanes.callstack.setStatus(WebInspector.UIString("Paused on assertion."));
253         else if (details.reason === WebInspector.DebuggerModel.BreakReason.CSPViolation)
254             this.sidebarPanes.callstack.setStatus(WebInspector.UIString("Paused on a script blocked due to Content Security Policy directive: \"%s\".", details.auxData["directiveText"]));
255         else if (details.reason === WebInspector.DebuggerModel.BreakReason.DebugCommand)
256             this.sidebarPanes.callstack.setStatus(WebInspector.UIString("Paused on a debugged function"));
257         else {
258             if (details.callFrames.length)
259                 details.callFrames[0].createLiveLocation(didGetUILocation.bind(this));
260             else
261                 console.warn("ScriptsPanel paused, but callFrames.length is zero."); // TODO remove this once we understand this case better
262         }
263
264         this._splitView.showBoth(true);
265         this._toggleDebuggerSidebarButton.setEnabled(false);
266         window.focus();
267         InspectorFrontendHost.bringToFront();
268     },
269
270     _debuggerResumed: function()
271     {
272         this._paused = false;
273         this._waitingToPause = false;
274
275         this._clearInterface();
276         this._toggleDebuggerSidebarButton.setEnabled(true);
277     },
278
279     _debuggerWasEnabled: function()
280     {
281         this._updateDebuggerButtons();
282     },
283
284     _debuggerWasDisabled: function()
285     {
286         this._debuggerReset();
287     },
288
289     _debuggerReset: function()
290     {
291         this._debuggerResumed();
292         this.sidebarPanes.watchExpressions.reset();
293         delete this._skipExecutionLineRevealing;
294     },
295
296     /**
297      * @return {!WebInspector.View}
298      */
299     get visibleView()
300     {
301         return this._sourcesView.visibleView();
302     },
303
304     /**
305      * @param {!WebInspector.UISourceCode} uiSourceCode
306      * @param {number=} lineNumber
307      * @param {number=} columnNumber
308      * @param {boolean=} forceShowInPanel
309      */
310     showUISourceCode: function(uiSourceCode, lineNumber, columnNumber, forceShowInPanel)
311     {
312         this._showEditor(forceShowInPanel);
313         this._sourcesView.showSourceLocation(uiSourceCode, lineNumber, columnNumber);
314     },
315
316     _showEditor: function(forceShowInPanel)
317     {
318         if (this._sourcesView.isShowing())
319             return;
320
321         if (this._shouldShowEditorInDrawer() && !forceShowInPanel)
322             this._drawerEditor()._show();
323         else
324             WebInspector.inspectorView.showPanel("sources");
325     },
326
327     /**
328      * @param {!WebInspector.UILocation} uiLocation
329      * @param {boolean=} forceShowInPanel
330      */
331     showUILocation: function(uiLocation, forceShowInPanel)
332     {
333         this.showUISourceCode(uiLocation.uiSourceCode, uiLocation.lineNumber, uiLocation.columnNumber, forceShowInPanel);
334     },
335
336     /**
337      * @return {boolean}
338      */
339     _shouldShowEditorInDrawer: function()
340     {
341         return WebInspector.experimentsSettings.showEditorInDrawer.isEnabled() && WebInspector.settings.showEditorInDrawer.get() && WebInspector.inspectorView.isDrawerEditorShown();
342     },
343
344     /**
345      * @param {!WebInspector.UISourceCode} uiSourceCode
346      */
347     _revealInNavigator: function(uiSourceCode)
348     {
349         this._navigator.revealUISourceCode(uiSourceCode);
350     },
351
352     _executionLineChanged: function(uiLocation)
353     {
354         this._sourcesView.clearCurrentExecutionLine();
355         this._sourcesView.setExecutionLine(uiLocation);
356         if (this._skipExecutionLineRevealing)
357             return;
358         this._skipExecutionLineRevealing = true;
359         this._sourcesView.showSourceLocation(uiLocation.uiSourceCode, uiLocation.lineNumber, 0, undefined, true);
360     },
361
362     _callFrameSelected: function(event)
363     {
364         var callFrame = event.data;
365
366         if (!callFrame)
367             return;
368
369         this.sidebarPanes.scopechain.update(callFrame);
370         this.sidebarPanes.watchExpressions.refreshExpressions();
371         this.sidebarPanes.callstack.setSelectedCallFrame(callFrame);
372         callFrame.createLiveLocation(this._executionLineChanged.bind(this));
373     },
374
375     /**
376      * @param {!WebInspector.Event} event
377      */
378     _sourceSelected: function(event)
379     {
380         var uiSourceCode = /** @type {!WebInspector.UISourceCode} */ (event.data.uiSourceCode);
381         this._sourcesView.showSourceLocation(uiSourceCode, undefined, undefined, !event.data.focusSource)
382     },
383
384     /**
385      * @param {!WebInspector.Event} event
386      */
387     _sourceRenamed: function(event)
388     {
389         var uiSourceCode = /** @type {!WebInspector.UISourceCode} */ (event.data);
390         this._sourcesView.sourceRenamed(uiSourceCode);
391     },
392
393     _pauseOnExceptionEnabledChanged: function()
394     {
395         var enabled = WebInspector.settings.pauseOnExceptionEnabled.get();
396         this._pauseOnExceptionButton.toggled = enabled;
397         this._pauseOnExceptionButton.title = WebInspector.UIString(enabled ? "Don't pause on exceptions." : "Pause on exceptions.");
398         this._debugToolbarDrawer.classList.toggle("expanded", enabled);
399     },
400
401     _updateDebuggerButtons: function()
402     {
403         if (this._paused) {
404             this._updateButtonTitle(this._pauseButton, WebInspector.UIString("Resume script execution (%s)."))
405             this._pauseButton.state = true;
406             this._pauseButton.setLongClickOptionsEnabled((function() { return [ this._longResumeButton ] }).bind(this));
407
408             this._pauseButton.setEnabled(true);
409             this._stepOverButton.setEnabled(true);
410             this._stepIntoButton.setEnabled(true);
411             this._stepOutButton.setEnabled(true);
412         } else {
413             this._updateButtonTitle(this._pauseButton, WebInspector.UIString("Pause script execution (%s)."))
414             this._pauseButton.state = false;
415             this._pauseButton.setLongClickOptionsEnabled(null);
416
417             this._pauseButton.setEnabled(!this._waitingToPause);
418             this._stepOverButton.setEnabled(false);
419             this._stepIntoButton.setEnabled(false);
420             this._stepOutButton.setEnabled(false);
421         }
422     },
423
424     _clearInterface: function()
425     {
426         this.sidebarPanes.callstack.update(null, null);
427         this.sidebarPanes.scopechain.update(null);
428         this.sidebarPanes.jsBreakpoints.clearBreakpointHighlight();
429         WebInspector.domBreakpointsSidebarPane.clearBreakpointHighlight();
430         this.sidebarPanes.eventListenerBreakpoints.clearBreakpointHighlight();
431         this.sidebarPanes.xhrBreakpoints.clearBreakpointHighlight();
432
433         this._sourcesView.clearCurrentExecutionLine();
434         this._updateDebuggerButtons();
435     },
436
437     _togglePauseOnExceptions: function()
438     {
439         WebInspector.settings.pauseOnExceptionEnabled.set(!this._pauseOnExceptionButton.toggled);
440     },
441
442     /**
443      * @return {boolean}
444      */
445     _runSnippet: function()
446     {
447         var uiSourceCode = this._sourcesView.currentUISourceCode();
448         if (uiSourceCode.project().type() !== WebInspector.projectTypes.Snippets)
449             return false;
450         WebInspector.scriptSnippetModel.evaluateScriptSnippet(uiSourceCode);
451         return true;
452     },
453
454     /**
455      * @param {!WebInspector.Event} event
456      */
457     _editorSelected: function(event)
458     {
459         var uiSourceCode = /** @type {!WebInspector.UISourceCode} */ (event.data);
460         this._editorChanged(uiSourceCode);
461    },
462
463     /**
464      * @param {!WebInspector.Event} event
465      */
466     _editorClosed: function(event)
467     {
468         var wasSelected = /** @type {boolean} */ (event.data.wasSelected);
469         if (wasSelected)
470             this._editorChanged(null);
471     },
472
473     /**
474      * @param {?WebInspector.UISourceCode} uiSourceCode
475      */
476     _editorChanged: function(uiSourceCode)
477     {
478         var isSnippet = uiSourceCode && uiSourceCode.project().type() === WebInspector.projectTypes.Snippets;
479         this._runSnippetButton.element.classList.toggle("hidden", !isSnippet);
480     },
481
482     /**
483      * @return {boolean}
484      */
485     _togglePause: function()
486     {
487         if (this._paused) {
488             delete this._skipExecutionLineRevealing;
489             this._paused = false;
490             this._waitingToPause = false;
491             WebInspector.debuggerModel.resume();
492         } else {
493             this._waitingToPause = true;
494             // Make sure pauses didn't stick skipped.
495             WebInspector.debuggerModel.skipAllPauses(false);
496             DebuggerAgent.pause();
497         }
498
499         this._clearInterface();
500         return true;
501     },
502
503     /**
504      * @return {boolean}
505      */
506     _longResume: function()
507     {
508         if (!this._paused)
509             return true;
510
511         this._paused = false;
512         this._waitingToPause = false;
513         WebInspector.debuggerModel.skipAllPausesUntilReloadOrTimeout(500);
514         WebInspector.debuggerModel.resume();
515
516         this._clearInterface();
517         return true;
518     },
519
520     /**
521      * @return {boolean}
522      */
523     _stepOverClicked: function()
524     {
525         if (!this._paused)
526             return true;
527
528         delete this._skipExecutionLineRevealing;
529         this._paused = false;
530
531         this._clearInterface();
532
533         WebInspector.debuggerModel.stepOver();
534         return true;
535     },
536
537     /**
538      * @return {boolean}
539      */
540     _stepIntoClicked: function()
541     {
542         if (!this._paused)
543             return true;
544
545         delete this._skipExecutionLineRevealing;
546         this._paused = false;
547
548         this._clearInterface();
549
550         WebInspector.debuggerModel.stepInto();
551         return true;
552     },
553
554     /**
555      * @return {boolean}
556      */
557     _stepOutClicked: function()
558     {
559         if (!this._paused)
560             return true;
561
562         delete this._skipExecutionLineRevealing;
563         this._paused = false;
564
565         this._clearInterface();
566
567         WebInspector.debuggerModel.stepOut();
568         return true;
569     },
570
571     /**
572      * @param {!WebInspector.Event} event
573      */
574     _callFrameSelectedInSidebar: function(event)
575     {
576         var callFrame = /** @type {!WebInspector.DebuggerModel.CallFrame} */ (event.data);
577         delete this._skipExecutionLineRevealing;
578         WebInspector.debuggerModel.setSelectedCallFrame(callFrame);
579     },
580
581     _callFrameRestartedInSidebar: function()
582     {
583         delete this._skipExecutionLineRevealing;
584     },
585
586     continueToLocation: function(rawLocation)
587     {
588         if (!this._paused)
589             return;
590
591         delete this._skipExecutionLineRevealing;
592         this._paused = false;
593         this._clearInterface();
594         WebInspector.debuggerModel.continueToLocation(rawLocation);
595     },
596
597     _toggleBreakpointsClicked: function(event)
598     {
599         WebInspector.debuggerModel.setBreakpointsActive(!WebInspector.debuggerModel.breakpointsActive());
600     },
601
602     _breakpointsActiveStateChanged: function(event)
603     {
604         var active = event.data;
605         this._toggleBreakpointsButton.toggled = !active;
606         this.sidebarPanes.jsBreakpoints.listElement.classList.toggle("breakpoints-list-deactivated", !active);
607         this._sourcesView.toggleBreakpointsActiveState(active);
608         if (active)
609             this._toggleBreakpointsButton.title = WebInspector.UIString("Deactivate breakpoints.");
610         else
611             this._toggleBreakpointsButton.title = WebInspector.UIString("Activate breakpoints.");
612     },
613
614     _createDebugToolbar: function()
615     {
616         var debugToolbar = document.createElement("div");
617         debugToolbar.className = "scripts-debug-toolbar";
618
619         var title, handler;
620         var platformSpecificModifier = WebInspector.KeyboardShortcut.Modifiers.CtrlOrMeta;
621
622         // Run snippet.
623         title = WebInspector.UIString("Run snippet (%s).");
624         handler = this._runSnippet.bind(this);
625         this._runSnippetButton = this._createButtonAndRegisterShortcuts("scripts-run-snippet", title, handler, WebInspector.ShortcutsScreen.SourcesPanelShortcuts.RunSnippet);
626         debugToolbar.appendChild(this._runSnippetButton.element);
627         this._runSnippetButton.element.classList.add("hidden");
628
629         // Continue.
630         handler = this._togglePause.bind(this);
631         this._pauseButton = this._createButtonAndRegisterShortcuts("scripts-pause", "", handler, WebInspector.ShortcutsScreen.SourcesPanelShortcuts.PauseContinue);
632         debugToolbar.appendChild(this._pauseButton.element);
633
634         // Long resume.
635         title = WebInspector.UIString("Resume with all pauses blocked for 500 ms");
636         this._longResumeButton = new WebInspector.StatusBarButton(title, "scripts-long-resume");
637         this._longResumeButton.addEventListener("click", this._longResume.bind(this), this);
638
639         // Step over.
640         title = WebInspector.UIString("Step over next function call (%s).");
641         handler = this._stepOverClicked.bind(this);
642         this._stepOverButton = this._createButtonAndRegisterShortcuts("scripts-step-over", title, handler, WebInspector.ShortcutsScreen.SourcesPanelShortcuts.StepOver);
643         debugToolbar.appendChild(this._stepOverButton.element);
644
645         // Step into.
646         title = WebInspector.UIString("Step into next function call (%s).");
647         handler = this._stepIntoClicked.bind(this);
648         this._stepIntoButton = this._createButtonAndRegisterShortcuts("scripts-step-into", title, handler, WebInspector.ShortcutsScreen.SourcesPanelShortcuts.StepInto);
649         debugToolbar.appendChild(this._stepIntoButton.element);
650
651         // Step out.
652         title = WebInspector.UIString("Step out of current function (%s).");
653         handler = this._stepOutClicked.bind(this);
654         this._stepOutButton = this._createButtonAndRegisterShortcuts("scripts-step-out", title, handler, WebInspector.ShortcutsScreen.SourcesPanelShortcuts.StepOut);
655         debugToolbar.appendChild(this._stepOutButton.element);
656
657         // Toggle Breakpoints
658         this._toggleBreakpointsButton = new WebInspector.StatusBarButton(WebInspector.UIString("Deactivate breakpoints."), "scripts-toggle-breakpoints");
659         this._toggleBreakpointsButton.toggled = false;
660         this._toggleBreakpointsButton.addEventListener("click", this._toggleBreakpointsClicked, this);
661         debugToolbar.appendChild(this._toggleBreakpointsButton.element);
662
663         // Pause on Exception
664         this._pauseOnExceptionButton = new WebInspector.StatusBarButton("", "scripts-pause-on-exceptions-status-bar-item");
665         this._pauseOnExceptionButton.addEventListener("click", this._togglePauseOnExceptions, this);
666         debugToolbar.appendChild(this._pauseOnExceptionButton.element);
667
668         return debugToolbar;
669     },
670
671     _createDebugToolbarDrawer: function()
672     {
673         var debugToolbarDrawer = document.createElement("div");
674         debugToolbarDrawer.className = "scripts-debug-toolbar-drawer";
675
676         var label = WebInspector.UIString("Pause On Caught Exceptions");
677         var setting = WebInspector.settings.pauseOnCaughtException;
678         debugToolbarDrawer.appendChild(WebInspector.SettingsUI.createSettingCheckbox(label, setting, true));
679
680         return debugToolbarDrawer;
681     },
682
683     /**
684      * @param {!WebInspector.StatusBarButton} button
685      * @param {string} buttonTitle
686      */
687     _updateButtonTitle: function(button, buttonTitle)
688     {
689         var hasShortcuts = button.shortcuts && button.shortcuts.length;
690         if (hasShortcuts)
691             button.title = String.vsprintf(buttonTitle, [button.shortcuts[0].name]);
692         else
693             button.title = buttonTitle;
694     },
695
696     /**
697      * @param {string} buttonId
698      * @param {string} buttonTitle
699      * @param {function(?Event=):boolean} handler
700      * @param {!Array.<!WebInspector.KeyboardShortcut.Descriptor>} shortcuts
701      * @return {!WebInspector.StatusBarButton}
702      */
703     _createButtonAndRegisterShortcuts: function(buttonId, buttonTitle, handler, shortcuts)
704     {
705         var button = new WebInspector.StatusBarButton(buttonTitle, buttonId);
706         button.element.addEventListener("click", handler, false);
707         button.shortcuts = shortcuts;
708         this._updateButtonTitle(button, buttonTitle);
709         this.registerShortcuts(shortcuts, handler);
710         return button;
711     },
712
713     addToWatch: function(expression)
714     {
715         this.sidebarPanes.watchExpressions.addExpression(expression);
716     },
717
718     _installDebuggerSidebarController: function()
719     {
720         this._toggleNavigatorSidebarButton = this.editorView.createShowHideSidebarButton("navigator", "scripts-navigator-show-hide-button");
721         this.editorView.mainElement().appendChild(this._toggleNavigatorSidebarButton.element);
722
723         this._toggleDebuggerSidebarButton = this._splitView.createShowHideSidebarButton("debugger", "scripts-debugger-show-hide-button");
724
725         this._splitView.mainElement().appendChild(this._toggleDebuggerSidebarButton.element);
726         this._splitView.mainElement().appendChild(this._debugSidebarResizeWidgetElement);
727     },
728
729     _updateDebugSidebarResizeWidget: function()
730     {
731         this._debugSidebarResizeWidgetElement.classList.toggle("hidden", this._splitView.showMode() !== WebInspector.SplitView.ShowMode.Both);
732     },
733
734     /**
735      * @param {!WebInspector.UISourceCode} uiSourceCode
736      */
737     _showLocalHistory: function(uiSourceCode)
738     {
739         WebInspector.RevisionHistoryView.showHistory(uiSourceCode);
740     },
741
742     /**
743      * @param {!WebInspector.ContextMenu} contextMenu
744      * @param {!Object} target
745      */
746     appendApplicableItems: function(event, contextMenu, target)
747     {
748         this._appendUISourceCodeItems(event, contextMenu, target);
749         this._appendRemoteObjectItems(contextMenu, target);
750     },
751
752     _suggestReload: function()
753     {
754         if (window.confirm(WebInspector.UIString("It is recommended to restart inspector after making these changes. Would you like to restart it?")))
755             WebInspector.reload();
756     },
757
758     /**
759      * @param {!WebInspector.UISourceCode} uiSourceCode
760      */
761     _mapFileSystemToNetwork: function(uiSourceCode)
762     {
763         WebInspector.SelectUISourceCodeForProjectTypeDialog.show(uiSourceCode.name(), WebInspector.projectTypes.Network, mapFileSystemToNetwork.bind(this), this.editorView.mainElement())
764
765         /**
766          * @param {!WebInspector.UISourceCode} networkUISourceCode
767          * @this {WebInspector.SourcesPanel}
768          */
769         function mapFileSystemToNetwork(networkUISourceCode)
770         {
771             this._workspace.addMapping(networkUISourceCode, uiSourceCode, WebInspector.fileSystemWorkspaceProvider);
772             this._suggestReload();
773         }
774     },
775
776     /**
777      * @param {!WebInspector.UISourceCode} uiSourceCode
778      */
779     _removeNetworkMapping: function(uiSourceCode)
780     {
781         if (confirm(WebInspector.UIString("Are you sure you want to remove network mapping?"))) {
782             this._workspace.removeMapping(uiSourceCode);
783             this._suggestReload();
784         }
785     },
786
787     /**
788      * @param {!WebInspector.UISourceCode} networkUISourceCode
789      */
790     _mapNetworkToFileSystem: function(networkUISourceCode)
791     {
792         WebInspector.SelectUISourceCodeForProjectTypeDialog.show(networkUISourceCode.name(), WebInspector.projectTypes.FileSystem, mapNetworkToFileSystem.bind(this), this.editorView.mainElement())
793
794         /**
795          * @param {!WebInspector.UISourceCode} uiSourceCode
796          * @this {WebInspector.SourcesPanel}
797          */
798         function mapNetworkToFileSystem(uiSourceCode)
799         {
800             this._workspace.addMapping(networkUISourceCode, uiSourceCode, WebInspector.fileSystemWorkspaceProvider);
801         }
802     },
803
804     /**
805      * @param {!WebInspector.ContextMenu} contextMenu
806      * @param {!WebInspector.UISourceCode} uiSourceCode
807      */
808     _appendUISourceCodeMappingItems: function(contextMenu, uiSourceCode)
809     {
810         if (uiSourceCode.project().type() === WebInspector.projectTypes.FileSystem) {
811             var hasMappings = !!uiSourceCode.url;
812             if (!hasMappings)
813                 contextMenu.appendItem(WebInspector.UIString(WebInspector.useLowerCaseMenuTitles() ? "Map to network resource\u2026" : "Map to Network Resource\u2026"), this._mapFileSystemToNetwork.bind(this, uiSourceCode));
814             else
815                 contextMenu.appendItem(WebInspector.UIString(WebInspector.useLowerCaseMenuTitles() ? "Remove network mapping" : "Remove Network Mapping"), this._removeNetworkMapping.bind(this, uiSourceCode));
816         }
817
818         /**
819          * @param {!WebInspector.Project} project
820          */
821         function filterProject(project)
822         {
823             return project.type() === WebInspector.projectTypes.FileSystem;
824         }
825
826         if (uiSourceCode.project().type() === WebInspector.projectTypes.Network) {
827             if (!this._workspace.projects().filter(filterProject).length)
828                 return;
829             if (this._workspace.uiSourceCodeForURL(uiSourceCode.url) === uiSourceCode)
830                 contextMenu.appendItem(WebInspector.UIString(WebInspector.useLowerCaseMenuTitles() ? "Map to file system resource\u2026" : "Map to File System Resource\u2026"), this._mapNetworkToFileSystem.bind(this, uiSourceCode));
831         }
832     },
833
834     /**
835      * @param {!Event} event
836      * @param {!WebInspector.ContextMenu} contextMenu
837      * @param {!Object} target
838      */
839     _appendUISourceCodeItems: function(event, contextMenu, target)
840     {
841         if (!(target instanceof WebInspector.UISourceCode))
842             return;
843
844         var uiSourceCode = /** @type {!WebInspector.UISourceCode} */ (target);
845         contextMenu.appendItem(WebInspector.UIString(WebInspector.useLowerCaseMenuTitles() ? "Local modifications\u2026" : "Local Modifications\u2026"), this._showLocalHistory.bind(this, uiSourceCode));
846         this._appendUISourceCodeMappingItems(contextMenu, uiSourceCode);
847
848         if (!event.target.isSelfOrDescendant(this.editorView.sidebarElement())) {
849             contextMenu.appendSeparator();
850             contextMenu.appendItem(WebInspector.UIString(WebInspector.useLowerCaseMenuTitles() ? "Reveal in navigator" : "Reveal in Navigator"), this._handleContextMenuReveal.bind(this, uiSourceCode));
851         }
852     },
853
854     /**
855      * @param {!WebInspector.UISourceCode} uiSourceCode
856      */
857     _handleContextMenuReveal: function(uiSourceCode)
858     {
859         this.editorView.showBoth();
860         this._revealInNavigator(uiSourceCode);
861     },
862
863     /**
864      * @param {!WebInspector.ContextMenu} contextMenu
865      * @param {!Object} target
866      */
867     _appendRemoteObjectItems: function(contextMenu, target)
868     {
869         if (!(target instanceof WebInspector.RemoteObject))
870             return;
871         var remoteObject = /** @type {!WebInspector.RemoteObject} */ (target);
872         contextMenu.appendItem(WebInspector.UIString(WebInspector.useLowerCaseMenuTitles() ? "Store as global variable" : "Store as Global Variable"), this._saveToTempVariable.bind(this, remoteObject));
873         if (remoteObject.type === "function")
874             contextMenu.appendItem(WebInspector.UIString(WebInspector.useLowerCaseMenuTitles() ? "Show function definition" : "Show Function Definition"), this._showFunctionDefinition.bind(this, remoteObject));
875     },
876
877     /**
878      * @param {!WebInspector.RemoteObject} remoteObject
879      */
880     _saveToTempVariable: function(remoteObject)
881     {
882         WebInspector.runtimeModel.evaluate("window", "", false, true, false, false, didGetGlobalObject);
883
884         /**
885          * @param {?WebInspector.RemoteObject} global
886          * @param {boolean=} wasThrown
887          */
888         function didGetGlobalObject(global, wasThrown)
889         {
890             /**
891              * @suppressReceiverCheck
892              * @this {Window}
893              */
894             function remoteFunction(value)
895             {
896                 var prefix = "temp";
897                 var index = 1;
898                 while ((prefix + index) in this)
899                     ++index;
900                 var name = prefix + index;
901                 this[name] = value;
902                 return name;
903             }
904
905             if (wasThrown || !global)
906                 failedToSave(global);
907             else
908                 global.callFunction(remoteFunction, [WebInspector.RemoteObject.toCallArgument(remoteObject)], didSave.bind(null, global));
909         }
910
911         /**
912          * @param {!WebInspector.RemoteObject} global
913          * @param {?WebInspector.RemoteObject} result
914          * @param {boolean=} wasThrown
915          */
916         function didSave(global, result, wasThrown)
917         {
918             global.release();
919             if (wasThrown || !result || result.type !== "string")
920                 failedToSave(result);
921             else
922                 WebInspector.console.evaluate(result.value);
923         }
924
925         /**
926          * @param {?WebInspector.RemoteObject} result
927          */
928         function failedToSave(result)
929         {
930             var message = WebInspector.UIString("Failed to save to temp variable.");
931             if (result) {
932                 message += " " + result.description;
933                 result.release();
934             }
935             WebInspector.console.showErrorMessage(message)
936         }
937     },
938
939     /**
940      * @param {!WebInspector.RemoteObject} remoteObject
941      */
942     _showFunctionDefinition: function(remoteObject)
943     {
944         /**
945          * @param {?Protocol.Error} error
946          * @param {!DebuggerAgent.FunctionDetails} response
947          * @this {WebInspector.SourcesPanel}
948          */
949         function didGetFunctionDetails(error, response)
950         {
951             if (error) {
952                 console.error(error);
953                 return;
954             }
955
956             var uiLocation = WebInspector.debuggerModel.rawLocationToUILocation(response.location);
957             if (!uiLocation)
958                 return;
959
960             this.showUILocation(uiLocation, true);
961         }
962         DebuggerAgent.getFunctionDetails(remoteObject.objectId, didGetFunctionDetails.bind(this));
963     },
964
965     showGoToSourceDialog: function()
966     {
967         this._sourcesView.showOpenResourceDialog();
968     },
969
970     _dockSideChanged: function()
971     {
972         var vertically = WebInspector.dockController.isVertical() && WebInspector.settings.splitVerticallyWhenDockedToRight.get();
973         this._splitVertically(vertically);
974     },
975
976     /**
977      * @param {boolean} vertically
978      */
979     _splitVertically: function(vertically)
980     {
981         if (this.sidebarPaneView && vertically === !this._splitView.isVertical())
982             return;
983
984         if (this.sidebarPaneView)
985             this.sidebarPaneView.detach();
986
987         this._splitView.setVertical(!vertically);
988
989         if (!vertically)
990             this._splitView.uninstallResizer(this._sourcesView.statusBarContainerElement());
991         else
992             this._splitView.installResizer(this._sourcesView.statusBarContainerElement());
993
994         // Create vertical box with stack.
995         var vbox = new WebInspector.VBox();
996         vbox.element.appendChild(this._debugToolbarDrawer);
997         vbox.element.appendChild(this.debugToolbar);
998         vbox.element.appendChild(this.threadsToolbar.element);
999         vbox.setMinimumSize(WebInspector.SourcesPanel.minToolbarWidth, 25);
1000         var sidebarPaneStack = new WebInspector.SidebarPaneStack();
1001         sidebarPaneStack.element.classList.add("flex-auto");
1002         sidebarPaneStack.show(vbox.element);
1003
1004         if (!vertically) {
1005             // Populate the only stack.
1006             for (var pane in this.sidebarPanes)
1007                 sidebarPaneStack.addPane(this.sidebarPanes[pane]);
1008             this._extensionSidebarPanesContainer = sidebarPaneStack;
1009
1010             this.sidebarPaneView = vbox;
1011         } else {
1012             var splitView = new WebInspector.SplitView(true, true, "sourcesPanelDebuggerSidebarSplitViewState", 0.5);
1013             vbox.show(splitView.mainElement());
1014
1015             // Populate the left stack.
1016             sidebarPaneStack.addPane(this.sidebarPanes.callstack);
1017             sidebarPaneStack.addPane(this.sidebarPanes.jsBreakpoints);
1018             sidebarPaneStack.addPane(this.sidebarPanes.domBreakpoints);
1019             sidebarPaneStack.addPane(this.sidebarPanes.xhrBreakpoints);
1020             sidebarPaneStack.addPane(this.sidebarPanes.eventListenerBreakpoints);
1021             if (this.sidebarPanes.workerList)
1022                 sidebarPaneStack.addPane(this.sidebarPanes.workerList);
1023
1024             var tabbedPane = new WebInspector.SidebarTabbedPane();
1025             tabbedPane.show(splitView.sidebarElement());
1026             tabbedPane.addPane(this.sidebarPanes.scopechain);
1027             tabbedPane.addPane(this.sidebarPanes.watchExpressions);
1028             this._extensionSidebarPanesContainer = tabbedPane;
1029
1030             this.sidebarPaneView = splitView;
1031         }
1032         for (var i = 0; i < this._extensionSidebarPanes.length; ++i)
1033             this._extensionSidebarPanesContainer.addPane(this._extensionSidebarPanes[i]);
1034
1035         this.sidebarPaneView.show(this._splitView.sidebarElement());
1036
1037         this.sidebarPanes.scopechain.expand();
1038         this.sidebarPanes.jsBreakpoints.expand();
1039         this.sidebarPanes.callstack.expand();
1040
1041         if (WebInspector.settings.watchExpressions.get().length > 0)
1042             this.sidebarPanes.watchExpressions.expand();
1043     },
1044
1045     /**
1046      * @param {string} id
1047      * @param {!WebInspector.SidebarPane} pane
1048      */
1049     addExtensionSidebarPane: function(id, pane)
1050     {
1051         this._extensionSidebarPanes.push(pane);
1052         this._extensionSidebarPanesContainer.addPane(pane);
1053         this.setHideOnDetach();
1054     },
1055
1056     /**
1057      * @return {!WebInspector.SourcesView}
1058      */
1059     sourcesView: function()
1060     {
1061         return this._sourcesView;
1062     },
1063
1064     __proto__: WebInspector.Panel.prototype
1065 }
1066
1067 /**
1068  * @constructor
1069  * @param {!Element} element
1070  */
1071 WebInspector.UpgradeFileSystemDropTarget = function(element)
1072 {
1073     element.addEventListener("dragenter", this._onDragEnter.bind(this), true);
1074     element.addEventListener("dragover", this._onDragOver.bind(this), true);
1075     this._element = element;
1076 }
1077
1078 WebInspector.UpgradeFileSystemDropTarget.dragAndDropFilesType = "Files";
1079
1080 WebInspector.UpgradeFileSystemDropTarget.prototype = {
1081     _onDragEnter: function (event)
1082     {
1083         if (event.dataTransfer.types.indexOf(WebInspector.UpgradeFileSystemDropTarget.dragAndDropFilesType) === -1)
1084             return;
1085         event.consume(true);
1086     },
1087
1088     _onDragOver: function (event)
1089     {
1090         if (event.dataTransfer.types.indexOf(WebInspector.UpgradeFileSystemDropTarget.dragAndDropFilesType) === -1)
1091             return;
1092         event.dataTransfer.dropEffect = "copy";
1093         event.consume(true);
1094         if (this._dragMaskElement)
1095             return;
1096         this._dragMaskElement = this._element.createChild("div", "fill drag-mask");
1097         this._dragMaskElement.createChild("div", "fill drag-mask-inner").textContent = WebInspector.UIString("Drop workspace folder here");
1098         this._dragMaskElement.addEventListener("drop", this._onDrop.bind(this), true);
1099         this._dragMaskElement.addEventListener("dragleave", this._onDragLeave.bind(this), true);
1100     },
1101
1102     _onDrop: function (event)
1103     {
1104         event.consume(true);
1105         this._removeMask();
1106         var items = /** @type {!Array.<!DataTransferItem>} */ (event.dataTransfer.items);
1107         if (!items.length)
1108             return;
1109         var entry = items[0].webkitGetAsEntry();
1110         if (!entry.isDirectory)
1111             return;
1112         InspectorFrontendHost.upgradeDraggedFileSystemPermissions(entry.filesystem);
1113     },
1114
1115     _onDragLeave: function (event)
1116     {
1117         event.consume(true);
1118         this._removeMask();
1119     },
1120
1121     _removeMask: function ()
1122     {
1123         this._dragMaskElement.remove();
1124         delete this._dragMaskElement;
1125     }
1126 }
1127
1128 /**
1129  * @constructor
1130  * @implements {WebInspector.DrawerEditor}
1131  */
1132 WebInspector.SourcesPanel.DrawerEditor = function()
1133 {
1134     this._panel = WebInspector.inspectorView.panel("sources");
1135 }
1136
1137 WebInspector.SourcesPanel.DrawerEditor.prototype = {
1138     /**
1139      * @return {!WebInspector.View}
1140      */
1141     view: function()
1142     {
1143         return this._panel._drawerEditorView;
1144     },
1145
1146     installedIntoDrawer: function()
1147     {
1148         if (this._panel.isShowing())
1149             this._panelWasShown();
1150         else
1151             this._panelWillHide();
1152     },
1153
1154     _panelWasShown: function()
1155     {
1156         WebInspector.inspectorView.setDrawerEditorAvailable(false);
1157         WebInspector.inspectorView.hideDrawerEditor();
1158     },
1159
1160     _panelWillHide: function()
1161     {
1162         WebInspector.inspectorView.setDrawerEditorAvailable(true);
1163         if (WebInspector.inspectorView.isDrawerEditorShown())
1164             WebInspector.inspectorView.showDrawerEditor();
1165     },
1166
1167     _show: function()
1168     {
1169         WebInspector.inspectorView.showDrawerEditor();
1170     },
1171 }
1172
1173 /**
1174  * @constructor
1175  * @extends {WebInspector.VBox}
1176  */
1177 WebInspector.SourcesPanel.DrawerEditorView = function()
1178 {
1179     WebInspector.VBox.call(this);
1180     this.element.id = "drawer-editor-view";
1181 }
1182
1183 WebInspector.SourcesPanel.DrawerEditorView.prototype = {
1184     __proto__: WebInspector.VBox.prototype
1185 }
1186
1187
1188 /**
1189  * @constructor
1190  * @implements {WebInspector.ContextMenu.Provider}
1191  */
1192 WebInspector.SourcesPanel.ContextMenuProvider = function()
1193 {
1194 }
1195
1196 WebInspector.SourcesPanel.ContextMenuProvider.prototype = {
1197     /**
1198      * @param {!WebInspector.ContextMenu} contextMenu
1199      * @param {!Object} target
1200      */
1201     appendApplicableItems: function(event, contextMenu, target)
1202     {
1203         WebInspector.inspectorView.panel("sources").appendApplicableItems(event, contextMenu, target);
1204     }
1205 }
1206
1207 /**
1208  * @constructor
1209  * @implements {WebInspector.Revealer}
1210  */
1211 WebInspector.SourcesPanel.UILocationRevealer = function()
1212 {
1213 }
1214
1215 WebInspector.SourcesPanel.UILocationRevealer.prototype = {
1216     /**
1217      * @param {!Object} uiLocation
1218      */
1219     reveal: function(uiLocation)
1220     {
1221         if (uiLocation instanceof WebInspector.UILocation)
1222             /** @type {!WebInspector.SourcesPanel} */ (WebInspector.inspectorView.panel("sources")).showUILocation(uiLocation);
1223     }
1224 }
1225
1226 /**
1227  * @constructor
1228  * @implements {WebInspector.ActionDelegate}
1229  */
1230 WebInspector.SourcesPanel.ShowGoToSourceDialogActionDelegate = function() {}
1231
1232 WebInspector.SourcesPanel.ShowGoToSourceDialogActionDelegate.prototype = {
1233     /**
1234      * @return {boolean}
1235      */
1236     handleAction: function()
1237     {
1238         /** @type {!WebInspector.SourcesPanel} */ (WebInspector.inspectorView.showPanel("sources")).showGoToSourceDialog();
1239         return true;
1240     }
1241 }