Bug 1009388 part.2 Accessible should use WidgetEvent::AccelModifier() for consistency with other modules r=smaug+surkov.alexander

This commit is contained in:
Masayuki Nakano 2014-05-22 13:06:05 +09:00
parent 442e0f0f31
commit 066f82fb48
3 changed files with 23 additions and 25 deletions

View File

@ -76,6 +76,7 @@
#endif #endif
#include "mozilla/Assertions.h" #include "mozilla/Assertions.h"
#include "mozilla/BasicEvents.h"
#include "mozilla/EventStates.h" #include "mozilla/EventStates.h"
#include "mozilla/FloatingPoint.h" #include "mozilla/FloatingPoint.h"
#include "mozilla/MouseEvents.h" #include "mozilla/MouseEvents.h"
@ -3264,6 +3265,25 @@ Accessible::StaticAsserts() const
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// KeyBinding class // KeyBinding class
// static
uint32_t
KeyBinding::AccelModifier()
{
switch (WidgetInputEvent::AccelModifier()) {
case MODIFIER_ALT:
return kAlt;
case MODIFIER_CONTROL:
return kControl;
case MODIFIER_META:
return kMeta;
case MODIFIER_OS:
return kOS;
default:
MOZ_CRASH("Handle the new result of WidgetInputEvent::AccelModifier()");
return 0;
}
}
void void
KeyBinding::ToPlatformFormat(nsAString& aValue) const KeyBinding::ToPlatformFormat(nsAString& aValue) const
{ {

View File

@ -1066,6 +1066,8 @@ public:
static const uint32_t kMeta = 8; static const uint32_t kMeta = 8;
static const uint32_t kOS = 16; static const uint32_t kOS = 16;
static uint32_t AccelModifier();
KeyBinding() : mKey(0), mModifierMask(0) {} KeyBinding() : mKey(0), mModifierMask(0) {}
KeyBinding(uint32_t aKey, uint32_t aModifierMask) : KeyBinding(uint32_t aKey, uint32_t aModifierMask) :
mKey(aKey), mModifierMask(aModifierMask) {} mKey(aKey), mModifierMask(aModifierMask) {}

View File

@ -233,31 +233,7 @@ XULMenuitemAccessible::KeyboardShortcut() const
if (modifiersStr.Find("control") != -1) if (modifiersStr.Find("control") != -1)
modifierMask |= KeyBinding::kControl; modifierMask |= KeyBinding::kControl;
if (modifiersStr.Find("accel") != -1) { if (modifiersStr.Find("accel") != -1) {
// Get the accelerator key value from prefs, overriding the default. modifierMask |= KeyBinding::AccelModifier();
switch (Preferences::GetInt("ui.key.accelKey", 0)) {
case nsIDOMKeyEvent::DOM_VK_META:
modifierMask |= KeyBinding::kMeta;
break;
case nsIDOMKeyEvent::DOM_VK_WIN:
modifierMask |= KeyBinding::kOS;
break;
case nsIDOMKeyEvent::DOM_VK_ALT:
modifierMask |= KeyBinding::kAlt;
break;
case nsIDOMKeyEvent::DOM_VK_CONTROL:
modifierMask |= KeyBinding::kControl;
break;
default:
#ifdef XP_MACOSX
modifierMask |= KeyBinding::kMeta;
#else
modifierMask |= KeyBinding::kControl;
#endif
}
} }
return KeyBinding(key, modifierMask); return KeyBinding(key, modifierMask);