diff options
Diffstat (limited to 'WebCore/inspector/front-end/ScriptsPanel.js')
-rw-r--r-- | WebCore/inspector/front-end/ScriptsPanel.js | 108 |
1 files changed, 89 insertions, 19 deletions
diff --git a/WebCore/inspector/front-end/ScriptsPanel.js b/WebCore/inspector/front-end/ScriptsPanel.js index 7af9292..0058374 100644 --- a/WebCore/inspector/front-end/ScriptsPanel.js +++ b/WebCore/inspector/front-end/ScriptsPanel.js @@ -56,6 +56,7 @@ WebInspector.ScriptsPanel = function() this.filesSelectElement.className = "status-bar-item"; this.filesSelectElement.id = "scripts-files"; this.filesSelectElement.addEventListener("change", this._changeVisibleFile.bind(this), false); + this.filesSelectElement.handleKeyEvent = this.handleKeyEvent.bind(this); this.topStatusBar.appendChild(this.filesSelectElement); this.functionsSelectElement = document.createElement("select"); @@ -132,13 +133,11 @@ WebInspector.ScriptsPanel = function() for (var pane in this.sidebarPanes) this.sidebarElement.appendChild(this.sidebarPanes[pane].element); - // FIXME: remove the following line of code when the Breakpoints pane has content. - this.sidebarElement.removeChild(this.sidebarPanes.breakpoints.element); - this.sidebarPanes.callstack.expanded = true; this.sidebarPanes.callstack.addEventListener("call frame selected", this._callFrameSelected, this); this.sidebarPanes.scopechain.expanded = true; + this.sidebarPanes.breakpoints.expanded = true; var panelEnablerHeading = WebInspector.UIString("You need to enable debugging before you can use the Scripts panel."); var panelEnablerDisclaimer = WebInspector.UIString("Enabling debugging will make scripts run slower."); @@ -152,17 +151,50 @@ WebInspector.ScriptsPanel = function() this.element.appendChild(this.sidebarElement); this.element.appendChild(this.sidebarResizeElement); - this.enableToggleButton = document.createElement("button"); + this.enableToggleButton = this.createStatusBarButton(); this.enableToggleButton.className = "enable-toggle-status-bar-item status-bar-item"; this.enableToggleButton.addEventListener("click", this._toggleDebugging.bind(this), false); - this.pauseOnExceptionButton = document.createElement("button"); + this.pauseOnExceptionButton = this.createStatusBarButton(); this.pauseOnExceptionButton.id = "scripts-pause-on-exceptions-status-bar-item"; this.pauseOnExceptionButton.className = "status-bar-item"; this.pauseOnExceptionButton.addEventListener("click", this._togglePauseOnExceptions.bind(this), false); this._breakpointsURLMap = {}; + this._shortcuts = {}; + + var isMac = InspectorController.platform().indexOf("mac-") === 0; + var platformSpecificModifier = isMac ? WebInspector.KeyboardShortcut.Modifiers.Meta : WebInspector.KeyboardShortcut.Modifiers.Ctrl; + + // Continue. + var handler = this.pauseButton.click.bind(this.pauseButton); + var shortcut = WebInspector.KeyboardShortcut.makeKey(WebInspector.KeyboardShortcut.KeyCodes.F8); + this._shortcuts[shortcut] = handler; + var shortcut = WebInspector.KeyboardShortcut.makeKey(WebInspector.KeyboardShortcut.KeyCodes.Slash, platformSpecificModifier); + this._shortcuts[shortcut] = handler; + + // Step over. + var handler = this.stepOverButton.click.bind(this.stepOverButton); + var shortcut = WebInspector.KeyboardShortcut.makeKey(WebInspector.KeyboardShortcut.KeyCodes.F10); + this._shortcuts[shortcut] = handler; + var shortcut = WebInspector.KeyboardShortcut.makeKey(WebInspector.KeyboardShortcut.KeyCodes.SingleQuote, platformSpecificModifier); + this._shortcuts[shortcut] = handler; + + // Step into. + var handler = this.stepIntoButton.click.bind(this.stepIntoButton); + var shortcut = WebInspector.KeyboardShortcut.makeKey(WebInspector.KeyboardShortcut.KeyCodes.F11); + this._shortcuts[shortcut] = handler; + var shortcut = WebInspector.KeyboardShortcut.makeKey(WebInspector.KeyboardShortcut.KeyCodes.Semicolon, platformSpecificModifier); + this._shortcuts[shortcut] = handler; + + // Step out. + var handler = this.stepOutButton.click.bind(this.stepOutButton); + var shortcut = WebInspector.KeyboardShortcut.makeKey(WebInspector.KeyboardShortcut.KeyCodes.F11, WebInspector.KeyboardShortcut.Modifiers.Shift); + this._shortcuts[shortcut] = handler; + var shortcut = WebInspector.KeyboardShortcut.makeKey(WebInspector.KeyboardShortcut.KeyCodes.Semicolon, WebInspector.KeyboardShortcut.Modifiers.Shift, platformSpecificModifier); + this._shortcuts[shortcut] = handler; + this.reset(); } @@ -206,7 +238,7 @@ WebInspector.ScriptsPanel.prototype = { view.visible = false; } if (this._attachDebuggerWhenShown) { - InspectorController.enableDebuggerFromFrontend(false); + InspectorController.enableDebugger(false); delete this._attachDebuggerWhenShown; } }, @@ -265,6 +297,11 @@ WebInspector.ScriptsPanel.prototype = { this._addScriptToFilesMenu(script); }, + scriptOrResourceForID: function(id) + { + return this._sourceIDMap[id]; + }, + addBreakpoint: function(breakpoint) { this.sidebarPanes.breakpoints.addBreakpoint(breakpoint); @@ -316,33 +353,53 @@ WebInspector.ScriptsPanel.prototype = { sourceFrame.removeBreakpoint(breakpoint); }, - evaluateInSelectedCallFrame: function(code, updateInterface) + evaluateInSelectedCallFrame: function(code, updateInterface, callback) { var selectedCallFrame = this.sidebarPanes.callstack.selectedCallFrame; if (!this._paused || !selectedCallFrame) return; + if (typeof updateInterface === "undefined") updateInterface = true; - var result = selectedCallFrame.evaluate(code); - if (updateInterface) - this.sidebarPanes.scopechain.update(selectedCallFrame); - return result; + + var self = this; + function updatingCallbackWrapper(result, exception) + { + callback(result, exception); + if (updateInterface) + self.sidebarPanes.scopechain.update(selectedCallFrame); + } + this.doEvalInCallFrame(selectedCallFrame, code, updatingCallbackWrapper); }, - variablesInScopeForSelectedCallFrame: function() + doEvalInCallFrame: function(callFrame, code, callback) { - var selectedCallFrame = this.sidebarPanes.callstack.selectedCallFrame; - if (!this._paused || !selectedCallFrame) - return {}; + var panel = this; + function delayedEvaluation() + { + if (!code) { + // Evaluate into properties in scope of the selected call frame. + callback(panel._variablesInScope(callFrame)); + return; + } + try { + callback(callFrame.evaluate(code)); + } catch (e) { + callback(e, true); + } + } + setTimeout(delayedEvaluation, 0); + }, + _variablesInScope: function(callFrame) + { var result = {}; - var scopeChain = selectedCallFrame.scopeChain; + var scopeChain = callFrame.scopeChain; for (var i = 0; i < scopeChain.length; ++i) { var scopeObject = scopeChain[i]; for (var property in scopeObject) result[property] = true; } - return result; }, @@ -375,7 +432,7 @@ WebInspector.ScriptsPanel.prototype = { attachDebuggerWhenShown: function() { if (this.element.parentElement) { - InspectorController.enableDebuggerFromFrontend(false); + InspectorController.enableDebugger(false); } else { this._attachDebuggerWhenShown = true; } @@ -467,6 +524,19 @@ WebInspector.ScriptsPanel.prototype = { this._showScriptOrResource((view.resource || view.script)); }, + handleKeyEvent: function(event) + { + var shortcut = WebInspector.KeyboardShortcut.makeKeyFromEvent(event); + var handler = this._shortcuts[shortcut]; + if (handler) { + handler(event); + event.preventDefault(); + event.handled = true; + } else { + this.sidebarPanes.callstack.handleKeyEvent(event); + } + }, + scriptViewForScript: function(script) { if (!script) @@ -796,7 +866,7 @@ WebInspector.ScriptsPanel.prototype = { if (InspectorController.debuggerEnabled()) InspectorController.disableDebugger(true); else - InspectorController.enableDebuggerFromFrontend(!!optionalAlways); + InspectorController.enableDebugger(!!optionalAlways); }, _togglePauseOnExceptions: function() |