Bug 1280513 part.1 Rename LogKeyStateImpl() to MouseScrollHandler::MaybeLogKeyState() r?m_kato draft
authorMasayuki Nakano <masayuki@d-toybox.com>
Fri, 17 Jun 2016 03:03:44 +0900
changeset 379721 c1989d4584badb03749a4841339dfc25b3d99d21
parent 378181 14c5bf11d37b9e92d27f7089d9392de2ac339bb3
child 379722 0f565f687fe44411f4afacf5c0c59c982921779d
push id21031
push usermasayuki@d-toybox.com
push dateThu, 16 Jun 2016 18:16:43 +0000
reviewersm_kato
bugs1280513
milestone50.0a1
Bug 1280513 part.1 Rename LogKeyStateImpl() to MouseScrollHandler::MaybeLogKeyState() r?m_kato MozReview-Commit-ID: DGDrRO3Y9jD
widget/windows/WinMouseScrollHandler.cpp
widget/windows/WinMouseScrollHandler.h
--- a/widget/windows/WinMouseScrollHandler.cpp
+++ b/widget/windows/WinMouseScrollHandler.cpp
@@ -29,42 +29,16 @@ namespace widget {
 
 PRLogModuleInfo* gMouseScrollLog = nullptr;
 
 static const char* GetBoolName(bool aBool)
 {
   return aBool ? "TRUE" : "FALSE";
 }
 
-static void LogKeyStateImpl()
-{
-  if (!MOZ_LOG_TEST(gMouseScrollLog, LogLevel::Debug)) {
-    return;
-  }
-  BYTE keyboardState[256];
-  if (::GetKeyboardState(keyboardState)) {
-    for (size_t i = 0; i < ArrayLength(keyboardState); i++) {
-      if (keyboardState[i]) {
-        MOZ_LOG(gMouseScrollLog, LogLevel::Debug,
-          ("    Current key state: keyboardState[0x%02X]=0x%02X (%s)",
-           i, keyboardState[i],
-           ((keyboardState[i] & 0x81) == 0x81) ? "Pressed and Toggled" :
-           (keyboardState[i] & 0x80) ? "Pressed" :
-           (keyboardState[i] & 0x01) ? "Toggled" : "Unknown"));
-      }
-    }
-  } else {
-    MOZ_LOG(gMouseScrollLog, LogLevel::Debug,
-      ("MouseScroll::Device::Elantech::HandleKeyMessage(): Failed to print "
-       "current keyboard state"));
-  }
-}
-
-#define LOG_KEYSTATE() LogKeyStateImpl()
-
 MouseScrollHandler* MouseScrollHandler::sInstance = nullptr;
 
 bool MouseScrollHandler::Device::sFakeScrollableWindowNeeded = false;
 
 bool MouseScrollHandler::Device::SynTP::sInitialized = false;
 int32_t MouseScrollHandler::Device::SynTP::sMajorVersion = 0;
 int32_t MouseScrollHandler::Device::SynTP::sMinorVersion = -1;
 
@@ -145,16 +119,42 @@ MouseScrollHandler::~MouseScrollHandler(
   MOZ_LOG(gMouseScrollLog, LogLevel::Info,
     ("MouseScroll: Destroying an instance, this=%p, sInstance=%p",
      this, sInstance));
 
   delete mSynthesizingEvent;
 }
 
 /* static */
+void
+MouseScrollHandler::MaybeLogKeyState()
+{
+  if (!MOZ_LOG_TEST(gMouseScrollLog, LogLevel::Debug)) {
+    return;
+  }
+  BYTE keyboardState[256];
+  if (::GetKeyboardState(keyboardState)) {
+    for (size_t i = 0; i < ArrayLength(keyboardState); i++) {
+      if (keyboardState[i]) {
+        MOZ_LOG(gMouseScrollLog, LogLevel::Debug,
+          ("    Current key state: keyboardState[0x%02X]=0x%02X (%s)",
+           i, keyboardState[i],
+           ((keyboardState[i] & 0x81) == 0x81) ? "Pressed and Toggled" :
+           (keyboardState[i] & 0x80) ? "Pressed" :
+           (keyboardState[i] & 0x01) ? "Toggled" : "Unknown"));
+      }
+    }
+  } else {
+    MOZ_LOG(gMouseScrollLog, LogLevel::Debug,
+      ("MouseScroll::MaybeLogKeyState(): Failed to print current keyboard "
+       "state"));
+  }
+}
+
+/* static */
 bool
 MouseScrollHandler::NeedsMessage(UINT aMsg)
 {
   switch (aMsg) {
     case WM_SETTINGCHANGE:
     case WM_MOUSEWHEEL:
     case WM_MOUSEHWHEEL:
     case WM_HSCROLL:
@@ -230,17 +230,17 @@ MouseScrollHandler::ProcessMessage(nsWin
     case WM_KEYDOWN:
     case WM_KEYUP:
       MOZ_LOG(gMouseScrollLog, LogLevel::Info,
         ("MouseScroll::ProcessMessage(): aWidget=%p, "
          "msg=%s(0x%04X), wParam=0x%02X, ::GetMessageTime()=%d",
          aWidget, msg == WM_KEYDOWN ? "WM_KEYDOWN" :
                     msg == WM_KEYUP ? "WM_KEYUP" : "Unknown", msg, wParam,
          ::GetMessageTime()));
-      LOG_KEYSTATE();
+      MaybeLogKeyState();
       if (Device::Elantech::HandleKeyMessage(aWidget, msg, wParam, lParam)) {
         aResult.mResult = 0;
         aResult.mConsumed = true;
         return true;
       }
       return false;
 
     default:
@@ -394,17 +394,17 @@ MouseScrollHandler::ProcessNativeMouseWh
 
   MOZ_LOG(gMouseScrollLog, LogLevel::Info,
     ("MouseScroll::ProcessNativeMouseWheelMessage: aWidget=%p, "
      "aMessage=%s, wParam=0x%08X, lParam=0x%08X, point: { x=%d, y=%d }",
      aWidget, aMessage == WM_MOUSEWHEEL ? "WM_MOUSEWHEEL" :
               aMessage == WM_MOUSEHWHEEL ? "WM_MOUSEHWHEEL" :
               aMessage == WM_VSCROLL ? "WM_VSCROLL" : "WM_HSCROLL",
      aWParam, aLParam, point.x, point.y));
-  LOG_KEYSTATE();
+  MaybeLogKeyState();
 
   HWND underCursorWnd = ::WindowFromPoint(point);
   if (!underCursorWnd) {
     MOZ_LOG(gMouseScrollLog, LogLevel::Info,
       ("MouseScroll::ProcessNativeMouseWheelMessage: "
        "No window is not found under the cursor"));
     return;
   }
--- a/widget/windows/WinMouseScrollHandler.h
+++ b/widget/windows/WinMouseScrollHandler.h
@@ -61,16 +61,18 @@ public:
   }
 
 private:
   MouseScrollHandler();
   ~MouseScrollHandler();
 
   bool mIsWaitingInternalMessage;
 
+  static void MaybeLogKeyState();
+
   static MouseScrollHandler* sInstance;
 
   /**
    * InitEvent() initializes the aEvent.  If aPoint is null, the result of
    * GetCurrentMessagePos() will be used.
    */
   static void InitEvent(nsWindowBase* aWidget,
                         WidgetGUIEvent& aEvent,