Bug 672175 part.1 Implement MouseScrollHandler for Windows r=jimm
authorMasayuki Nakano <masayuki@d-toybox.com>
Tue, 06 Mar 2012 12:20:28 +0900
changeset 88343 a752fae4b8dfb29522c999a575ec83c3dbb7141b
parent 88342 ae005ec67376f06621d997ff208c95202b55c308
child 88344 927dae404b953b3427e2d906b4e1b61c2214aa28
push id22194
push usermak77@bonardo.net
push dateWed, 07 Mar 2012 09:33:54 +0000
treeherdermozilla-central@8ef88a69f861 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjimm
bugs672175
milestone13.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 672175 part.1 Implement MouseScrollHandler for Windows r=jimm
widget/windows/Makefile.in
widget/windows/WinMouseScrollHandler.cpp
widget/windows/WinMouseScrollHandler.h
widget/windows/nsWidgetFactory.cpp
widget/windows/nsWindow.cpp
--- a/widget/windows/Makefile.in
+++ b/widget/windows/Makefile.in
@@ -74,16 +74,17 @@ CPPSRCS = \
   TaskbarPreviewButton.cpp \
   JumpListBuilder.cpp \
   JumpListItem.cpp \
   GfxInfo.cpp \
   WidgetTraceEvent.cpp \
   AudioSession.cpp \
   nsWidgetFactory.cpp \
   WinUtils.cpp \
+  WinMouseScrollHandler.cpp \
   $(NULL)
 
 ifdef MOZ_CRASHREPORTER
 CPPSRCS += LSPAnnotator.cpp
 endif
 
 ifdef NS_PRINTING
 CPPSRCS		+= \
new file mode 100644
--- /dev/null
+++ b/widget/windows/WinMouseScrollHandler.cpp
@@ -0,0 +1,85 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this file,
+ * You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#ifdef MOZ_LOGGING
+#define FORCE_PR_LOG /* Allow logging in the release build */
+#endif // MOZ_LOGGING
+#include "prlog.h"
+
+#include "WinMouseScrollHandler.h"
+#include "nsWindow.h"
+
+namespace mozilla {
+namespace widget {
+
+#ifdef PR_LOGGING
+PRLogModuleInfo* gMouseScrollLog = nsnull;
+#endif
+
+MouseScrollHandler* MouseScrollHandler::sInstance = nsnull;
+
+
+/******************************************************************************
+ *
+ * MouseScrollHandler
+ *
+ ******************************************************************************/
+
+/* static */
+void
+MouseScrollHandler::Initialize()
+{
+#ifdef PR_LOGGING
+  if (!gMouseScrollLog) {
+    gMouseScrollLog = PR_NewLogModule("MouseScrollHandlerWidgets");
+  }
+#endif
+}
+
+/* static */
+void
+MouseScrollHandler::Shutdown()
+{
+  delete sInstance;
+  sInstance = nsnull;
+}
+
+/* static */
+MouseScrollHandler*
+MouseScrollHandler::GetInstance()
+{
+  if (!sInstance) {
+    sInstance = new MouseScrollHandler();
+  }
+  return sInstance;
+}
+
+MouseScrollHandler::MouseScrollHandler()
+{
+  PR_LOG(gMouseScrollLog, PR_LOG_ALWAYS,
+    ("MouseScroll: Creating an instance, this=%p, sInstance=%p",
+     this, sInstance));
+}
+
+MouseScrollHandler::~MouseScrollHandler()
+{
+  PR_LOG(gMouseScrollLog, PR_LOG_ALWAYS,
+    ("MouseScroll: Destroying an instance, this=%p, sInstance=%p",
+     this, sInstance));
+}
+
+/* static */
+bool
+MouseScrollHandler::ProcessMessage(nsWindow* aWindow, UINT msg,
+                                   WPARAM wParam, LPARAM lParam,
+                                   LRESULT *aRetValue, bool &aEatMessage)
+{
+  return false;
+}
+
+
+} // namespace widget
+} // namespace mozilla
new file mode 100644
--- /dev/null
+++ b/widget/windows/WinMouseScrollHandler.h
@@ -0,0 +1,44 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this file,
+ * You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#ifndef mozilla_widget_WinMouseScrollHandler_h__
+#define mozilla_widget_WinMouseScrollHandler_h__
+
+#include "nscore.h"
+#include "nsDebug.h"
+#include "mozilla/Assertions.h"
+#include <windows.h>
+
+class nsWindow;
+
+namespace mozilla {
+namespace widget {
+
+class MouseScrollHandler {
+public:
+  static MouseScrollHandler* GetInstance();
+
+  static void Initialize();
+  static void Shutdown();
+
+  static bool ProcessMessage(nsWindow* aWindow,
+                             UINT msg,
+                             WPARAM wParam,
+                             LPARAM lParam,
+                             LRESULT *aRetValue,
+                             bool &aEatMessage);
+
+private:
+  MouseScrollHandler();
+  ~MouseScrollHandler();
+
+  static MouseScrollHandler* sInstance;
+};
+
+} // namespace widget
+} // namespace mozilla
+
+#endif // mozilla_widget_WinMouseScrollHandler_h__
\ No newline at end of file
--- a/widget/windows/nsWidgetFactory.cpp
+++ b/widget/windows/nsWidgetFactory.cpp
@@ -48,16 +48,17 @@
 #include "mozilla/ModuleUtils.h"
 #include "nsIServiceManager.h"
 #include "nsIdleServiceWin.h"
 #include "nsLookAndFeel.h"
 #include "nsNativeThemeWin.h"
 #include "nsScreenManagerWin.h"
 #include "nsSound.h"
 #include "nsWindow.h"
