mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-27 06:43:32 +00:00
Bug 1337739 Create an enum eKeyLocation* for avoiding to use nsIDOMKeyEvent::DOM_KEY_LOCATION_* r=smaug
Currently, we use alias NS_VK_* for WidgetKeyboardEvent::mKeyCode. Similarly, we should create alias enum for nsIDOMKeyEvent::DOM_KEY_LOCATION_*. Then, we can reduce the length and avoid to include nsIDOMKeyEvent in some cpp files. MozReview-Commit-ID: 5cs4zQ061Lc --HG-- extra : rebase_source : e6a6edd27718b9e3d4a40b07902d029791876999
This commit is contained in:
parent
30d9ef4d29
commit
5442d350f3
@ -8206,16 +8206,16 @@ nsContentUtils::SendKeyEvent(nsIWidget* aWidget,
|
||||
nsIDOMWindowUtils::KEY_FLAG_LOCATION_RIGHT | nsIDOMWindowUtils::KEY_FLAG_LOCATION_NUMPAD));
|
||||
switch (locationFlag) {
|
||||
case nsIDOMWindowUtils::KEY_FLAG_LOCATION_STANDARD:
|
||||
event.mLocation = nsIDOMKeyEvent::DOM_KEY_LOCATION_STANDARD;
|
||||
event.mLocation = eKeyLocationStandard;
|
||||
break;
|
||||
case nsIDOMWindowUtils::KEY_FLAG_LOCATION_LEFT:
|
||||
event.mLocation = nsIDOMKeyEvent::DOM_KEY_LOCATION_LEFT;
|
||||
event.mLocation = eKeyLocationLeft;
|
||||
break;
|
||||
case nsIDOMWindowUtils::KEY_FLAG_LOCATION_RIGHT:
|
||||
event.mLocation = nsIDOMKeyEvent::DOM_KEY_LOCATION_RIGHT;
|
||||
event.mLocation = eKeyLocationRight;
|
||||
break;
|
||||
case nsIDOMWindowUtils::KEY_FLAG_LOCATION_NUMPAD:
|
||||
event.mLocation = nsIDOMKeyEvent::DOM_KEY_LOCATION_NUMPAD;
|
||||
event.mLocation = eKeyLocationNumpad;
|
||||
break;
|
||||
default:
|
||||
if (locationFlag != 0) {
|
||||
@ -8239,16 +8239,16 @@ nsContentUtils::SendKeyEvent(nsIWidget* aWidget,
|
||||
case nsIDOMKeyEvent::DOM_VK_SUBTRACT:
|
||||
case nsIDOMKeyEvent::DOM_VK_DECIMAL:
|
||||
case nsIDOMKeyEvent::DOM_VK_DIVIDE:
|
||||
event.mLocation = nsIDOMKeyEvent::DOM_KEY_LOCATION_NUMPAD;
|
||||
event.mLocation = eKeyLocationNumpad;
|
||||
break;
|
||||
case nsIDOMKeyEvent::DOM_VK_SHIFT:
|
||||
case nsIDOMKeyEvent::DOM_VK_CONTROL:
|
||||
case nsIDOMKeyEvent::DOM_VK_ALT:
|
||||
case nsIDOMKeyEvent::DOM_VK_META:
|
||||
event.mLocation = nsIDOMKeyEvent::DOM_KEY_LOCATION_LEFT;
|
||||
event.mLocation = eKeyLocationLeft;
|
||||
break;
|
||||
default:
|
||||
event.mLocation = nsIDOMKeyEvent::DOM_KEY_LOCATION_STANDARD;
|
||||
event.mLocation = eKeyLocationStandard;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
@ -519,13 +519,15 @@ bool IsCtrlShiftPressed(nsIDOMKeyEvent* aEvent, bool& isRTL)
|
||||
return false;
|
||||
}
|
||||
|
||||
uint32_t location = keyboardEvent->mLocation;
|
||||
if (location == nsIDOMKeyEvent::DOM_KEY_LOCATION_RIGHT) {
|
||||
isRTL = true;
|
||||
} else if (location == nsIDOMKeyEvent::DOM_KEY_LOCATION_LEFT) {
|
||||
isRTL = false;
|
||||
} else {
|
||||
return false;
|
||||
switch (keyboardEvent->mLocation) {
|
||||
case eKeyLocationRight:
|
||||
isRTL = true;
|
||||
break;
|
||||
case eKeyLocationLeft:
|
||||
isRTL = false;
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
||||
// Scan the key status to find pressed keys. We should abandon changing the
|
||||
|
@ -41,6 +41,14 @@ enum
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
enum : uint32_t
|
||||
{
|
||||
eKeyLocationStandard = nsIDOMKeyEvent::DOM_KEY_LOCATION_STANDARD,
|
||||
eKeyLocationLeft = nsIDOMKeyEvent::DOM_KEY_LOCATION_LEFT,
|
||||
eKeyLocationRight = nsIDOMKeyEvent::DOM_KEY_LOCATION_RIGHT,
|
||||
eKeyLocationNumpad = nsIDOMKeyEvent::DOM_KEY_LOCATION_NUMPAD
|
||||
};
|
||||
|
||||
const nsCString GetDOMKeyCodeName(uint32_t aKeyCode);
|
||||
|
||||
namespace dom {
|
||||
@ -108,14 +116,14 @@ protected:
|
||||
, mKeyCode(0)
|
||||
, mCharCode(0)
|
||||
, mPseudoCharCode(0)
|
||||
, mLocation(nsIDOMKeyEvent::DOM_KEY_LOCATION_STANDARD)
|
||||
, mLocation(eKeyLocationStandard)
|
||||
, mAccessKeyForwardedToChild(false)
|
||||
, mUniqueId(0)
|
||||
#ifdef XP_MACOSX
|
||||
, mNativeModifierFlags(0)
|
||||
, mNativeKeyCode(0)
|
||||
#endif // #ifdef XP_MACOSX
|
||||
, mKeyNameIndex(mozilla::KEY_NAME_INDEX_Unidentified)
|
||||
, mKeyNameIndex(KEY_NAME_INDEX_Unidentified)
|
||||
, mCodeNameIndex(CODE_NAME_INDEX_UNKNOWN)
|
||||
, mInputMethodAppState(eNotHandled)
|
||||
, mIsChar(false)
|
||||
@ -137,14 +145,14 @@ public:
|
||||
, mKeyCode(0)
|
||||
, mCharCode(0)
|
||||
, mPseudoCharCode(0)
|
||||
, mLocation(nsIDOMKeyEvent::DOM_KEY_LOCATION_STANDARD)
|
||||
, mLocation(eKeyLocationStandard)
|
||||
, mAccessKeyForwardedToChild(false)
|
||||
, mUniqueId(0)
|
||||
#ifdef XP_MACOSX
|
||||
, mNativeModifierFlags(0)
|
||||
, mNativeKeyCode(0)
|
||||
#endif // #ifdef XP_MACOSX
|
||||
, mKeyNameIndex(mozilla::KEY_NAME_INDEX_Unidentified)
|
||||
, mKeyNameIndex(KEY_NAME_INDEX_Unidentified)
|
||||
, mCodeNameIndex(CODE_NAME_INDEX_UNKNOWN)
|
||||
, mInputMethodAppState(eNotHandled)
|
||||
, mIsChar(false)
|
||||
@ -227,7 +235,7 @@ public:
|
||||
// This stores mCharCode value of keypress event which is fired with same
|
||||
// key value and same modifier state.
|
||||
uint32_t mPseudoCharCode;
|
||||
// One of nsIDOMKeyEvent::DOM_KEY_LOCATION_*
|
||||
// One of eKeyLocation*
|
||||
uint32_t mLocation;
|
||||
// True if accesskey handling was forwarded to the child via
|
||||
// TabParent::HandleAccessKey. In this case, parent process menu access key
|
||||
@ -340,8 +348,8 @@ public:
|
||||
|
||||
/**
|
||||
* ComputeLocationFromCodeValue() returns one of .mLocation value
|
||||
* (nsIDOMKeyEvent::DOM_KEY_LOCATION_*) which is the most preferred value
|
||||
* for the specified specified code value.
|
||||
* (eKeyLocation*) which is the most preferred value for the specified code
|
||||
* value.
|
||||
*/
|
||||
static uint32_t ComputeLocationFromCodeValue(CodeNameIndex aCodeNameIndex);
|
||||
|
||||
|
@ -895,12 +895,12 @@ WidgetKeyboardEvent::ComputeLocationFromCodeValue(CodeNameIndex aCodeNameIndex)
|
||||
case CODE_NAME_INDEX_ControlLeft:
|
||||
case CODE_NAME_INDEX_OSLeft:
|
||||
case CODE_NAME_INDEX_ShiftLeft:
|
||||
return nsIDOMKeyEvent::DOM_KEY_LOCATION_LEFT;
|
||||
return eKeyLocationLeft;
|
||||
case CODE_NAME_INDEX_AltRight:
|
||||
case CODE_NAME_INDEX_ControlRight:
|
||||
case CODE_NAME_INDEX_OSRight:
|
||||
case CODE_NAME_INDEX_ShiftRight:
|
||||
return nsIDOMKeyEvent::DOM_KEY_LOCATION_RIGHT;
|
||||
return eKeyLocationRight;
|
||||
case CODE_NAME_INDEX_Numpad0:
|
||||
case CODE_NAME_INDEX_Numpad1:
|
||||
case CODE_NAME_INDEX_Numpad2:
|
||||
@ -929,9 +929,9 @@ WidgetKeyboardEvent::ComputeLocationFromCodeValue(CodeNameIndex aCodeNameIndex)
|
||||
case CODE_NAME_INDEX_NumpadParenLeft:
|
||||
case CODE_NAME_INDEX_NumpadParenRight:
|
||||
case CODE_NAME_INDEX_NumpadSubtract:
|
||||
return nsIDOMKeyEvent::DOM_KEY_LOCATION_NUMPAD;
|
||||
return eKeyLocationNumpad;
|
||||
default:
|
||||
return nsIDOMKeyEvent::DOM_KEY_LOCATION_STANDARD;
|
||||
return eKeyLocationStandard;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -911,14 +911,14 @@ TISInputSourceWrapper::InitKeyEvent(NSEvent *aNativeKeyEvent,
|
||||
case kVK_Shift:
|
||||
case kVK_Option:
|
||||
case kVK_Control:
|
||||
aKeyEvent.mLocation = nsIDOMKeyEvent::DOM_KEY_LOCATION_LEFT;
|
||||
aKeyEvent.mLocation = eKeyLocationLeft;
|
||||
break;
|
||||
|
||||
case kVK_RightCommand:
|
||||
case kVK_RightShift:
|
||||
case kVK_RightOption:
|
||||
case kVK_RightControl:
|
||||
aKeyEvent.mLocation = nsIDOMKeyEvent::DOM_KEY_LOCATION_RIGHT;
|
||||
aKeyEvent.mLocation = eKeyLocationRight;
|
||||
break;
|
||||
|
||||
case kVK_ANSI_Keypad0:
|
||||
@ -940,11 +940,11 @@ TISInputSourceWrapper::InitKeyEvent(NSEvent *aNativeKeyEvent,
|
||||
case kVK_ANSI_KeypadEnter:
|
||||
case kVK_JIS_KeypadComma:
|
||||
case kVK_Powerbook_KeypadEnter:
|
||||
aKeyEvent.mLocation = nsIDOMKeyEvent::DOM_KEY_LOCATION_NUMPAD;
|
||||
aKeyEvent.mLocation = eKeyLocationNumpad;
|
||||
break;
|
||||
|
||||
default:
|
||||
aKeyEvent.mLocation = nsIDOMKeyEvent::DOM_KEY_LOCATION_STANDARD;
|
||||
aKeyEvent.mLocation = eKeyLocationStandard;
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -946,7 +946,7 @@ KeymapWrapper::InitKeyEvent(WidgetKeyboardEvent& aKeyEvent,
|
||||
case GDK_Super_L:
|
||||
case GDK_Hyper_L:
|
||||
case GDK_Meta_L:
|
||||
aKeyEvent.mLocation = nsIDOMKeyEvent::DOM_KEY_LOCATION_LEFT;
|
||||
aKeyEvent.mLocation = eKeyLocationLeft;
|
||||
break;
|
||||
|
||||
case GDK_Shift_R:
|
||||
@ -955,7 +955,7 @@ KeymapWrapper::InitKeyEvent(WidgetKeyboardEvent& aKeyEvent,
|
||||
case GDK_Super_R:
|
||||
case GDK_Hyper_R:
|
||||
case GDK_Meta_R:
|
||||
aKeyEvent.mLocation = nsIDOMKeyEvent::DOM_KEY_LOCATION_RIGHT;
|
||||
aKeyEvent.mLocation = eKeyLocationRight;
|
||||
break;
|
||||
|
||||
case GDK_KP_0:
|
||||
@ -993,11 +993,11 @@ KeymapWrapper::InitKeyEvent(WidgetKeyboardEvent& aKeyEvent,
|
||||
case GDK_KP_Subtract:
|
||||
case GDK_KP_Decimal:
|
||||
case GDK_KP_Divide:
|
||||
aKeyEvent.mLocation = nsIDOMKeyEvent::DOM_KEY_LOCATION_NUMPAD;
|
||||
aKeyEvent.mLocation = eKeyLocationNumpad;
|
||||
break;
|
||||
|
||||
default:
|
||||
aKeyEvent.mLocation = nsIDOMKeyEvent::DOM_KEY_LOCATION_STANDARD;
|
||||
aKeyEvent.mLocation = eKeyLocationStandard;
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -17,7 +17,6 @@
|
||||
#include "nsExceptionHandler.h"
|
||||
#endif
|
||||
#include "nsGkAtoms.h"
|
||||
#include "nsIDOMKeyEvent.h"
|
||||
#include "nsIIdleServiceInternal.h"
|
||||
#include "nsIWindowsRegKey.h"
|
||||
#include "nsMemory.h"
|
||||
@ -255,13 +254,13 @@ static const nsCString
|
||||
GetKeyLocationName(uint32_t aLocation)
|
||||
{
|
||||
switch (aLocation) {
|
||||
case nsIDOMKeyEvent::DOM_KEY_LOCATION_LEFT:
|
||||
case eKeyLocationLeft:
|
||||
return NS_LITERAL_CSTRING("KEY_LOCATION_LEFT");
|
||||
case nsIDOMKeyEvent::DOM_KEY_LOCATION_RIGHT:
|
||||
case eKeyLocationRight:
|
||||
return NS_LITERAL_CSTRING("KEY_LOCATION_RIGHT");
|
||||
case nsIDOMKeyEvent::DOM_KEY_LOCATION_STANDARD:
|
||||
case eKeyLocationStandard:
|
||||
return NS_LITERAL_CSTRING("KEY_LOCATION_STANDARD");
|
||||
case nsIDOMKeyEvent::DOM_KEY_LOCATION_NUMPAD:
|
||||
case eKeyLocationNumpad:
|
||||
return NS_LITERAL_CSTRING("KEY_LOCATION_NUMPAD");
|
||||
default:
|
||||
return nsPrintfCString("Unknown (0x%04X)", aLocation);
|
||||
@ -1777,18 +1776,17 @@ NativeKey::GetKeyLocation() const
|
||||
case VK_LCONTROL:
|
||||
case VK_LMENU:
|
||||
case VK_LWIN:
|
||||
return nsIDOMKeyEvent::DOM_KEY_LOCATION_LEFT;
|
||||
return eKeyLocationLeft;
|
||||
|
||||
case VK_RSHIFT:
|
||||
case VK_RCONTROL:
|
||||
case VK_RMENU:
|
||||
case VK_RWIN:
|
||||
return nsIDOMKeyEvent::DOM_KEY_LOCATION_RIGHT;
|
||||
return eKeyLocationRight;
|
||||
|
||||
case VK_RETURN:
|
||||
// XXX This code assumes that all keyboard drivers use same mapping.
|
||||
return !mIsExtended ? nsIDOMKeyEvent::DOM_KEY_LOCATION_STANDARD :
|
||||
nsIDOMKeyEvent::DOM_KEY_LOCATION_NUMPAD;
|
||||
return !mIsExtended ? eKeyLocationStandard : eKeyLocationNumpad;
|
||||
|
||||
case VK_INSERT:
|
||||
case VK_DELETE:
|
||||
@ -1802,8 +1800,7 @@ NativeKey::GetKeyLocation() const
|
||||
case VK_UP:
|
||||
case VK_PRIOR:
|
||||
// XXX This code assumes that all keyboard drivers use same mapping.
|
||||
return mIsExtended ? nsIDOMKeyEvent::DOM_KEY_LOCATION_STANDARD :
|
||||
nsIDOMKeyEvent::DOM_KEY_LOCATION_NUMPAD;
|
||||
return mIsExtended ? eKeyLocationStandard : eKeyLocationNumpad;
|
||||
|
||||
// NumLock key isn't included due to IE9's behavior.
|
||||
case VK_NUMPAD0:
|
||||
@ -1823,7 +1820,7 @@ NativeKey::GetKeyLocation() const
|
||||
case VK_ADD:
|
||||
// Separator key of Brazilian keyboard or JIS keyboard for Mac
|
||||
case VK_ABNT_C2:
|
||||
return nsIDOMKeyEvent::DOM_KEY_LOCATION_NUMPAD;
|
||||
return eKeyLocationNumpad;
|
||||
|
||||
case VK_SHIFT:
|
||||
case VK_CONTROL:
|
||||
@ -1831,7 +1828,7 @@ NativeKey::GetKeyLocation() const
|
||||
NS_WARNING("Failed to decide the key location?");
|
||||
|
||||
default:
|
||||
return nsIDOMKeyEvent::DOM_KEY_LOCATION_STANDARD;
|
||||
return eKeyLocationStandard;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -452,7 +452,7 @@ private:
|
||||
|
||||
UINT GetScanCodeWithExtendedFlag() const;
|
||||
|
||||
// The result is one of nsIDOMKeyEvent::DOM_KEY_LOCATION_*.
|
||||
// The result is one of eKeyLocation*.
|
||||
uint32_t GetKeyLocation() const;
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user