Web Inspector: Whole program sometimes highlighted instead of just first statement
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 12 Oct 2016 18:43:19 +0000 (18:43 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 12 Oct 2016 18:43:19 +0000 (18:43 +0000)
https://bugs.webkit.org/show_bug.cgi?id=163300
<rdar://problem/28723162>

Patch by Joseph Pecoraro <pecoraro@apple.com> on 2016-10-12
Reviewed by Timothy Hatcher.

* UserInterface/Views/SourceCodeTextEditor.js:
(WebInspector.SourceCodeTextEditor.prototype.textEditorExecutionHighlightRange):
Avoid highlighting the entire program by skipping a Program type Node.

* UserInterface/Views/TextEditor.js:
(WebInspector.TextEditor.prototype.setExecutionLineAndColumn):
Avoid unnecessary work before content has loaded.

(WebInspector.TextEditor.prototype.currentPositionToOriginalOffset):
Avoid unnecessary indirection to get the CodeMirror editor.

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

Source/WebInspectorUI/ChangeLog
Source/WebInspectorUI/UserInterface/Views/SourceCodeTextEditor.js
Source/WebInspectorUI/UserInterface/Views/TextEditor.js

index 31b5ca6..94db3f1 100644 (file)
@@ -1,3 +1,22 @@
+2016-10-12  Joseph Pecoraro  <pecoraro@apple.com>
+
+        Web Inspector: Whole program sometimes highlighted instead of just first statement
+        https://bugs.webkit.org/show_bug.cgi?id=163300
+        <rdar://problem/28723162>
+
+        Reviewed by Timothy Hatcher.
+
+        * UserInterface/Views/SourceCodeTextEditor.js:
+        (WebInspector.SourceCodeTextEditor.prototype.textEditorExecutionHighlightRange):
+        Avoid highlighting the entire program by skipping a Program type Node.
+
+        * UserInterface/Views/TextEditor.js:
+        (WebInspector.TextEditor.prototype.setExecutionLineAndColumn):
+        Avoid unnecessary work before content has loaded.
+
+        (WebInspector.TextEditor.prototype.currentPositionToOriginalOffset):
+        Avoid unnecessary indirection to get the CodeMirror editor.
+
 2016-10-11  Joseph Pecoraro  <pecoraro@apple.com>
 
         Web Inspector: Remove line highlight on primary execution line while stepping because it is distracting
index 6290c4f..4a9fa9d 100644 (file)
@@ -1235,9 +1235,10 @@ WebInspector.SourceCodeTextEditor = class SourceCodeTextEditor extends WebInspec
             }
 
             // Find a node starting at this offset.
+            // Avoid highlighting the entire program if this is the start of the first statement.
             for (let node of nodes) {
                 let startOffset = node.range[0];
-                if (startOffset === offset) {
+                if (startOffset === offset && node.type !== WebInspector.ScriptSyntaxTree.NodeType.Program) {
                     callback(convertRangeOffsetsToSourceCodeOffsets(node.range));
                     return;
                 }
index 0d033f6..ba64cc3 100644 (file)
@@ -336,8 +336,10 @@ WebInspector.TextEditor = class TextEditor extends WebInspector.View
         this._executionLineNumber = lineNumber;
         this._executionColumnNumber = columnNumber;
 
-        this._updateExecutionLine();
-        this._updateExecutionRangeHighlight();
+        if (!this._initialStringNotSet) {
+            this._updateExecutionLine();
+            this._updateExecutionRangeHighlight();
+        }
 
         // Still dispatch the event even if the number didn't change. The execution state still
         // could have changed (e.g. continuing in a loop with a breakpoint inside).
@@ -703,7 +705,7 @@ WebInspector.TextEditor = class TextEditor extends WebInspector.View
         if (this._formatterSourceMap)
             offset = this._formatterSourceMap.formattedToOriginalOffset(position.line, position.ch);
         else
-            offset = this.tokenTrackingController._codeMirror.getDoc().indexFromPos(position);
+            offset = this._codeMirror.getDoc().indexFromPos(position);
 
         return offset;
     }