Title: [121534] trunk/Source/WebCore
Revision
121534
Author
[email protected]
Date
2012-06-29 02:09:02 -0700 (Fri, 29 Jun 2012)

Log Message

Web Inspector: Cursor should follow execution line when debugging.
https://bugs.webkit.org/show_bug.cgi?id=90184

Reviewed by Yury Semikhatsky.

Added TextViewer.setSelection public method to set cursor selection in the editor.
Added TextRange.createFromLocation method to create TextRanges with the same start and end points.
Drive-by: removed unused _setCaretLocation() method in TextViewer.js

* inspector/front-end/_javascript_SourceFrame.js:
(WebInspector._javascript_SourceFrame.prototype.setExecutionLine):
* inspector/front-end/ScriptsPanel.js:
(WebInspector.ScriptsPanel.prototype._revealExecutionLine):
(WebInspector.ScriptsPanel.prototype._editorSelected):
* inspector/front-end/SourceFrame.js:
(WebInspector.SourceFrame.prototype.setSelection):
(WebInspector.SourceFrame.prototype.setContent):
* inspector/front-end/TextEditorModel.js:
(WebInspector.TextRange.createFromLocation):
* inspector/front-end/TextViewer.js:
(WebInspector.TextViewer.prototype.setSelection):
(WebInspector.TextEditorMainPanel.prototype.highlightLine):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (121533 => 121534)


--- trunk/Source/WebCore/ChangeLog	2012-06-29 09:05:58 UTC (rev 121533)
+++ trunk/Source/WebCore/ChangeLog	2012-06-29 09:09:02 UTC (rev 121534)
@@ -1,3 +1,28 @@
+2012-06-28  Vsevolod Vlasov  <[email protected]>
+
+        Web Inspector: Cursor should follow execution line when debugging.
+        https://bugs.webkit.org/show_bug.cgi?id=90184
+
+        Reviewed by Yury Semikhatsky.
+
+        Added TextViewer.setSelection public method to set cursor selection in the editor.
+        Added TextRange.createFromLocation method to create TextRanges with the same start and end points.
+        Drive-by: removed unused _setCaretLocation() method in TextViewer.js
+
+        * inspector/front-end/_javascript_SourceFrame.js:
+        (WebInspector._javascript_SourceFrame.prototype.setExecutionLine):
+        * inspector/front-end/ScriptsPanel.js:
+        (WebInspector.ScriptsPanel.prototype._revealExecutionLine):
+        (WebInspector.ScriptsPanel.prototype._editorSelected):
+        * inspector/front-end/SourceFrame.js:
+        (WebInspector.SourceFrame.prototype.setSelection):
+        (WebInspector.SourceFrame.prototype.setContent):
+        * inspector/front-end/TextEditorModel.js:
+        (WebInspector.TextRange.createFromLocation):
+        * inspector/front-end/TextViewer.js:
+        (WebInspector.TextViewer.prototype.setSelection):
+        (WebInspector.TextEditorMainPanel.prototype.highlightLine):
+
 2012-06-27  Vsevolod Vlasov  <[email protected]>
 
         Web Inspector: IDBObjectStore.autoIncrement flag not exposed

Modified: trunk/Source/WebCore/inspector/front-end/_javascript_SourceFrame.js (121533 => 121534)


--- trunk/Source/WebCore/inspector/front-end/_javascript_SourceFrame.js	2012-06-29 09:05:58 UTC (rev 121533)
+++ trunk/Source/WebCore/inspector/front-end/_javascript_SourceFrame.js	2012-06-29 09:09:02 UTC (rev 121534)
@@ -437,6 +437,8 @@
             this.textViewer.addDecoration(lineNumber, "webkit-execution-line");
             this.revealLine(this._executionLineNumber);
         }
+        if (this.canEditSource())
+            this.setSelection(WebInspector.TextRange.createFromLocation(lineNumber, 0));
     },
 
     clearExecutionLine: function()

Modified: trunk/Source/WebCore/inspector/front-end/ScriptsPanel.js (121533 => 121534)


--- trunk/Source/WebCore/inspector/front-end/ScriptsPanel.js	2012-06-29 09:05:58 UTC (rev 121533)
+++ trunk/Source/WebCore/inspector/front-end/ScriptsPanel.js	2012-06-29 09:09:02 UTC (rev 121534)
@@ -548,6 +548,7 @@
         this._editorContainer.uiSourceCodeAdded(uiLocation.uiSourceCode);
         var sourceFrame = this._showFile(uiLocation.uiSourceCode);
         sourceFrame.revealLine(uiLocation.lineNumber);
