Bug 1272012 - Support more keys to open and/or toggle a combobox dropdown menu. r=enndeakin

Up/Down should open the dropdown menu on OSX, but not close it.
Spacebar should toggle the dropdown on OSX, but only if Alt, Ctrl or
Cmd isn't pressed.
Spacebar should open the dropdown on non-OSX platforms, but not close
it, with or without key modifiers.
This commit is contained in:
Mats Palmgren 2016-05-25 10:48:52 +02:00
Родитель a41e908395
Коммит 2b1544d87c
1 изменённых файлов: 18 добавлений и 3 удалений

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

@ -2108,10 +2108,25 @@ nsListControlFrame::KeyDown(nsIDOMEvent* aKeyEvent)
MOZ_ASSERT(keyEvent,
"DOM event must have WidgetKeyboardEvent for its internal event");
if (keyEvent->IsAlt()) {
if (keyEvent->mKeyCode == NS_VK_UP || keyEvent->mKeyCode == NS_VK_DOWN) {
bool dropDownMenuOnUpDown;
bool dropDownMenuOnSpace;
#ifdef XP_MACOSX
dropDownMenuOnUpDown = IsInDropDownMode() && !mComboboxFrame->IsDroppedDown();
dropDownMenuOnSpace = !keyEvent->IsAlt() && !keyEvent->IsControl() &&
!keyEvent->IsMeta();
#else
dropDownMenuOnUpDown = keyEvent->IsAlt();
dropDownMenuOnSpace = IsInDropDownMode() && !mComboboxFrame->IsDroppedDown();
#endif
if ((dropDownMenuOnUpDown &&
(keyEvent->mKeyCode == NS_VK_UP || keyEvent->mKeyCode == NS_VK_DOWN)) ||
(dropDownMenuOnSpace && keyEvent->mKeyCode == NS_VK_SPACE)) {
DropDownToggleKey(aKeyEvent);
if (keyEvent->DefaultPrevented()) {
return NS_OK;
}
}
if (keyEvent->IsAlt()) {
return NS_OK;
}