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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Masayuki Nakano 2019-02-22 13:35:55 +00:00
Родитель da3a46f861
Коммит 249269b4ff
1 изменённых файлов: 10 добавлений и 0 удалений

Просмотреть файл

@ -2642,6 +2642,16 @@ bool TextInputHandler::HandleCommand(Command aCommand) {
}
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: {