KeyBinding XULMenuitemAccessible::AccessKey() const { // Return menu accesskey: N or Alt+F. static int32_t gMenuAccesskeyModifier = -1; // magic value of -1 indicates unitialized state // We do not use nsCoreUtils::GetAccesskeyFor() because accesskeys for // menu are't registered by EventStateManager. nsAutoString accesskey; mContent->AsElement()->GetAttr(kNameSpaceID_None, nsGkAtoms::accesskey, accesskey); if (accesskey.IsEmpty()) return KeyBinding(); uint32_t modifierKey = 0; Accessible* parentAcc = Parent(); if (parentAcc) { if (parentAcc->NativeRole() == roles::MENUBAR) { // If top level menu item, add Alt+ or whatever modifier text to string // No need to cache pref service, this happens rarely if (gMenuAccesskeyModifier == -1) { // Need to initialize cached global accesskey pref gMenuAccesskeyModifier = Preferences::GetInt("ui.key.menuAccessKey", 0); } switch (gMenuAccesskeyModifier) { case dom::KeyboardEvent_Binding::DOM_VK_CONTROL: modifierKey = KeyBinding::kControl; break; case dom::KeyboardEvent_Binding::DOM_VK_ALT: modifierKey = KeyBinding::kAlt; break; case dom::KeyboardEvent_Binding::DOM_VK_META: modifierKey = KeyBinding::kMeta; break; case dom::KeyboardEvent_Binding::DOM_VK_WIN: modifierKey = KeyBinding::kOS; break; } } } return KeyBinding(accesskey[0], modifierKey); }