+#include "WinMouseScrollHandler.h"
 #include "WinTaskbar.h"
 #include "JumpListBuilder.h"
 #include "JumpListItem.h"
 #include "GfxInfo.h"
 #include "nsToolkit.h"
 
 // Drag & Drop, Clipboard
 
@@ -204,16 +205,17 @@ static const mozilla::Module::ContractID
   { "@mozilla.org/gfx/devicecontextspec;1", &kNS_DEVICE_CONTEXT_SPEC_CID },
 #endif
   { NULL }
 };
 
 static void
 nsWidgetWindowsModuleDtor()
 {
+  MouseScrollHandler::Shutdown();
   nsLookAndFeel::Shutdown();
   nsToolkit::Shutdown();
   nsAppShellShutdown();
 }
 
 static const mozilla::Module kWidgetModule = {
   mozilla::Module::kVersion,
   kWidgetCIDs,
--- a/widget/windows/nsWindow.cpp
+++ b/widget/windows/nsWindow.cpp
@@ -128,16 +128,17 @@
 #include "nsIObserverService.h"
 #include "nsIScreenManager.h"
 #include "imgIContainer.h"
 #include "nsIFile.h"
 #include "nsIRollupListener.h"
 #include "nsIServiceManager.h"
 #include "nsIClipboard.h"
 #include "nsIMM32Handler.h"
+#include "WinMouseScrollHandler.h"
 #include "nsILocalFile.h"
 #include "nsFontMetrics.h"
 #include "nsIFontEnumerator.h"
 #include "nsGUIEvent.h"
 #include "nsFont.h"
 #include "nsRect.h"
 #include "nsThreadUtils.h"
 #include "nsNativeCharsetUtils.h"
@@ -422,37 +423,32 @@ nsWindow::nsWindow() : nsBaseWidget()
   mTaskbarPreview = nsnull;
   mHasTaskbarIconBeenCreated = false;
 
   // Global initialization
   if (!sInstanceCount) {
     // Global app registration id for Win7 and up. See
     // WinTaskbar.cpp for details.
     mozilla::widget::WinTaskbar::RegisterAppUserModelID();
-
     gKbdLayout.LoadLayout(::GetKeyboardLayout(0));
-
     // Init IME handler
     nsIMM32Handler::Initialize();
-
 #ifdef NS_ENABLE_TSF
     nsTextStore::Initialize();
 #endif
-
-    if (SUCCEEDED(::OleInitialize(NULL)))
+    if (SUCCEEDED(::OleInitialize(NULL))) {
       sIsOleInitialized = TRUE;
+    }
     NS_ASSERTION(sIsOleInitialized, "***** OLE is not initialized!\n");
-
     InitInputWorkaroundPrefDefaults();
-
+    MouseScrollHandler::Initialize();
     // Init titlebar button info for custom frames.
     nsUXThemeData::InitTitlebarInfo();
     // Init theme data
     nsUXThemeData::UpdateNativeThemeInfo();
-
     ForgetRedirectedKeyDownMessage();
   } // !sInstanceCount
 
   mIdleService = nsnull;
 
   sInstanceCount++;
 }
 
@@ -4523,16 +4519,21 @@ bool nsWindow::ProcessMessage(UINT msg, 
 #endif
 
   bool eatMessage;
   if (nsIMM32Handler::ProcessMessage(this, msg, wParam, lParam, aRetValue,
                                      eatMessage)) {
     return mWnd ? eatMessage : true;
   }
 
+  if (MouseScrollHandler::ProcessMessage(this, msg, wParam, lParam, aRetValue,
+                                         eatMessage)) {
+    return mWnd ? eatMessage : true;
+  }
+
   if (PluginHasFocus()) {
     bool callDefaultWndProc;
     MSG nativeMsg = WinUtils::InitMSG(msg, wParam, lParam);
     if (ProcessMessageForPlugin(nativeMsg, aRetValue, callDefaultWndProc)) {
       return mWnd ? !callDefaultWndProc : true;
     }
   }