Bug 1306549 part.1 KeyboardLayout::InitNativeKey() should use KeyboardLayout::IsDeadKey() r=m_kato

KeyboardLayout::InitNativeKey() is very messy because it handles a lot of cases without helper methods.

It's important to make it simpler implementation for preventing regressions caused by some patches which are written with misunderstanding.  So, let's rewrite the method with helper method.

First, this patch make InitNativeKey() use IsDeadKey() instead of referring the table because calling IsDeadKey() is easier to understand.

MozReview-Commit-ID: DtN9qoh7Gz7

--HG--
extra : rebase_source : 8e769c1c88bfe646940491c111de609dbf53eeec
This commit is contained in:
Masayuki Nakano 2016-09-16 17:24:39 +09:00
Родитель 69fd7610fa
Коммит af0de6d7e8
1 изменённых файлов: 4 добавлений и 1 удалений

Просмотреть файл

@ -3577,6 +3577,9 @@ KeyboardLayout::IsDeadKey(uint8_t aVirtualKey,
const ModifierKeyState& aModKeyState) const
{
int32_t virtualKeyIndex = GetKeyIndex(aVirtualKey);
// XXX KeyboardLayout class doesn't support unusual keyboard layout which
// maps some function keys as dead keys.
if (virtualKeyIndex < 0) {
return false;
}
@ -3653,7 +3656,7 @@ KeyboardLayout::InitNativeKey(NativeKey& aNativeKey,
uint8_t shiftState =
VirtualKey::ModifiersToShiftState(aModKeyState.GetModifiers());
if (mVirtualKeys[virtualKeyIndex].IsDeadKey(shiftState)) {
if (IsDeadKey(virtualKey, aModKeyState)) {
if ((isKeyDown && mActiveDeadKey < 0) ||
(!isKeyDown && mActiveDeadKey == virtualKey)) {
// First dead key event doesn't generate characters.