зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1306549 part.4 Create KeyboardLayout::GetNativeUniCharsAndModifiers() for wrapping VirtualKey::GetNativeUniChars() r=m_kato
Similar to VirtualKey::GetUniChars(), VirtualKey::GetNativeUniChars() needs key index. So, it should be wrapped by a new helper method, KeyboardLayout::GetNativeUniCharsAndModifiers(), and KeyboardEvent::InitNativeKey() should use this instead of accessing its member's GetNativeUniChars(). MozReview-Commit-ID: 7M9OlNF698Y --HG-- extra : rebase_source : e19a5c99014a8f0a0ed7cc3a86fe0c4ee10cebb5
This commit is contained in:
Родитель
49ebeb51f0
Коммит
da22fd3b2b
|
@ -3639,11 +3639,13 @@ KeyboardLayout::InitNativeKey(NativeKey& aNativeKey,
|
|||
}
|
||||
|
||||
uint8_t virtualKey = aNativeKey.mOriginalVirtualKeyCode;
|
||||
int32_t virtualKeyIndex = GetKeyIndex(virtualKey);
|
||||
|
||||
if (virtualKeyIndex < 0) {
|
||||
// Does not produce any printable characters, but still preserves the
|
||||
// dead-key state.
|
||||
// If the key is not a usual printable key, KeyboardLayout class assume that
|
||||
// it's not cause dead char nor printable char. Therefore, there are nothing
|
||||
// to do here fore such keys (e.g., function keys).
|
||||
// However, this should keep dead key state even if non-printable key is
|
||||
// pressed during a dead key sequence.
|
||||
if (!IsPrintableCharKey(virtualKey)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -3665,7 +3667,7 @@ KeyboardLayout::InitNativeKey(NativeKey& aNativeKey,
|
|||
VirtualKey::ModifierKeyStateToShiftState(aModKeyState);
|
||||
}
|
||||
UniCharsAndModifiers deadChars =
|
||||
mVirtualKeys[virtualKeyIndex].GetNativeUniChars(aModKeyState);
|
||||
GetNativeUniCharsAndModifiers(virtualKey, aModKeyState);
|
||||
NS_ASSERTION(deadChars.mLength == 1,
|
||||
"dead key must generate only one character");
|
||||
aNativeKey.mKeyNameIndex = KEY_NAME_INDEX_Dead;
|
||||
|
@ -3800,6 +3802,20 @@ KeyboardLayout::GetUniCharsAndModifiers(
|
|||
return mVirtualKeys[key].GetUniChars(aShiftState);
|
||||
}
|
||||
|
||||
UniCharsAndModifiers
|
||||
KeyboardLayout::GetNativeUniCharsAndModifiers(
|
||||
uint8_t aVirtualKey,
|
||||
const ModifierKeyState& aModKeyState) const
|
||||
{
|
||||
int32_t key = GetKeyIndex(aVirtualKey);
|
||||
if (key < 0) {
|
||||
return UniCharsAndModifiers();
|
||||
}
|
||||
VirtualKey::ShiftState shiftState =
|
||||
VirtualKey::ModifierKeyStateToShiftState(aModKeyState);
|
||||
return mVirtualKeys[key].GetNativeUniChars(shiftState);
|
||||
}
|
||||
|
||||
void
|
||||
KeyboardLayout::LoadLayout(HKL aLayout)
|
||||
{
|
||||
|
|
|
@ -699,7 +699,7 @@ public:
|
|||
const ModifierKeyState& aModKeyState);
|
||||
|
||||
/**
|
||||
* GetUniCharsAndModifiers() returns characters which is inputted by the
|
||||
* GetUniCharsAndModifiers() returns characters which are inputted by
|
||||
* aVirtualKey with aModKeyState. This method isn't stateful.
|
||||
* Note that if the combination causes text input, the result's Ctrl and
|
||||
* Alt key state are never active.
|
||||
|
@ -713,6 +713,16 @@ public:
|
|||
return GetUniCharsAndModifiers(aVirtualKey, shiftState);
|
||||
}
|
||||
|
||||
/**
|
||||
* GetNativeUniCharsAndModifiers() returns characters which are inputted by
|
||||
* aVirtualKey with aModKeyState. The method isn't stateful.
|
||||
* Note that different from GetUniCharsAndModifiers(), this returns
|
||||
* actual modifier state of Ctrl and Alt.
|
||||
*/
|
||||
UniCharsAndModifiers GetNativeUniCharsAndModifiers(
|
||||
uint8_t aVirtualKey,
|
||||
const ModifierKeyState& aModKeyState) const;
|
||||
|
||||
/**
|
||||
* OnLayoutChange() must be called before the first keydown message is
|
||||
* received. LoadLayout() changes the keyboard state, that causes breaking
|
||||
|
|
Загрузка…
Ссылка в новой задаче