Web Inspector: Add toggle breakpoint shortcut.
authorvsevik@chromium.org <vsevik@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 29 Jun 2012 09:12:12 +0000 (09:12 +0000)
committervsevik@chromium.org <vsevik@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 29 Jun 2012 09:12:12 +0000 (09:12 +0000)
https://bugs.webkit.org/show_bug.cgi?id=90188

Reviewed by Yury Semikhatsky.

* inspector/front-end/JavaScriptSourceFrame.js:
(WebInspector.JavaScriptSourceFrame.prototype._onMouseDown):
(WebInspector.JavaScriptSourceFrame.prototype._toggleBreakpoint):
(WebInspector.JavaScriptSourceFrame.prototype.toggleBreakpointOnCurrentLine):
* inspector/front-end/ScriptsPanel.js:
(WebInspector.ScriptsPanel.prototype._toggleBreakpoint):
(WebInspector.ScriptsPanel.prototype._showOutlineDialog):
* inspector/front-end/TextViewer.js:
(WebInspector.TextViewer.prototype.selection):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@121535 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/inspector/front-end/JavaScriptSourceFrame.js
Source/WebCore/inspector/front-end/ScriptsPanel.js
Source/WebCore/inspector/front-end/TextViewer.js

index 538ebb1..8ed75cc 100644 (file)
@@ -1,5 +1,22 @@
 2012-06-28  Vsevolod Vlasov  <vsevik@chromium.org>
 
+        Web Inspector: Add toggle breakpoint shortcut.
+        https://bugs.webkit.org/show_bug.cgi?id=90188
+
+        Reviewed by Yury Semikhatsky.
+
+        * inspector/front-end/JavaScriptSourceFrame.js:
+        (WebInspector.JavaScriptSourceFrame.prototype._onMouseDown):
+        (WebInspector.JavaScriptSourceFrame.prototype._toggleBreakpoint):
+        (WebInspector.JavaScriptSourceFrame.prototype.toggleBreakpointOnCurrentLine):
+        * inspector/front-end/ScriptsPanel.js:
+        (WebInspector.ScriptsPanel.prototype._toggleBreakpoint):
+        (WebInspector.ScriptsPanel.prototype._showOutlineDialog):
+        * inspector/front-end/TextViewer.js:
+        (WebInspector.TextViewer.prototype.selection):
+
+2012-06-28  Vsevolod Vlasov  <vsevik@chromium.org>
+
         Web Inspector: Cursor should follow execution line when debugging.
         https://bugs.webkit.org/show_bug.cgi?id=90184
 
index b8ec356..48c4b95 100644 (file)
@@ -359,14 +359,7 @@ WebInspector.JavaScriptSourceFrame.prototype = {
             return;
         var lineNumber = target.lineNumber;
 
-        var breakpoint = this._breakpointManager.findBreakpoint(this._javaScriptSource, lineNumber);
-        if (breakpoint) {
-            if (event.shiftKey)
-                breakpoint.setEnabled(!breakpoint.enabled());
-            else
-                breakpoint.remove();
-        } else
-            this._setBreakpoint(lineNumber, "", true);
+        this._toggleBreakpoint(lineNumber, event.shiftKey);
         event.preventDefault();
     },
 
@@ -532,6 +525,30 @@ WebInspector.JavaScriptSourceFrame.prototype = {
 
     /**
      * @param {number} lineNumber
+     * @param {boolean} onlyDisable
+     */
+    _toggleBreakpoint: function(lineNumber, onlyDisable)
+    {
+        var breakpoint = this._breakpointManager.findBreakpoint(this._javaScriptSource, lineNumber);
+        if (breakpoint) {
+            if (onlyDisable)
+                breakpoint.setEnabled(!breakpoint.enabled());
+            else
+                breakpoint.remove();
+        } else
+            this._setBreakpoint(lineNumber, "", true);
+    },
+
+    toggleBreakpointOnCurrentLine: function()
+    {
+        var selection = this.textViewer.selection();
+        if (!selection)
+            return;
+        this._toggleBreakpoint(selection.startLine, false);
+    },
+
+    /**
+     * @param {number} lineNumber
      * @param {string} condition
      * @param {boolean} enabled
      */
index 807056d..2869775 100644 (file)
@@ -133,6 +133,10 @@ WebInspector.ScriptsPanel = function(uiSourceCodeProviderForTest)
     helpSection.addKey(outlineShortcut.name, WebInspector.UIString("Go to member"));
     this.registerShortcut(outlineShortcut.key, this._showOutlineDialog.bind(this));
 
+    var createBreakpointShortcut = WebInspector.KeyboardShortcut.makeDescriptor("b", WebInspector.KeyboardShortcut.Modifiers.CtrlOrMeta);
+    helpSection.addKey(createBreakpointShortcut.name, WebInspector.UIString("Toggle breakpoint"));
+    this.registerShortcut(createBreakpointShortcut.key, this._toggleBreakpoint.bind(this));
+
     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.");
     var panelEnablerButton = WebInspector.UIString("Enable Debugging");
@@ -952,16 +956,28 @@ WebInspector.ScriptsPanel.prototype = {
         this.sidebarPanes.watchExpressions.addExpression(expression);
     },
 
+    _toggleBreakpoint: function()
+    {
+        var sourceFrame = this.visibleView;
+        if (!sourceFrame)
+            return;
+
+        if (sourceFrame instanceof WebInspector.JavaScriptSourceFrame) {
+            var javaScriptSourceFrame = /** @type {WebInspector.JavaScriptSourceFrame} */ sourceFrame;
+            javaScriptSourceFrame.toggleBreakpointOnCurrentLine();
+        }            
+    },
+
     _showOutlineDialog: function()
     {
-         var uiSourceCode = this._editorContainer.currentFile();
-         if (!uiSourceCode)
-             return;
+        var uiSourceCode = this._editorContainer.currentFile();
+        if (!uiSourceCode)
+            return;
 
-         if (uiSourceCode instanceof WebInspector.JavaScriptSource)
-             WebInspector.JavaScriptOutlineDialog.show(this.visibleView, uiSourceCode);
-         else if (uiSourceCode instanceof WebInspector.StyleSource)
-             WebInspector.StyleSheetOutlineDialog.show(this.visibleView, /** @type {WebInspector.StyleSource} */ uiSourceCode);
+        if (uiSourceCode instanceof WebInspector.JavaScriptSource)
+            WebInspector.JavaScriptOutlineDialog.show(this.visibleView, uiSourceCode);
+        else if (uiSourceCode instanceof WebInspector.StyleSource)
+            WebInspector.StyleSheetOutlineDialog.show(this.visibleView, /** @type {WebInspector.StyleSource} */ uiSourceCode);
     },
 
     _installDebuggerSidebarController: function()
index 1d5ad75..96fe8ad 100644 (file)
@@ -308,6 +308,14 @@ WebInspector.TextViewer.prototype = {
     },
 
     /**
+     * @return {WebInspector.TextRange}
+     */
+    selection: function(textRange)
+    {
+        return this._mainPanel._getSelection();
+    },
+    
+    /**
      * @param {WebInspector.TextRange} textRange
      */
     setSelection: function(textRange)