Bug 1272012 - Support more keys to open and/or toggle a combobox dropdown menu. r=enndeakin
☠☠ backed out by 5c66fb81be68 ☠ ☠
authorMats Palmgren <mats@mozilla.com>
Wed, 25 May 2016 10:48:52 +0200
changeset 337974 e24bac891d7d00c4a71cec12e152b65eb95349af
parent 337973 e2f558143b0b39cec662497990322b4968494900
child 337975 5e25db36b720b695da94b2bc1373ea369408e404
push id6249
push userjlund@mozilla.com
push dateMon, 01 Aug 2016 13:59:36 +0000
treeherdermozilla-beta@bad9d4f5bf7e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersenndeakin
bugs1272012
milestone49.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
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.
layout/forms/nsListControlFrame.cpp
--- a/layout/forms/nsListControlFrame.cpp
+++ b/layout/forms/nsListControlFrame.cpp
@@ -2103,20 +2103,35 @@ nsListControlFrame::KeyDown(nsIDOMEvent*
   // XXXmats keyboard events, even tabbing, when preventDefault() is called
   // XXXmats in onkeydown. That seems sub-optimal though.
 
   const WidgetKeyboardEvent* keyEvent =
     aKeyEvent->WidgetEventPtr()->AsKeyboardEvent();
   MOZ_ASSERT(keyEvent,
     "DOM event must have WidgetKeyboardEvent for its internal event");
 
+  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()) {
-    if (keyEvent->mKeyCode == NS_VK_UP || keyEvent->mKeyCode == NS_VK_DOWN) {
-      DropDownToggleKey(aKeyEvent);
-    }
     return NS_OK;
   }
 
   // now make sure there are options or we are wasting our time
   RefPtr<dom::HTMLOptionsCollection> options = GetOptions();
   NS_ENSURE_TRUE(options, NS_ERROR_FAILURE);
 
   uint32_t numOptions = options->Length();