Bug 1307112 part.6 Get rid of char message argument from public NativeKey::HandleCharMessage() method r=m_kato
authorMasayuki Nakano <masayuki@d-toybox.com>
Mon, 03 Oct 2016 23:55:14 +0900
changeset 316880 6d50e95e5494dd263c0e98ca2d04567e47ba86df
parent 316879 38f802fc35a0944031248d677b60e67c3adc8d78
child 316881 c6dca012337bcb0a625335b3c4904ce6ae3bcf23
push id32935
push usermasayuki@d-toybox.com
push dateFri, 07 Oct 2016 05:19:38 +0000
treeherderautoland@1de5e07bed66 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersm_kato
bugs1307112
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 1307112 part.6 Get rid of char message argument from public NativeKey::HandleCharMessage() method r=m_kato Currently, NativeKey::HandleCharMessage() is only a public method and it takes any char message. However, when it's called outside of NativeKey, it should work only with NativeKey::mMsg. Therefore, we should make current HandleCharMessage() a private method and create new overload method which doesn't take MSG as an argument. MozReview-Commit-ID: LowV2FUmR3U
widget/windows/KeyboardLayout.cpp
widget/windows/KeyboardLayout.h
widget/windows/nsWindow.cpp
--- a/widget/windows/KeyboardLayout.cpp
+++ b/widget/windows/KeyboardLayout.cpp
@@ -2485,16 +2485,23 @@ NativeKey::HandleKeyDownMessage(bool* aE
 
   MOZ_LOG(sNativeKeyLogger, LogLevel::Info,
     ("%p   NativeKey::HandleKeyDownMessage(), tries to be dispatching "
      "keypress events due to no following char messages...", this));
   return DispatchKeyPressEventsWithoutCharMessage();
 }
 
 bool
+NativeKey::HandleCharMessage(bool* aEventDispatched) const
+{
+  MOZ_ASSERT(IsCharOrSysCharMessage(mMsg));
+  return HandleCharMessage(mMsg, aEventDispatched);
+}
+
+bool
 NativeKey::HandleCharMessage(const MSG& aCharMsg,
                              bool* aEventDispatched) const
 {
   MOZ_ASSERT(IsKeyDownMessage() || IsCharOrSysCharMessage(mMsg));
   MOZ_ASSERT(IsCharOrSysCharMessage(aCharMsg.message));
 
   if (aEventDispatched) {
     *aEventDispatched = false;
--- a/widget/windows/KeyboardLayout.h
+++ b/widget/windows/KeyboardLayout.h
@@ -242,21 +242,20 @@ public:
    * initialized with WM_KEYDOWN or WM_SYSKEYDOWN.
    * Returns true if dispatched keydown event or keypress event is consumed.
    * Otherwise, false.
    */
   bool HandleKeyDownMessage(bool* aEventDispatched = nullptr) const;
 
   /**
    * Handles WM_CHAR message or WM_SYSCHAR message.  The instance must be
-   * initialized with WM_KEYDOWN, WM_SYSKEYDOWN or them.
+   * initialized with them.
    * Returns true if dispatched keypress event is consumed.  Otherwise, false.
    */
-  bool HandleCharMessage(const MSG& aCharMsg,
-                         bool* aEventDispatched = nullptr) const;
+  bool HandleCharMessage(bool* aEventDispatched = nullptr) const;
 
   /**
    * Handles keyup message.  Returns true if the event is consumed.
    * Otherwise, false.
    */
   bool HandleKeyUpMessage(bool* aEventDispatched = nullptr) const;
 
   /**
@@ -578,16 +577,24 @@ private:
    * IsFocusedWindowChanged() returns true if focused window is changed
    * after the instance is created.
    */
   bool IsFocusedWindowChanged() const
   {
     return mFocusedWndBeforeDispatch != ::GetFocus();
   }
 
+  /**
+   * Handles WM_CHAR message or WM_SYSCHAR message.  The instance must be
+   * initialized with WM_KEYDOWN, WM_SYSKEYDOWN or them.
+   * Returns true if dispatched keypress event is consumed.  Otherwise, false.
+   */
+  bool HandleCharMessage(const MSG& aCharMsg,
+                         bool* aEventDispatched = nullptr) const;
+
   // Calls of PeekMessage() from NativeKey might cause nested message handling
   // due to (perhaps) odd API hook.  NativeKey should do nothing if given
   // message is tried to be retrieved by another instance.
 
   /**
    * sLatestInstacne is a pointer to the newest instance of NativeKey which is
    * handling a key or char message(s).
    */
--- a/widget/windows/nsWindow.cpp
+++ b/widget/windows/nsWindow.cpp
@@ -6033,18 +6033,17 @@ LRESULT nsWindow::ProcessCharMessage(con
   if (IMEHandler::IsComposingOn(this)) {
     IMEHandler::NotifyIME(this, REQUEST_TO_COMMIT_COMPOSITION);
   }
   // These must be checked here too as a lone WM_CHAR could be received
   // if a child window didn't handle it (for example Alt+Space in a content
   // window)
   ModifierKeyState modKeyState;
   NativeKey nativeKey(this, aMsg, modKeyState);
-  return static_cast<LRESULT>(nativeKey.HandleCharMessage(aMsg,
-                                                          aEventDispatched));
+  return static_cast<LRESULT>(nativeKey.HandleCharMessage(aEventDispatched));
 }
 
 LRESULT nsWindow::ProcessKeyUpMessage(const MSG &aMsg, bool *aEventDispatched)
 {
   ModifierKeyState modKeyState;
   NativeKey nativeKey(this, aMsg, modKeyState);
   return static_cast<LRESULT>(nativeKey.HandleKeyUpMessage(aEventDispatched));
 }