Bug 1587557: When activating an HTML text field via a11y APIs, if it already has focus, simulate a click. r=MarcoZ

Previously, HTMLTextFieldAccessible::DoAction just called TakeFocus().
When the field already has focus, TakeFocus() will do nothing.
However, the user might be activating this element because they dismissed a touch keyboard and want to bring it back.
Therefore, we must simulate a click so Gecko will bring up the keyboard.

Differential Revision: https://phabricator.services.mozilla.com/D54106

--HG--
extra : moz-landing-system : lando
This commit is contained in:
James Teh 2019-11-21 10:42:36 +00:00
Родитель aabcbaf2bd
Коммит a984f604fe
1 изменённых файлов: 8 добавлений и 1 удалений

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

@ -373,7 +373,14 @@ void HTMLTextFieldAccessible::ActionNameAt(uint8_t aIndex, nsAString& aName) {
bool HTMLTextFieldAccessible::DoAction(uint8_t aIndex) const {
if (aIndex != 0) return false;
TakeFocus();
if (FocusMgr()->IsFocused(this)) {
// This already has focus, so TakeFocus()will do nothing. However, the user
// might be activating this element because they dismissed a touch keyboard
// and want to bring it back.
DoCommand();
} else {
TakeFocus();
}
return true;
}