Web Inspector: fix bug in highlighting single chars via highlightRange API of DTE
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 2 Feb 2013 11:58:26 +0000 (11:58 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 2 Feb 2013 11:58:26 +0000 (11:58 +0000)
https://bugs.webkit.org/show_bug.cgi?id=108685

Patch by Andrey Lushnikov <lushnikov@chromium.org> on 2013-02-02
Reviewed by Pavel Feldman.

Source/WebCore:

Use Math.min instead of Math.max in rangesForLine method.

Updated test: text-editor-highlight-api.html

* inspector/front-end/DefaultTextEditor.js:
(WebInspector.TextEditorMainPanel.RangeHighlightDescriptor.prototype.rangesForLine):

LayoutTests:

Updated layout test to cover specific bug case.

* inspector/editor/text-editor-highlight-api-expected.txt:
* inspector/editor/text-editor-highlight-api.html:

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

LayoutTests/ChangeLog
LayoutTests/inspector/editor/text-editor-highlight-api-expected.txt
LayoutTests/inspector/editor/text-editor-highlight-api.html
Source/WebCore/ChangeLog
Source/WebCore/inspector/front-end/DefaultTextEditor.js

index 14fda30..bad26ed 100644 (file)
@@ -1,3 +1,15 @@
+2013-02-02  Andrey Lushnikov  <lushnikov@chromium.org>
+
+        Web Inspector: fix bug in highlighting single chars via highlightRange API of DTE
+        https://bugs.webkit.org/show_bug.cgi?id=108685
+
+        Reviewed by Pavel Feldman.
+
+        Updated layout test to cover specific bug case.
+
+        * inspector/editor/text-editor-highlight-api-expected.txt:
+        * inspector/editor/text-editor-highlight-api.html:
+
 2013-02-02  Zan Dobersek  <zdobersek@igalia.com>
 
         Unreviewed GTK gardening.
index da7816d..658d435 100644 (file)
@@ -63,3 +63,16 @@ Lines repainted: 3
 <div class="webkit-line-content">global_foo2</div>
 <div class="webkit-line-content">some_other_foo_X</div></div>
 
+Running: testHighlightSmallRange
+
+Highlighting range from (1, 1) to (1, 1)
+Lines repainted: 1
+
+<div class="inner-container" tabindex="0">
+<div class="webkit-line-content">foo();</div>
+<div class="webkit-line-content">foo_1; foor; foo_;<span class="some-other-class text-editor-overlay-highlight" style="left: 7px; width: 7px; height: <number>px;"></span></div>
+<div class="webkit-line-content">foo_</div>
+<div class="webkit-line-content">global_foo</div>
+<div class="webkit-line-content">global_foo2</div>
+<div class="webkit-line-content">some_other_foo_X</div></div>
+
index e9d83cb..09ce5fd 100644 (file)
@@ -67,6 +67,17 @@ function test()
             InspectorTest.dumpEditorHTML(textEditor, true);
             next();
         },
+
+        function testHighlightSmallRange(next)
+        {
+            InspectorTest.addResult("\nHighlighting range from (1, 1) to (1, 1)");
+            paintLineCalls = 0;
+            var smallRangeHighlightDescriptor = textEditor.highlightRange(new WebInspector.TextRange(1, 1, 1, 1), "some-other-class");
+            InspectorTest.addResult("Lines repainted: " + paintLineCalls);
+            InspectorTest.dumpEditorHTML(textEditor, true);
+            next();
+        },
+
     ]);
 }
 
index 5e084a5..2a7381e 100644 (file)
@@ -1,3 +1,17 @@
+2013-02-02  Andrey Lushnikov  <lushnikov@chromium.org>
+
+        Web Inspector: fix bug in highlighting single chars via highlightRange API of DTE
+        https://bugs.webkit.org/show_bug.cgi?id=108685
+
+        Reviewed by Pavel Feldman.
+
+        Use Math.min instead of Math.max in rangesForLine method.
+
+        Updated test: text-editor-highlight-api.html
+
+        * inspector/front-end/DefaultTextEditor.js:
+        (WebInspector.TextEditorMainPanel.RangeHighlightDescriptor.prototype.rangesForLine):
+
 2013-02-02  Tony Gentilcore  <tonyg@chromium.org>
 
         Continue making XSSAuditor thread safe: Remove unsafe AtomicString compares
index 2a7ed83..30a3364 100644 (file)
@@ -2825,7 +2825,7 @@ WebInspector.TextEditorMainPanel.RangeHighlightDescriptor.prototype = {
             return [];
 
         var startColumn = lineNumber === this._range.startLine ? this._range.startColumn : 0;
-        var endColumn = lineNumber === this._range.endLine ? Math.max(this._range.endColumn, line.length) : line.length;
+        var endColumn = lineNumber === this._range.endLine ? Math.min(this._range.endColumn, line.length) : line.length;
         return [{
             startColumn: startColumn,
             endColumn: endColumn