Commit 563aa625 authored by Robert Liao's avatar Robert Liao Committed by Commit Bot

Map Alt+Backspace to Undo in Blink

BUG=177450

Change-Id: I91fd7a22a58e1c9dc43bcfe279192e25dc9a5eff
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1968153
Commit-Queue: Robert Liao <robliao@chromium.org>
Reviewed-by: default avatarXiaocheng Hu <xiaochengh@chromium.org>
Auto-Submit: Robert Liao <robliao@chromium.org>
Cr-Commit-Position: refs/heads/master@{#734079}
parent 0777da7e
......@@ -176,6 +176,10 @@ const KeyboardCodeKeyDownEntry kKeyboardCodeKeyDownEntries[] = {
{'Z', kCtrlKey, "Undo"},
{'Z', kCtrlKey | kShiftKey, "Redo"},
{'Y', kCtrlKey, "Redo"},
#endif
#if defined(OS_WIN)
{VKEY_BACK, kAltKey, "Undo"},
{VKEY_BACK, kAltKey | kShiftKey, "Redo"},
#endif
{VKEY_INSERT, 0, "OverWrite"},
};
......
......@@ -39,8 +39,7 @@ namespace blink {
bool Editor::HandleEditingKeyboardEvent(KeyboardEvent* evt) {
const WebKeyboardEvent* key_event = evt->KeyEvent();
// do not treat this as text input if it's a system key event
if (!key_event || key_event->is_system_key)
if (!key_event)
return false;
String command_name = Behavior().InterpretKeyEvent(*evt);
......
<!doctype html>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<script src="../assert_selection.js"></script>
<script>
const isWin = navigator.platform.indexOf('Win') !== -1;
selection_test(
'<div contenteditable>one two three four|</div>',
selection => {
assert_own_property(window, 'eventSender',
'This test requires eventSender to test key bindings.');
selection.document.execCommand('insertText', false, 'undo');
if (isWin) {
// Alt+Backspace shortcut is bound to undo on Windows only.
// Performing this on Mac will cause a one word delete.
eventSender.keyDown('Backspace', 'altKey');
}
},
// Alt+Backspace shortcut is bound to undo on Windows only.
isWin
? '<div contenteditable>one two three four|</div>'
: '<div contenteditable>one two three fourundo|</div>',
'Alt+Backspace should be bound to undo on Windows');
selection_test(
'<div contenteditable>one two three four|</div>',
selection => {
assert_own_property(window, 'eventSender',
'This test requires eventSender to test key bindings.');
selection.document.execCommand('insertText', false, 'undo');
selection.document.execCommand('undo');
if (isWin) {
// Alt+Shift+Backspace shortcut is bound to redo on Windows only.
// Performing this on Mac will cause a one word delete.
eventSender.keyDown('Backspace', ['altKey', 'shiftKey']);
}
},
// Alt+Shift+Backspace shortcut is bound to redo on Windows only.
isWin
? '<div contenteditable>one two three fourundo|</div>'
: '<div contenteditable>one two three four|</div>',
'Alt+Shift+Backspace should be bound to redo on Windows');
</script>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment