Changeset 142471 in webkit
- Timestamp:
- Feb 11, 2013 7:40:18 AM (11 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 1 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r142463 r142471 1 2013-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 1 29 2013-02-11 Zan Dobersek <zdobersek@igalia.com> 2 30 -
trunk/Source/WebCore/WebCore.gypi
r142460 r142471 5303 5303 'inspector/front-end/TextEditorModel.js', 5304 5304 'inspector/front-end/TextPrompt.js', 5305 'inspector/front-end/TextUtils.js', 5305 5306 'inspector/front-end/TimelineGrid.js', 5306 5307 'inspector/front-end/TimelineManager.js', -
trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj
r142460 r142471 77779 77779 </File> 77780 77780 <File 77781 RelativePath="..\inspector\front-end\TextUtils.js" 77782 > 77783 </File> 77784 <File 77781 77785 RelativePath="..\inspector\front-end\TimelineFrameController.js" 77782 77786 > -
trunk/Source/WebCore/inspector/compile-front-end.py
r141272 r142471 157 157 "TextEditorModel.js", 158 158 "TextPrompt.js", 159 "TextUtils.js", 159 160 "TimelineGrid.js", 160 161 "Toolbar.js", -
trunk/Source/WebCore/inspector/front-end/DefaultTextEditor.js
r142439 r142471 3219 3219 } 3220 3220 3221 WebInspector.TextEditorMainPanel.TokenHighlighter._NonWordCharRegex = /[^a-zA-Z0-9_]/;3222 WebInspector.TextEditorMainPanel.TokenHighlighter._WordRegex = /^[a-zA-Z0-9_]+$/;3223 3224 3221 WebInspector.TextEditorMainPanel.TokenHighlighter.prototype = { 3225 3222 /** … … 3288 3285 _isWord: function(range, selectedText) 3289 3286 { 3290 const NonWordChar = WebInspector.TextEditorMainPanel.TokenHighlighter._NonWordCharRegex;3291 const WordRegex = WebInspector.TextEditorMainPanel.TokenHighlighter._WordRegex;3292 3287 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 && W ordRegex.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); 3296 3291 } 3297 3292 } … … 3333 3328 _rangeForCtrlArrowMove: function(selection, direction) 3334 3329 { 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; 3353 3332 3354 3333 var lineNumber = selection.endLine; … … 3462 3441 var column = selectionRange.startColumn; 3463 3442 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))) 3465 3444 --column; 3466 3445 -
trunk/Source/WebCore/inspector/front-end/WebKit.qrc
r141272 r142471 205 205 <file>TextEditorModel.js</file> 206 206 <file>TextPrompt.js</file> 207 <file>TextUtils.js</file> 207 208 <file>TimelineFrameController.js</file> 208 209 <file>TimelineManager.js</file> -
trunk/Source/WebCore/inspector/front-end/inspector.html
r141258 r142471 126 126 <script type="text/javascript" src="TextEditorModel.js"></script> 127 127 <script type="text/javascript" src="TextEditorHighlighter.js"></script> 128 <script type="text/javascript" src="TextUtils.js"></script> 128 129 <script type="text/javascript" src="SourceTokenizer.js"></script> 129 130 <script type="text/javascript" src="SourceCSSTokenizer.js"></script>
Note: See TracChangeset
for help on using the changeset viewer.