Bug 1314251, close menulist on alt+up/down, r=ksteuber

This commit is contained in:
Neil Deakin 2016-11-17 09:56:43 -05:00
Родитель 74aa0c0079
Коммит 18dc1a098a
2 изменённых файлов: 21 добавлений и 8 удалений

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

@ -2340,10 +2340,21 @@ nsXULPopupManager::HandleKeyboardEventWithKeyCode(
bool consume = (mPopups || mActiveMenuBar);
switch (keyCode) {
case nsIDOMKeyEvent::DOM_VK_LEFT:
case nsIDOMKeyEvent::DOM_VK_RIGHT:
case nsIDOMKeyEvent::DOM_VK_UP:
case nsIDOMKeyEvent::DOM_VK_DOWN:
#ifndef XP_MACOSX
// roll up the popup when alt+up/down are pressed within a menulist.
bool alt;
aKeyEvent->GetAltKey(&alt);
if (alt && aTopVisibleMenuItem && aTopVisibleMenuItem->Frame()->IsMenuList()) {
Rollup(0, false, nullptr, nullptr);
break;
}
MOZ_FALLTHROUGH;
#endif
case nsIDOMKeyEvent::DOM_VK_LEFT:
case nsIDOMKeyEvent::DOM_VK_RIGHT:
case nsIDOMKeyEvent::DOM_VK_HOME:
case nsIDOMKeyEvent::DOM_VK_END:
HandleKeyboardNavigation(keyCode);

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

@ -20,7 +20,7 @@
</menulist>
<button id="button2" label="Two"/>
<menulist id="list2">
<menupopup id="popup" onpopupshown="checkCursorNavigation();" onpopuphidden="done()">
<menupopup id="popup" onpopupshown="checkCursorNavigation();">
<menuitem id="b1" label="One"/>
<menuitem id="b2" label="Two" selected="true"/>
<menuitem id="b3" label="Three"/>
@ -230,7 +230,7 @@ function verifyPopupOnClose()
is(gModifiers, 2, "modifiers checked when set");
ok(!list.open, "list closed on enter press with modifiers");
list.removeEventListener("popuphidden", done, false);
list.removeEventListener("popuphidden", verifyPopupOnClose, false);
list = $("list2");
list.focus();
@ -268,11 +268,13 @@ function checkCursorNavigation()
is(list.menuBoxObject.activeChild,
document.getElementById(iswin || ismac ? "b4" : "b1"), "cursor down wrap while open");
list.open = false;
}
synthesizeKey("VK_UP", { altKey: true });
is(list.open, ismac, "alt+up closes popup");
if (ismac) {
list.open = false;
}
function done()
{
SimpleTest.finish();
}