Changeset 141245 in webkit
- Timestamp:
- Jan 30, 2013 3:53:04 AM (11 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r141244 r141245 1 2013-01-30 Andrey Lushnikov <lushnikov@chromium.org> 2 3 Web Inspector: implmenet Ctrl-Arrow/Ctrl-Backspace in DefaultTextEditor 4 https://bugs.webkit.org/show_bug.cgi?id=107944 5 6 Reviewed by Pavel Feldman. 7 8 Add new test to verify ctrl-arrow/ctrl-backspace behavior. Exclude 9 this test on the platforms that do not currently support eventSender. 10 11 * inspector/editor/text-editor-ctrl-movements-expected.txt: Added. 12 * inspector/editor/text-editor-ctrl-movements.html: Added. 13 * platform/efl/TestExpectations: 14 * platform/mac/TestExpectations: 15 * platform/qt/TestExpectations: 16 1 17 2013-01-30 Andrey Lushnikov <lushnikov@chromium.org> 2 18 -
trunk/LayoutTests/platform/efl/TestExpectations
r141239 r141245 1798 1798 # https://bugs.webkit.org/show_bug.cgi?id=106883 1799 1799 inspector/editor/text-editor-formatter.html 1800 inspector/editor/text-editor-ctrl-movements.html 1800 1801 1801 1802 # Test fails on JSC platforms due to GC timing problems -
trunk/LayoutTests/platform/mac/TestExpectations
r141243 r141245 241 241 # https://bugs.webkit.org/show_bug.cgi?id=106793 242 242 inspector/editor/text-editor-formatter.html [ Skip ] 243 inspector/editor/text-editor-ctrl-movements.html [ Skip ] 243 244 244 245 # https://bugs.webkit.org/show_bug.cgi?id=71120 -
trunk/LayoutTests/platform/qt/TestExpectations
r141123 r141245 2556 2556 # https://bugs.webkit.org/show_bug.cgi?id=106883 2557 2557 inspector/editor/text-editor-formatter.html 2558 inspector/editor/text-editor-ctrl-movements.html 2558 2559 2559 2560 # Needs rebaseline after https://bugs.webkit.org/show_bug.cgi?id=14664 -
trunk/Source/WebCore/ChangeLog
r141244 r141245 1 2013-01-30 Andrey Lushnikov <lushnikov@chromium.org> 2 3 ctrl-arrows, ctrl-shift-arrow, ctrl-backspace 4 5 Web Inspector: implmenet Ctrl-Arrow/Ctrl-Backspace in DefaultTextEditor 6 https://bugs.webkit.org/show_bug.cgi?id=107944 7 8 Reviewed by Pavel Feldman. 9 10 Add ctrl-arrows/ctrl-shift-arrow/ctrl-backspace shortcuts to jump over 11 and delete words. 12 13 New test: inspector/editor/text-editor-ctrl-movements.html 14 15 * inspector/front-end/DefaultTextEditor.js: 16 (WebInspector.DefaultTextEditor): 17 (WebInspector.DefaultTextEditor.prototype._registerShortcuts): 18 (WebInspector.DefaultTextEditor.prototype.selection): 19 (WebInspector.DefaultTextEditor.WordMovementController): Added. 20 (WebInspector.DefaultTextEditor.WordMovementController.prototype._registerShortcuts): 21 (WebInspector.DefaultTextEditor.WordMovementController.prototype.): 22 (WebInspector.DefaultTextEditor.WordMovementController.prototype._rangeForCtrlArrowMove): 23 (WebInspector.DefaultTextEditor.WordMovementController.prototype._handleCtrlArrow): 24 (WebInspector.DefaultTextEditor.WordMovementController.prototype._handleCtrlShiftArrow): 25 (WebInspector.DefaultTextEditor.WordMovementController.prototype._handleCtrlBackspace): 26 1 27 2013-01-30 Andrey Lushnikov <lushnikov@chromium.org> 2 28 -
trunk/Source/WebCore/inspector/front-end/DefaultTextEditor.js
r141244 r141245 95 95 this.element.addEventListener("contextmenu", this._contextMenu.bind(this), true); 96 96 97 this._wordMovementController = new WebInspector.DefaultTextEditor.WordMovementController(this, this._textModel); 97 98 this._registerShortcuts(); 98 99 } … … 412 413 this._shortcuts[WebInspector.KeyboardShortcut.makeKey(keys.Tab.code)] = handleTabKey; 413 414 this._shortcuts[WebInspector.KeyboardShortcut.makeKey(keys.Tab.code, modifiers.Shift)] = handleShiftTabKey; 415 416 this._wordMovementController._registerShortcuts(this._shortcuts); 414 417 }, 415 418 … … 470 473 * @return {WebInspector.TextRange} 471 474 */ 472 selection: function( textRange)475 selection: function() 473 476 { 474 477 return this._mainPanel.selection(); … … 3119 3122 } 3120 3123 3124 /** 3125 * @constructor 3126 * @param {WebInspector.TextEditorModel} textModel 3127 * @param {WebInspector.TextEditor} textEditor 3128 */ 3129 WebInspector.DefaultTextEditor.WordMovementController = function(textEditor, textModel) 3130 { 3131 this._textModel = textModel; 3132 this._textEditor = textEditor; 3133 } 3134 3135 WebInspector.DefaultTextEditor.WordMovementController.prototype = { 3136 3137 /** 3138 * @param {Object.<number, function()>} shortcuts 3139 */ 3140 _registerShortcuts: function(shortcuts) 3141 { 3142 var keys = WebInspector.KeyboardShortcut.Keys; 3143 var modifiers = WebInspector.KeyboardShortcut.Modifiers; 3144 3145 const wordJumpModifier = WebInspector.isMac() ? modifiers.Alt : modifiers.Ctrl; 3146 shortcuts[WebInspector.KeyboardShortcut.makeKey(keys.Backspace.code, wordJumpModifier)] = this._handleCtrlBackspace.bind(this); 3147 shortcuts[WebInspector.KeyboardShortcut.makeKey(keys.Left.code, wordJumpModifier)] = this._handleCtrlArrow.bind(this, "left"); 3148 shortcuts[WebInspector.KeyboardShortcut.makeKey(keys.Right.code, wordJumpModifier)] = this._handleCtrlArrow.bind(this, "right"); 3149 shortcuts[WebInspector.KeyboardShortcut.makeKey(keys.Left.code, modifiers.Shift | wordJumpModifier)] = this._handleCtrlShiftArrow.bind(this, "left"); 3150 shortcuts[WebInspector.KeyboardShortcut.makeKey(keys.Right.code, modifiers.Shift | wordJumpModifier)] = this._handleCtrlShiftArrow.bind(this, "right"); 3151 }, 3152 3153 /** 3154 * @param {WebInspector.TextRange} selection 3155 * @param {string} direction 3156 * @return {WebInspector.TextRange} 3157 */ 3158 _rangeForCtrlArrowMove: function(selection, direction) 3159 { 3160 /** 3161 * @param {string} char 3162 */ 3163 function isStopChar(char) 3164 { 3165 return (char > " " && char < "0") || 3166 (char > "9" && char < "A") || 3167 (char > "Z" && char < "a") || 3168 (char > "z" && char <= "~"); 3169 } 3170 3171 /** 3172 * @param {string} char 3173 */ 3174 function isSpaceChar(char) 3175 { 3176 return char === "\t" || char === "\r" || char === "\n" || char === " "; 3177 } 3178 3179 var lineNumber = selection.endLine; 3180 var column = selection.endColumn; 3181 if (direction === "left") 3182 --column; 3183 3184 if (column === -1 && direction === "left") { 3185 if (lineNumber > 0) 3186 return new WebInspector.TextRange(selection.startLine, selection.startColumn, lineNumber - 1, this._textModel.line(lineNumber - 1).length); 3187 else 3188 return selection.clone(); 3189 } 3190 3191 var line = this._textModel.line(lineNumber); 3192 if (column === line.length && direction === "right") { 3193 if (lineNumber + 1 < this._textModel.linesCount) 3194 return new WebInspector.TextRange(selection.startLine, selection.startColumn, selection.endLine + 1, 0); 3195 else 3196 return selection.clone(); 3197 } 3198 3199 var delta = direction === "left" ? -1 : +1; 3200 var directionDependentEndColumnOffset = (delta + 1) / 2; 3201 3202 if (isSpaceChar(line.charAt(column))) { 3203 while(column + delta >= 0 && column + delta < line.length && isSpaceChar(line.charAt(column + delta))) 3204 column += delta; 3205 if (column + delta < 0 || column + delta === line.length) 3206 return new WebInspector.TextRange(selection.startLine, selection.startColumn, lineNumber, column + directionDependentEndColumnOffset); 3207 else 3208 column += delta; 3209 } 3210 3211 var group = isStopChar(line.charAt(column)); 3212 3213 while(column + delta >= 0 && column + delta < line.length && isStopChar(line.charAt(column + delta)) === group && !isSpaceChar(line.charAt(column + delta))) 3214 column += delta; 3215 3216 return new WebInspector.TextRange(selection.startLine, selection.startColumn, lineNumber, column + directionDependentEndColumnOffset); 3217 }, 3218 3219 /** 3220 * @param {string} direction 3221 * @return {boolean} 3222 */ 3223 _handleCtrlArrow: function(direction) 3224 { 3225 var newSelection = this._rangeForCtrlArrowMove(this._textEditor.selection(), direction); 3226 this._textEditor.setSelection(newSelection.collapseToEnd()); 3227 return true; 3228 }, 3229 3230 /** 3231 * @param {string} direction 3232 * @return {boolean} 3233 */ 3234 _handleCtrlShiftArrow: function(direction) 3235 { 3236 this._textEditor.setSelection(this._rangeForCtrlArrowMove(this._textEditor.selection(), direction)); 3237 return true; 3238 }, 3239 3240 /** 3241 * @return {boolean} 3242 */ 3243 _handleCtrlBackspace: function() 3244 { 3245 var selection = this._textEditor.selection(); 3246 if (!selection.isEmpty()) 3247 return false; 3248 3249 var newSelection = this._rangeForCtrlArrowMove(selection, "left"); 3250 this._textModel.editRange(newSelection.normalize(), ""); 3251 3252 this._textEditor.setSelection(newSelection.collapseToEnd()); 3253 return true; 3254 } 3255 } 3256 3121 3257 WebInspector.debugDefaultTextEditor = false; -
trunk/Source/WebCore/inspector/front-end/TextEditor.js
r141111 r141245 152 152 * @return {WebInspector.TextRange} 153 153 */ 154 selection: function( textRange) { },154 selection: function() { }, 155 155 156 156 /**
Note: See TracChangeset
for help on using the changeset viewer.