Changeset 141401 in webkit


Ignore:
Timestamp:
Jan 31, 2013 4:04:09 AM (11 years ago)
Author:
commit-queue@webkit.org
Message:

Web Inspector: DTE doesn't highlight words if the selected one is the last in the line
https://bugs.webkit.org/show_bug.cgi?id=108344

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

Source/WebCore:

Fix error in _isWord function which made an erroneous line-end check.

Improved test: inspector/editor/text-editor-highlight-token.html

  • inspector/front-end/DefaultTextEditor.js:

(WebInspector.TextEditorMainPanel.TokenHighlighter.prototype._isWord):

LayoutTests:

Add a test to cover specific case which caused the bug.

  • inspector/editor/text-editor-highlight-token-expected.txt:
  • inspector/editor/text-editor-highlight-token.html:
Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r141399 r141401  
     12013-01-31  Andrey Lushnikov  <lushnikov@chromium.org>
     2
     3        Web Inspector: DTE doesn't highlight words if the selected one is the last in the line
     4        https://bugs.webkit.org/show_bug.cgi?id=108344
     5
     6        Reviewed by Pavel Feldman.
     7
     8        Add a test to cover specific case which caused the bug.
     9
     10        * inspector/editor/text-editor-highlight-token-expected.txt:
     11        * inspector/editor/text-editor-highlight-token.html:
     12
    1132013-01-31  Andrey Lushnikov  <lushnikov@chromium.org>
    214
  • trunk/LayoutTests/inspector/editor/text-editor-highlight-token-expected.txt

    r140828 r141401  
    33=========== TextEditor text ==========
    44function findElement(collection, elem) {
     5        // length
    56        for(var i = 0; i < collection.length; ++i)
    67            if (collection[i] === elem)
     
    1213<div class="inner-container text-editor-editable" tabindex="0">
    1314<div class="webkit-line-content">function findElement(collection, elem) {</div>
     15<div class="webkit-line-content">        // length</div>
    1416<div class="webkit-line-content">        for(var i = 0; i <span class="webkit-html-tag">&lt;</span> <span class="webkit-html-tag">collection.length;</span> <span class="webkit-html-attribute-name">++i)</span></div>
    1517<div class="webkit-line-content">            <span class="webkit-html-attribute-name">if</span> <span class="webkit-html-attribute-name">(collection</span>[<span class="webkit-html-attribute-name">i</span>] === <span class="webkit-html-attribute-value">elem)</span></div>
     
    2123<div class="inner-container text-editor-editable" tabindex="0">
    2224<div class="webkit-line-content">function findElement(collection, elem) {<span class="text-editor-token-highlight text-editor-overlay-highlight" style="left: 146px; width: 72px;"> </span></div>
     25<div class="webkit-line-content">        // length</div>
    2326<div class="webkit-line-content">        for(var i = 0; i <span class="webkit-html-tag">&lt;</span> <span class="webkit-html-tag">collection.length;</span> <span class="webkit-html-attribute-name">++i)</span><span class="text-editor-token-highlight text-editor-overlay-highlight" style="left: 188px; width: 72px;"> </span></div>
    2427<div class="webkit-line-content">            <span class="webkit-html-attribute-name">if</span> <span class="webkit-html-attribute-name">(collection</span>[<span class="webkit-html-attribute-name">i</span>] === <span class="webkit-html-attribute-value">elem)</span><span class="text-editor-token-highlight text-editor-overlay-highlight" style="left: 111px; width: 72px;"> </span></div>
     
    3033<div class="inner-container text-editor-editable" tabindex="0">
    3134<div class="webkit-line-content">function findElement(collection, elem) {<span class="text-editor-token-highlight text-editor-overlay-highlight" style="left: 230px; width: 30px;"> </span></div>
     35<div class="webkit-line-content">        // length</div>
    3236<div class="webkit-line-content">        for(var i = 0; i <span class="webkit-html-tag">&lt;</span> <span class="webkit-html-tag">collection.length;</span> <span class="webkit-html-attribute-name">++i)</span></div>
    3337<div class="webkit-line-content">            <span class="webkit-html-attribute-name">if</span> <span class="webkit-html-attribute-name">(collection</span>[<span class="webkit-html-attribute-name">i</span>] === <span class="webkit-html-attribute-value">elem)</span><span class="text-editor-token-highlight text-editor-overlay-highlight" style="left: 237px; width: 30px;"> </span></div>
     
    3539<div class="webkit-line-content">        <span class="webkit-html-attribute-value">return</span> <span class="webkit-html-attribute-value">null;</span></div>
    3640<div class="webkit-line-content">    <span class="webkit-html-attribute-value">}</span></div></div>
     41=========== After selecting 'length' ===========
    3742
     43<div class="inner-container text-editor-editable" tabindex="0">
     44<div class="webkit-line-content">function findElement(collection, elem) {</div>
     45<div class="webkit-line-content">        // length<span class="text-editor-token-highlight text-editor-overlay-highlight" style="left: 76px; width: 44px;"> </span></div>
     46<div class="webkit-line-content">        for(var i = 0; i <span class="webkit-html-tag">&lt;</span> <span class="webkit-html-tag">collection.length;</span> <span class="webkit-html-attribute-name">++i)</span><span class="text-editor-token-highlight text-editor-overlay-highlight" style="left: 265px; width: 44px;"> </span></div>
     47<div class="webkit-line-content">            <span class="webkit-html-attribute-name">if</span> <span class="webkit-html-attribute-name">(collection</span>[<span class="webkit-html-attribute-name">i</span>] === <span class="webkit-html-attribute-value">elem)</span></div>
     48<div class="webkit-line-content">                <span class="webkit-html-attribute-value">return</span> <span class="webkit-html-attribute-value">i;</span></div>
     49<div class="webkit-line-content">        <span class="webkit-html-attribute-value">return</span> <span class="webkit-html-attribute-value">null;</span></div>
     50<div class="webkit-line-content">    <span class="webkit-html-attribute-value">}</span></div></div>
     51
  • trunk/LayoutTests/inspector/editor/text-editor-highlight-token.html

    r140828 r141401  
    77{
    88    function findElement(collection, elem) {
     9        // length
    910        for(var i = 0; i < collection.length; ++i)
    1011            if (collection[i] === elem)
     
    1314    }
    1415
    15     var steps = [step2, step1]; // reversed order
     16    var steps = [step3, step2, step1]; // reversed order
    1617    function selectionChangeListener()
    1718    {
     
    4950        InspectorTest.addResult("=========== After selecting '" + textEditor._textModel.copyRange(range) + "' ===========");
    5051        InspectorTest.dumpEditorHTML(textEditor, true);
     52        range = new WebInspector.TextRange(1, 11, 1, 17);
     53        textEditor.setSelection(range);
     54    }
     55
     56    function step3()
     57    {
     58        InspectorTest.addResult("=========== After selecting '" + textEditor._textModel.copyRange(range) + "' ===========");
     59        InspectorTest.dumpEditorHTML(textEditor, true);
    5160        InspectorTest.completeTest();
    5261    }
  • trunk/Source/WebCore/ChangeLog

    r141398 r141401  
     12013-01-31  Andrey Lushnikov  <lushnikov@chromium.org>
     2
     3        Web Inspector: DTE doesn't highlight words if the selected one is the last in the line
     4        https://bugs.webkit.org/show_bug.cgi?id=108344
     5
     6        Reviewed by Pavel Feldman.
     7
     8        Fix error in _isWord function which made an erroneous line-end check.
     9
     10        Improved test: inspector/editor/text-editor-highlight-token.html
     11
     12        * inspector/front-end/DefaultTextEditor.js:
     13        (WebInspector.TextEditorMainPanel.TokenHighlighter.prototype._isWord):
     14
    1152013-01-31  Philippe Normand  <pnormand@igalia.com>
    216
  • trunk/Source/WebCore/inspector/front-end/DefaultTextEditor.js

    r141257 r141401  
    31883188        var line = this._textModel.line(range.startLine);
    31893189        var leftBound = range.startColumn === 0 || NonWordChar.test(line.charAt(range.startColumn - 1));
    3190         var rightBound = range.endColumn === line.length - 1 || NonWordChar.test(line.charAt(range.endColumn));
     3190        var rightBound = range.endColumn === line.length || NonWordChar.test(line.charAt(range.endColumn));
    31913191        return leftBound && rightBound && WordRegex.test(selectedText);
    31923192    }
Note: See TracChangeset for help on using the changeset viewer.