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

This commit is contained in:
Mats Palmgren 2016-05-25 21:52:36 +02:00
parent 9d77d9f4ce
commit 551e9fc180

View File

@ -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) {
DropDownToggleKey(aKeyEvent);
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;
}