Bug 1529466 - Make `TextInputHandler::HandleCommand()` dispatch `keydown`/`keypress` events for emulating `Tab` key when `insertTab:` or `intertBacktab:` command is received r=m_kato
authorMasayuki Nakano <masayuki@d-toybox.com>
Fri, 22 Feb 2019 13:35:55 +0000
changeset 518737 f89b6fea58479ac105a575eed55f4e4e5b41703b
parent 518736 36874ca17f849005def814927d8beb56ed2d3fba
child 518738 52e867c4246a204db6f5b50c14bc11b9e9844711
push id10862
push userffxbld-merge
push dateMon, 11 Mar 2019 13:01:11 +0000
treeherdermozilla-beta@a2e7f5c935da [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersm_kato
bugs1529466
milestone67.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1529466 - Make `TextInputHandler::HandleCommand()` dispatch `keydown`/`keypress` events for emulating `Tab` key when `insertTab:` or `intertBacktab:` command is received r=m_kato `TextInputHandler::HandleCommand()` dispatches `Tab` key events only when it receives `insertTab:` or `intertBacktab:` command which are caused by actual `Tab` key press. However, these commands could be generated by IME or the system shortcut keys are customized oddly. This patch makes the method support such situation with dispatching fake `keydown` and `keypress` events to emulate `Tab` key press for mainly focus navigation. Differential Revision: https://phabricator.services.mozilla.com/D20804
widget/cocoa/TextInputHandler.mm
--- a/widget/cocoa/TextInputHandler.mm
+++ b/widget/cocoa/TextInputHandler.mm
@@ -2637,16 +2637,26 @@ bool TextInputHandler::HandleCommand(Com
         keypressEvent.mModifiers &= ~(MODIFIER_CONTROL | MODIFIER_ALT | MODIFIER_META);
         if (aCommand == CommandInsertLineBreak) {
           // In default settings, Ctrl + Enter causes insertLineBreak command.
           // So, let's make Ctrl state active of the keypress event.
           keypressEvent.mModifiers |= MODIFIER_CONTROL;
         }
         break;
       }
+      case CommandInsertTab:
+      case CommandInsertBacktab:
+        nsCocoaUtils::InitInputEvent(keypressEvent, keyEvent);
+        keypressEvent.mKeyCode = NS_VK_TAB;
+        keypressEvent.mKeyNameIndex = KEY_NAME_INDEX_Tab;
+        keypressEvent.mModifiers &= ~(MODIFIER_CONTROL | MODIFIER_ALT | MODIFIER_META);
+        if (aCommand == CommandInsertBacktab) {
+          keypressEvent.mModifiers |= MODIFIER_SHIFT;
+        }
+        break;
       case CommandDeleteCharBackward:
       case CommandDeleteToBeginningOfLine:
       case CommandDeleteWordBackward: {
         nsCocoaUtils::InitInputEvent(keypressEvent, keyEvent);
         keypressEvent.mKeyCode = NS_VK_BACK;
         keypressEvent.mKeyNameIndex = KEY_NAME_INDEX_Backspace;
         keypressEvent.mModifiers &= ~(MODIFIER_CONTROL | MODIFIER_ALT | MODIFIER_META);
         if (aCommand == CommandDeleteToBeginningOfLine) {