Bug 1409620 Move definition of inline function from .cpp to .h in widget/windows/KeyboardLayout r?jimm
inline functions are supposed to be declared in the header file, so the compiler can inline them.
gcc complains about this, but clang/msvc apparently do not.
We also needed to move the DeadKey struct and class into the header, as the function calls a
method on the DeadKey class, and you can't do that on a forward declared class.
MozReview-Commit-ID: 8NxP59AXuZi
old mode 100644
new mode 100755
--- a/widget/windows/KeyboardLayout.cpp
+++ b/widget/windows/KeyboardLayout.cpp
@@ -652,59 +652,16 @@ ToString(const ModifierKeyState& aModifi
return result;
}
// Unique id counter associated with a keydown / keypress events. Used in
// identifing keypress events for removal from async event dispatch queue
// in metrofx after preventDefault is called on keydown events.
static uint32_t sUniqueKeyEventId = 0;
-struct DeadKeyEntry
-{
- char16_t BaseChar;
- char16_t CompositeChar;
-};
-
-
-class DeadKeyTable
-{
- friend class KeyboardLayout;
-
- uint16_t mEntries;
- // KeyboardLayout::AddDeadKeyTable() will allocate as many entries as
- // required. It is the only way to create new DeadKeyTable instances.
- DeadKeyEntry mTable[1];
-
- void Init(const DeadKeyEntry* aDeadKeyArray, uint32_t aEntries)
- {
- mEntries = aEntries;
- memcpy(mTable, aDeadKeyArray, aEntries * sizeof(DeadKeyEntry));
- }
-
- static uint32_t SizeInBytes(uint32_t aEntries)
- {
- return offsetof(DeadKeyTable, mTable) + aEntries * sizeof(DeadKeyEntry);
- }
-
-public:
- uint32_t Entries() const
- {
- return mEntries;
- }
-
- bool IsEqual(const DeadKeyEntry* aDeadKeyArray, uint32_t aEntries) const
- {
- return (mEntries == aEntries &&
- !memcmp(mTable, aDeadKeyArray,
- aEntries * sizeof(DeadKeyEntry)));
- }
-
- char16_t GetCompositeChar(char16_t aBaseChar) const;
-};
-
/*****************************************************************************
* mozilla::widget::ModifierKeyState
*****************************************************************************/
ModifierKeyState::ModifierKeyState()
{
Update();
@@ -1018,22 +975,16 @@ VirtualKey::ShiftStateToModifiers(ShiftS
}
if ((modifiers & (MODIFIER_ALT | MODIFIER_CONTROL)) ==
(MODIFIER_ALT | MODIFIER_CONTROL)) {
modifiers |= MODIFIER_ALTGRAPH;
}
return modifiers;
}
-inline char16_t
-VirtualKey::GetCompositeChar(ShiftState aShiftState, char16_t aBaseChar) const
-{
- return mShiftStates[aShiftState].DeadKey.Table->GetCompositeChar(aBaseChar);
-}
-
const DeadKeyTable*
VirtualKey::MatchingDeadKeyTable(const DeadKeyEntry* aDeadKeyArray,
uint32_t aEntries) const
{
if (!mIsDeadKey) {
return nullptr;
}
old mode 100644
new mode 100755
--- a/widget/windows/KeyboardLayout.h
+++ b/widget/windows/KeyboardLayout.h
@@ -110,19 +110,58 @@ public:
private:
nsAutoString mChars;
// 5 is enough number for normal keyboard layout handling. On Windows,
// a dead key sequence may cause inputting up to 5 characters per key press.
AutoTArray<Modifiers, 5> mModifiers;
};
-struct DeadKeyEntry;
-class DeadKeyTable;
+struct DeadKeyEntry
+{
+ char16_t BaseChar;
+ char16_t CompositeChar;
+};
+
+
+class DeadKeyTable
+{
+ friend class KeyboardLayout;
+
+ uint16_t mEntries;
+ // KeyboardLayout::AddDeadKeyTable() will allocate as many entries as
+ // required. It is the only way to create new DeadKeyTable instances.
+ DeadKeyEntry mTable[1];
+ void Init(const DeadKeyEntry* aDeadKeyArray, uint32_t aEntries)
+ {
+ mEntries = aEntries;
+ memcpy(mTable, aDeadKeyArray, aEntries * sizeof(DeadKeyEntry));
+ }
+
+ static uint32_t SizeInBytes(uint32_t aEntries)
+ {
+ return offsetof(DeadKeyTable, mTable) + aEntries * sizeof(DeadKeyEntry);
+ }
+
+public:
+ uint32_t Entries() const
+ {
+ return mEntries;
+ }
+
+ bool IsEqual(const DeadKeyEntry* aDeadKeyArray, uint32_t aEntries) const
+ {
+ return (mEntries == aEntries &&
+ !memcmp(mTable, aDeadKeyArray,
+ aEntries * sizeof(DeadKeyEntry)));
+ }
+
+ char16_t GetCompositeChar(char16_t aBaseChar) const;
+};
class VirtualKey
{
public:
// 0 - Normal
// 1 - Shift
// 2 - Control
// 3 - Control + Shift
@@ -198,17 +237,21 @@ public:
}
void SetNormalChars(ShiftState aShiftState, const char16_t* aChars,
uint32_t aNumOfChars);
void SetDeadChar(ShiftState aShiftState, char16_t aDeadChar);
const DeadKeyTable* MatchingDeadKeyTable(const DeadKeyEntry* aDeadKeyArray,
uint32_t aEntries) const;
inline char16_t GetCompositeChar(ShiftState aShiftState,
- char16_t aBaseChar) const;
+ char16_t aBaseChar) const
+ {
+ return mShiftStates[aShiftState].DeadKey.Table->GetCompositeChar(aBaseChar);
+ }
+
char16_t GetCompositeChar(const ModifierKeyState& aModKeyState,
char16_t aBaseChar) const
{
return GetCompositeChar(ModifierKeyStateToShiftState(aModKeyState),
aBaseChar);
}
UniCharsAndModifiers GetNativeUniChars(ShiftState aShiftState) const;
UniCharsAndModifiers GetNativeUniChars(