Bug 1306549 part.10 Reorder member declaration of KeyboardLayout class r=m_kato
authorMasayuki Nakano <masayuki@d-toybox.com>
Tue, 04 Oct 2016 16:37:07 +0900
changeset 316367 0bf2bbd0c300ade6567d0381481fd44b03960233
parent 316366 be15fd5862d35175c6d70db7a1e2e924aa4d05f3
child 316368 b3947e0eeeb838daf9b1c9d809113aaa49bcfc25
push id30770
push userkwierso@gmail.com
push dateWed, 05 Oct 2016 00:00:48 +0000
treeherdermozilla-central@3470e326025c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersm_kato
bugs1306549
milestone52.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1306549 part.10 Reorder member declaration of KeyboardLayout class r=m_kato We usually declare class members with following order: 1. public members 2. private members 3. friends However, current KeyboardLayout is declared with completely opposite order. Let's use usual order for preventing mistakes. MozReview-Commit-ID: LwOcEUbJzes
widget/windows/KeyboardLayout.h
--- a/widget/windows/KeyboardLayout.h
+++ b/widget/windows/KeyboardLayout.h
@@ -599,118 +599,16 @@ private:
   bool IsAnotherInstanceRemovingCharMessage() const
   {
     return mLastInstance && !IsEmptyMSG(mLastInstance->mRemovingMsg);
   }
 };
 
 class KeyboardLayout
 {
-  friend class NativeKey;
-
-private:
-  KeyboardLayout();
-  ~KeyboardLayout();
-
-  static KeyboardLayout* sInstance;
-  static nsIIdleServiceInternal* sIdleService;
-
-  struct DeadKeyTableListEntry
-  {
-    DeadKeyTableListEntry* next;
-    uint8_t data[1];
-  };
-
-  HKL mKeyboardLayout;
-
-  VirtualKey mVirtualKeys[NS_NUM_OF_KEYS];
-  DeadKeyTableListEntry* mDeadKeyTableListHead;
-  int32_t mActiveDeadKey;                 // -1 = no active dead-key
-  VirtualKey::ShiftState mDeadKeyShiftState;
-
-  bool mIsOverridden : 1;
-  bool mIsPendingToRestoreKeyboardLayout : 1;
-
-  static inline int32_t GetKeyIndex(uint8_t aVirtualKey);
-  static int CompareDeadKeyEntries(const void* aArg1, const void* aArg2,
-                                   void* aData);
-  static bool AddDeadKeyEntry(char16_t aBaseChar, char16_t aCompositeChar,
-                                DeadKeyEntry* aDeadKeyArray, uint32_t aEntries);
-  bool EnsureDeadKeyActive(bool aIsActive, uint8_t aDeadKey,
-                             const PBYTE aDeadKeyKbdState);
-  uint32_t GetDeadKeyCombinations(uint8_t aDeadKey,
-                                  const PBYTE aDeadKeyKbdState,
-                                  uint16_t aShiftStatesWithBaseChars,
-                                  DeadKeyEntry* aDeadKeyArray,
-                                  uint32_t aMaxEntries);
-  /**
-   * Activates or deactivates dead key state.
-   */
-  void ActivateDeadKeyState(const NativeKey& aNativeKey,
-                            const ModifierKeyState& aModKeyState);
-  void DeactivateDeadKeyState();
-
-  const DeadKeyTable* AddDeadKeyTable(const DeadKeyEntry* aDeadKeyArray,
-                                      uint32_t aEntries);
-  void ReleaseDeadKeyTables();
-
-  /**
-   * Loads the specified keyboard layout. This method always clear the dead key
-   * state.
-   */
-  void LoadLayout(HKL aLayout);
-
-  /**
-   * InitNativeKey() must be called when actually widget receives WM_KEYDOWN or
-   * WM_KEYUP.  This method is stateful.  This saves current dead key state at
-   * WM_KEYDOWN.  Additionally, computes current inputted character(s) and set
-   * them to the aNativeKey.
-   */
-  void InitNativeKey(NativeKey& aNativeKey,
-                     const ModifierKeyState& aModKeyState);
-
-  /**
-   * MaybeInitNativeKeyAsDeadKey() initializes aNativeKey only when aNativeKey
-   * is a dead key's event.
-   * When it's not in a dead key sequence, this activates the dead key state.
-   * When it's in a dead key sequence, this initializes aNativeKey with a
-   * composite character or a preceding dead char and a dead char which should
-   * be caused by aNativeKey.
-   * Returns true when this initializes aNativeKey.  Otherwise, false.
-   */
-  bool MaybeInitNativeKeyAsDeadKey(NativeKey& aNativeKey,
-                                   const ModifierKeyState& aModKeyState);
-
-  /**
-   * MaybeInitNativeKeyWithCompositeChar() may initialize aNativeKey with
-   * proper composite character when dead key produces a composite character.
-   * Otherwise, just returns false.
-   */
-  bool MaybeInitNativeKeyWithCompositeChar(
-         NativeKey& aNativeKey,
-         const ModifierKeyState& aModKeyState);
-
-  /**
-   * See the comment of GetUniCharsAndModifiers() below.
-   */
-  UniCharsAndModifiers GetUniCharsAndModifiers(
-                         uint8_t aVirtualKey,
-                         VirtualKey::ShiftState aShiftState) const;
-
-  /**
-   * GetCompositeChar() returns a composite character with dead character
-   * caused by aVirtualKeyOfDeadKey and aShiftStateOfDeadKey and a base
-   * character (aBaseChar).
-   * If the combination of the dead character and the base character doesn't
-   * cause a composite character, this returns 0.
-   */
-  char16_t GetCompositeChar(uint8_t aVirtualKeyOfDeadKey,
-                            VirtualKey::ShiftState aShiftStateOfDeadKey,
-                            char16_t aBaseChar) const;
-
 public:
   static KeyboardLayout* GetInstance();
   static void Shutdown();
   static void NotifyIdleServiceOfUserActivity();
 
   static bool IsPrintableCharKey(uint8_t aVirtualKey);
 
   /**
@@ -819,16 +717,121 @@ public:
    * Implementation of nsIWidget::SynthesizeNativeKeyEvent().
    */
   nsresult SynthesizeNativeKeyEvent(nsWindowBase* aWidget,
                                     int32_t aNativeKeyboardLayout,
                                     int32_t aNativeKeyCode,
                                     uint32_t aModifierFlags,
                                     const nsAString& aCharacters,
                                     const nsAString& aUnmodifiedCharacters);
+
+private:
+  KeyboardLayout();
+  ~KeyboardLayout();
+
+  static KeyboardLayout* sInstance;
+  static nsIIdleServiceInternal* sIdleService;
+
+  struct DeadKeyTableListEntry
+  {
+    DeadKeyTableListEntry* next;
+    uint8_t data[1];
+  };
+
+  HKL mKeyboardLayout;
+
+  VirtualKey mVirtualKeys[NS_NUM_OF_KEYS];
+  DeadKeyTableListEntry* mDeadKeyTableListHead;
+  int32_t mActiveDeadKey;                 // -1 = no active dead-key
+  VirtualKey::ShiftState mDeadKeyShiftState;
+
+  bool mIsOverridden;
+  bool mIsPendingToRestoreKeyboardLayout;
+
+  static inline int32_t GetKeyIndex(uint8_t aVirtualKey);
+  static int CompareDeadKeyEntries(const void* aArg1, const void* aArg2,
+                                   void* aData);
+  static bool AddDeadKeyEntry(char16_t aBaseChar, char16_t aCompositeChar,
+                                DeadKeyEntry* aDeadKeyArray, uint32_t aEntries);
+  bool EnsureDeadKeyActive(bool aIsActive, uint8_t aDeadKey,
+                             const PBYTE aDeadKeyKbdState);
+  uint32_t GetDeadKeyCombinations(uint8_t aDeadKey,
+                                  const PBYTE aDeadKeyKbdState,
+                                  uint16_t aShiftStatesWithBaseChars,
+                                  DeadKeyEntry* aDeadKeyArray,
+                                  uint32_t aMaxEntries);
+  /**
+   * Activates or deactivates dead key state.
+   */
+  void ActivateDeadKeyState(const NativeKey& aNativeKey,
+                            const ModifierKeyState& aModKeyState);
+  void DeactivateDeadKeyState();
+
+  const DeadKeyTable* AddDeadKeyTable(const DeadKeyEntry* aDeadKeyArray,
+                                      uint32_t aEntries);
+  void ReleaseDeadKeyTables();
+
+  /**
+   * Loads the specified keyboard layout. This method always clear the dead key
+   * state.
+   */
+  void LoadLayout(HKL aLayout);
+
+  /**
+   * InitNativeKey() must be called when actually widget receives WM_KEYDOWN or
+   * WM_KEYUP.  This method is stateful.  This saves current dead key state at
+   * WM_KEYDOWN.  Additionally, computes current inputted character(s) and set
+   * them to the aNativeKey.
+   */
+  void InitNativeKey(NativeKey& aNativeKey,
+                     const ModifierKeyState& aModKeyState);
+
+  /**
+   * MaybeInitNativeKeyAsDeadKey() initializes aNativeKey only when aNativeKey
+   * is a dead key's event.
+   * When it's not in a dead key sequence, this activates the dead key state.
+   * When it's in a dead key sequence, this initializes aNativeKey with a
+   * composite character or a preceding dead char and a dead char which should
+   * be caused by aNativeKey.
+   * Returns true when this initializes aNativeKey.  Otherwise, false.
+   */
+  bool MaybeInitNativeKeyAsDeadKey(NativeKey& aNativeKey,
+                                   const ModifierKeyState& aModKeyState);
+
+  /**
+   * MaybeInitNativeKeyWithCompositeChar() may initialize aNativeKey with
+   * proper composite character when dead key produces a composite character.
+   * Otherwise, just returns false.
+   */
+  bool MaybeInitNativeKeyWithCompositeChar(
+         NativeKey& aNativeKey,
+         const ModifierKeyState& aModKeyState);
+
+  /**
+   * See the comment of GetUniCharsAndModifiers() below.
+   */
+  UniCharsAndModifiers GetUniCharsAndModifiers(
+                         uint8_t aVirtualKey,
+                         VirtualKey::ShiftState aShiftState) const;
+
+  /**
+   * GetCompositeChar() returns a composite character with dead character
+   * caused by aVirtualKeyOfDeadKey and aShiftStateOfDeadKey and a base
+   * character (aBaseChar).
+   * If the combination of the dead character and the base character doesn't
+   * cause a composite character, this returns 0.
+   */
+  char16_t GetCompositeChar(uint8_t aVirtualKeyOfDeadKey,
+                            VirtualKey::ShiftState aShiftStateOfDeadKey,
+                            char16_t aBaseChar) const;
+
+  // NativeKey class should access InitNativeKey() directly, but it shouldn't
+  // be available outside of NativeKey.  So, let's make NativeKey a friend
+  // class of this.
+  friend class NativeKey;
 };
 
 class RedirectedKeyDownMessageManager
 {
 public:
   /*
    * If a window receives WM_KEYDOWN message or WM_SYSKEYDOWM message which is
    * a redirected message, NativeKey::DispatchKeyDownAndKeyPressEvent()