Bug 912858 part.2 Implement KeyboardEvent.key for printable keys on Windows r=jimm+smaug

This commit is contained in:
Masayuki Nakano 2013-12-11 01:14:54 +09:00
parent 63a192a317
commit fba9280344

View File

@ -947,6 +947,9 @@ NativeKey::InitKeyEvent(WidgetKeyboardEvent& aKeyEvent,
aKeyEvent.mIsRepeat = IsRepeat();
aKeyEvent.mKeyNameIndex = mKeyNameIndex;
if (mKeyNameIndex == KEY_NAME_INDEX_USE_STRING) {
aKeyEvent.mKeyValue = mCommittedCharsAndModifiers.ToString();
}
aKeyEvent.location = GetKeyLocation();
aModKeyState.InitInputEvent(aKeyEvent);
}
@ -1668,6 +1671,9 @@ KeyboardLayout::InitNativeKey(NativeKey& aNativeKey,
return;
}
MOZ_ASSERT(aNativeKey.mKeyNameIndex == KEY_NAME_INDEX_USE_STRING,
"Printable key's key name index must be KEY_NAME_INDEX_USE_STRING");
bool isKeyDown = aNativeKey.IsKeyDownMessage();
uint8_t shiftState =
VirtualKey::ModifiersToShiftState(aModKeyState.GetModifiers());
@ -2311,6 +2317,10 @@ KeyboardLayout::ConvertNativeKeyCodeToDOMKeyCode(UINT aNativeKeyCode) const
KeyNameIndex
KeyboardLayout::ConvertNativeKeyCodeToKeyNameIndex(uint8_t aVirtualKey) const
{
if (IsPrintableCharKey(aVirtualKey)) {
return KEY_NAME_INDEX_USE_STRING;
}
#define NS_NATIVE_KEY_TO_DOM_KEY_NAME_INDEX(aNativeKey, aKeyNameIndex)
#define NS_JAPANESE_NATIVE_KEY_TO_DOM_KEY_NAME_INDEX(aNativeKey, aKeyNameIndex)
#define NS_KOREAN_NATIVE_KEY_TO_DOM_KEY_NAME_INDEX(aNativeKey, aKeyNameIndex)
@ -2328,9 +2338,6 @@ KeyboardLayout::ConvertNativeKeyCodeToKeyNameIndex(uint8_t aVirtualKey) const
#define NS_NATIVE_KEY_TO_DOM_KEY_NAME_INDEX(aNativeKey, aKeyNameIndex)
default:
if (IsPrintableCharKey(aVirtualKey)) {
return KEY_NAME_INDEX_PrintableKey;
}
break;
}