+        sourceFrame.focus();
     },
 
     _callFrameSelected: function(event)
@@ -578,8 +579,9 @@
     _editorSelected: function(event)
     {
         var uiSourceCode = /** @type {WebInspector.UISourceCode} */ event.data;
-        this._showFile(uiSourceCode);
+        var sourceFrame = this._showFile(uiSourceCode);
         this._navigatorController.hideNavigatorOverlay();
+        sourceFrame.focus();
     },
 
     _scriptSelected: function(event)

Modified: trunk/Source/WebCore/inspector/front-end/SourceFrame.js (121533 => 121534)


--- trunk/Source/WebCore/inspector/front-end/SourceFrame.js	2012-06-29 09:05:58 UTC (rev 121533)
+++ trunk/Source/WebCore/inspector/front-end/SourceFrame.js	2012-06-29 09:09:02 UTC (rev 121534)
@@ -177,6 +177,17 @@
             this._lineToReveal = line;
     },
 
+    /**
+     * @param {WebInspector.TextRange} textRange
+     */
+    setSelection: function(textRange)
+    {
+        if (this.loaded)
+            this._textViewer.setSelection(textRange);
+        else
+            this._selectionToSet = textRange;
+    },
+
     _clearLineToReveal: function()
     {
         delete this._lineToReveal;
@@ -218,6 +229,11 @@
             delete this._lineToReveal;
         }
 
+        if (typeof this._selectionToSet === "object") {
+            this.setSelection(this._selectionToSet);
+            delete this._selectionToSet;
+        }
+
         if (this._delayedFindSearchMatches) {
             this._delayedFindSearchMatches();
             delete this._delayedFindSearchMatches;

Modified: trunk/Source/WebCore/inspector/front-end/TextEditorModel.js (121533 => 121534)


--- trunk/Source/WebCore/inspector/front-end/TextEditorModel.js	2012-06-29 09:05:58 UTC (rev 121533)
+++ trunk/Source/WebCore/inspector/front-end/TextEditorModel.js	2012-06-29 09:09:02 UTC (rev 121534)
@@ -43,6 +43,11 @@
     this.endColumn = endColumn;
 }
 
+WebInspector.TextRange.createFromLocation = function(line, column)
+{
+    return new WebInspector.TextRange(line, column, line, column);
+}
+
 WebInspector.TextRange.prototype = {
     /**
      * @return {boolean}

Modified: trunk/Source/WebCore/inspector/front-end/TextViewer.js (121533 => 121534)


--- trunk/Source/WebCore/inspector/front-end/TextViewer.js	2012-06-29 09:05:58 UTC (rev 121533)
+++ trunk/Source/WebCore/inspector/front-end/TextViewer.js	2012-06-29 09:09:02 UTC (rev 121534)
@@ -307,6 +307,14 @@
         return true;
     },
 
+    /**
+     * @param {WebInspector.TextRange} textRange
+     */
+    setSelection: function(textRange)
+    {
+        this._mainPanel._restoreSelection(textRange);
+    },
+    
     wasShown: function()
     {
         if (!this.readOnly())
@@ -1059,7 +1067,7 @@
         this.revealLine(lineNumber);
 
         if (!this._readOnly)
-            this._restoreSelection(new WebInspector.TextRange(lineNumber, 0, lineNumber, 0), false);
+            this._restoreSelection(WebInspector.TextRange.createFromLocation(lineNumber, 0), false);
 
         this.addDecoration(lineNumber, "webkit-highlighted-line");
     },
@@ -1160,7 +1168,7 @@
             indentEndLine--;
 
         for (var lineNumber = range.startLine; lineNumber <= indentEndLine; lineNumber++)
-            this._textModel.editRange(new WebInspector.TextRange(lineNumber, 0, lineNumber, 0), indent);
+            this._textModel.editRange(new WebInspector.TextRange.createFromLocation(lineNumber, 0), indent);
 
         this._lastEditedRange = newRange;
 
@@ -1534,6 +1542,9 @@
         this._cachedRows.push(lineRow);
     },
 
+    /**
+     * @return {WebInspector.TextRange}
+     */
     _getSelection: function()
     {
         var selection = window.getSelection();
@@ -1568,12 +1579,6 @@
         }
     },
 
-    _setCaretLocation: function(line, column, scrollIntoView)
-    {
-        var range = new WebInspector.TextRange(line, column, line, column);
-        this._restoreSelection(range, scrollIntoView);
-    },
-
     _selectionToPosition: function(container, offset)
     {
         if (container === this._container && offset === 0)
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to