Changeset 142471 in webkit


Ignore:
Timestamp:
Feb 11, 2013 7:40:18 AM (11 years ago)
Author:
commit-queue@webkit.org
Message:

Web Inspector: introduce WebInspector.TextUtils
https://bugs.webkit.org/show_bug.cgi?id=109289

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

Add new WebInspector.TextUtils file and extract commonly used
text-operation subroutines from DefaultTextEditor into it.

No new tests: no change in behaviour.

  • WebCore.gypi:
  • WebCore.vcproj/WebCore.vcproj:
  • inspector/compile-front-end.py:
  • inspector/front-end/DefaultTextEditor.js:

(WebInspector.TextEditorMainPanel.TokenHighlighter.prototype._isWord):
(WebInspector.DefaultTextEditor.WordMovementController.prototype._rangeForCtrlArrowMove):
(WebInspector.TextEditorMainPanel.BraceHighlightController.prototype.handleSelectionChange):

  • inspector/front-end/TextUtils.js: Added.

(WebInspector.TextUtils.isStopChar):
(WebInspector.TextUtils.isWordChar):
(WebInspector.TextUtils.isSpaceChar):
(WebInspector.TextUtils.isWord):
(WebInspector.TextUtils.isBraceChar):

  • inspector/front-end/WebKit.qrc:
  • inspector/front-end/inspector.html:
Location:
trunk/Source/WebCore
Files:
1 added
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r142463 r142471  
     12013-02-11  Andrey Lushnikov  <lushnikov@chromium.org>
     2
     3        Web Inspector: introduce WebInspector.TextUtils
     4        https://bugs.webkit.org/show_bug.cgi?id=109289
     5
     6        Reviewed by Pavel Feldman.
     7
     8        Add new WebInspector.TextUtils file and extract commonly used
     9        text-operation subroutines from DefaultTextEditor into it.
     10
     11        No new tests: no change in behaviour.
     12
     13        * WebCore.gypi:
     14        * WebCore.vcproj/WebCore.vcproj:
     15        * inspector/compile-front-end.py:
     16        * inspector/front-end/DefaultTextEditor.js:
     17        (WebInspector.TextEditorMainPanel.TokenHighlighter.prototype._isWord):
     18        (WebInspector.DefaultTextEditor.WordMovementController.prototype._rangeForCtrlArrowMove):
     19        (WebInspector.TextEditorMainPanel.BraceHighlightController.prototype.handleSelectionChange):
     20        * inspector/front-end/TextUtils.js: Added.
     21        (WebInspector.TextUtils.isStopChar):
     22        (WebInspector.TextUtils.isWordChar):
     23        (WebInspector.TextUtils.isSpaceChar):
     24        (WebInspector.TextUtils.isWord):
     25        (WebInspector.TextUtils.isBraceChar):
     26        * inspector/front-end/WebKit.qrc:
     27        * inspector/front-end/inspector.html:
     28
    1292013-02-11  Zan Dobersek  <zdobersek@igalia.com>
    230
  • trunk/Source/WebCore/WebCore.gypi

    r142460 r142471  
    53035303            'inspector/front-end/TextEditorModel.js',
    53045304            'inspector/front-end/TextPrompt.js',
     5305            'inspector/front-end/TextUtils.js',
    53055306            'inspector/front-end/TimelineGrid.js',
    53065307            'inspector/front-end/TimelineManager.js',
  • trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj

    r142460 r142471  
    7777977779                                </File>
    7778077780                                <File
     77781                                        RelativePath="..\inspector\front-end\TextUtils.js"
     77782                                        >
     77783                                </File>
     77784                                <File
    7778177785                                        RelativePath="..\inspector\front-end\TimelineFrameController.js"
    7778277786                                        >
  • trunk/Source/WebCore/inspector/compile-front-end.py

    r141272 r142471  
    157157            "TextEditorModel.js",
    158158            "TextPrompt.js",
     159            "TextUtils.js",
    159160            "TimelineGrid.js",
    160161            "Toolbar.js",
  • trunk/Source/WebCore/inspector/front-end/DefaultTextEditor.js

    r142439 r142471  
    32193219}
    32203220
    3221 WebInspector.TextEditorMainPanel.TokenHighlighter._NonWordCharRegex = /[^a-zA-Z0-9_]/;
    3222 WebInspector.TextEditorMainPanel.TokenHighlighter._WordRegex = /^[a-zA-Z0-9_]+$/;
    3223 
    32243221WebInspector.TextEditorMainPanel.TokenHighlighter.prototype = {
    32253222    /**
     
    32883285    _isWord: function(range, selectedText)
    32893286    {
    3290         const NonWordChar = WebInspector.TextEditorMainPanel.TokenHighlighter._NonWordCharRegex;
    3291         const WordRegex = WebInspector.TextEditorMainPanel.TokenHighlighter._WordRegex;
    32923287        var line = this._textModel.line(range.startLine);
    3293         var leftBound = range.startColumn === 0 || NonWordChar.test(line.charAt(range.startColumn - 1));
    3294         var rightBound = range.endColumn === line.length || NonWordChar.test(line.charAt(range.endColumn));
    3295         return leftBound && rightBound && WordRegex.test(selectedText);
     3288        var leftBound = range.startColumn === 0 || !WebInspector.TextUtils.isWordChar(line.charAt(range.startColumn - 1));
     3289        var rightBound = range.endColumn === line.length || !WebInspector.TextUtils.isWordChar(line.charAt(range.endColumn));
     3290        return leftBound && rightBound && WebInspector.TextUtils.isWord(selectedText);
    32963291    }
    32973292}
     
    33333328    _rangeForCtrlArrowMove: function(selection, direction)
    33343329    {
    3335         /**
    3336          * @param {string} char
    3337          */
    3338         function isStopChar(char)
    3339         {
    3340             return (char > " " && char < "0") ||
    3341                 (char > "9" && char < "A") ||
    3342                 (char > "Z" && char < "a") ||
    3343                 (char > "z" && char <= "~");
    3344         }
    3345 
    3346         /**
    3347          * @param {string} char
    3348          */
    3349         function isSpaceChar(char)
    3350         {
    3351             return char === "\t" || char === "\r" || char === "\n" || char === " ";
    3352         }
     3330        const isStopChar = WebInspector.TextUtils.isStopChar;
     3331        const isSpaceChar = WebInspector.TextUtils.isSpaceChar;
    33533332
    33543333        var lineNumber = selection.endLine;
     
    34623441        var column = selectionRange.startColumn;
    34633442        var line = this._textModel.line(lineNumber);
    3464         if (column > 0 && /[)}]/.test(line.charAt(column - 1)))
     3443        if (column > 0 && WebInspector.TextUtils.isBraceChar(line.charAt(column - 1)))
    34653444            --column;
    34663445
  • trunk/Source/WebCore/inspector/front-end/WebKit.qrc

    r141272 r142471  
    205205    <file>TextEditorModel.js</file>
    206206    <file>TextPrompt.js</file>
     207    <file>TextUtils.js</file>
    207208    <file>TimelineFrameController.js</file>
    208209    <file>TimelineManager.js</file>
  • trunk/Source/WebCore/inspector/front-end/inspector.html

    r141258 r142471  
    126126    <script type="text/javascript" src="TextEditorModel.js"></script>
    127127    <script type="text/javascript" src="TextEditorHighlighter.js"></script>
     128    <script type="text/javascript" src="TextUtils.js"></script>
    128129    <script type="text/javascript" src="SourceTokenizer.js"></script>
    129130    <script type="text/javascript" src="SourceCSSTokenizer.js"></script>
Note: See TracChangeset for help on using the changeset viewer.