Bug 1390097 - Revert a part of bug 1354020 changes. r?masayuki draft
authorMakoto Kato <m_kato@ga2.so-net.ne.jp>
Wed, 23 Aug 2017 12:59:40 +0900
changeset 651811 6aa2013bcaa7624d4ea096048d49e603cdaa700d
parent 650941 7c50f0c999c5bf8ee915261997597a5a9b8fb2ae
child 727862 d4e6467511f815a5ce06816801c223c4b3ee1d9d
push id75809
push userbmo:m_kato@ga2.so-net.ne.jp
push dateThu, 24 Aug 2017 00:50:58 +0000
reviewersmasayuki
bugs1390097, 1354020
milestone57.0a1
Bug 1390097 - Revert a part of bug 1354020 changes. r?masayuki Bug 1354020 causes that IMM-IME on Windows 7 doesn't work with --no-remote. Although I think that this issue is OS or IME bug, when default window proceduce by RegisterClass is DefaultWindowProcW, Google Japanese IME doesn't work. I am not sure why this issue occurs when lpfnWndProc is DefWidnowProcW and DDE isn't started. But for workaround, we should revert a part of bug 1354020 changes. MozReview-Commit-ID: BkxlZnm8mIh
widget/windows/WinUtils.cpp
widget/windows/WinUtils.h
widget/windows/nsWindow.cpp
--- a/widget/windows/WinUtils.cpp
+++ b/widget/windows/WinUtils.cpp
@@ -470,17 +470,17 @@ WinUtils::Initialize()
 #endif
 }
 
 // static
 LRESULT WINAPI
 WinUtils::NonClientDpiScalingDefWindowProcW(HWND hWnd, UINT msg,
                                             WPARAM wParam, LPARAM lParam)
 {
-  if (msg == WM_NCCREATE) {
+  if (msg == WM_NCCREATE && sEnableNonClientDpiScaling) {
     sEnableNonClientDpiScaling(hWnd);
   }
   return ::DefWindowProcW(hWnd, msg, wParam, lParam);
 }
 
 // static
 void
 WinUtils::LogW(const wchar_t *fmt, ...)
--- a/widget/windows/WinUtils.h
+++ b/widget/windows/WinUtils.h
@@ -158,22 +158,16 @@ public:
 
 class WinUtils
 {
   // Function pointers for APIs that may not be available depending on
   // the Win10 update version -- will be set up in Initialize().
   static SetThreadDpiAwarenessContextProc sSetThreadDpiAwarenessContext;
   static EnableNonClientDpiScalingProc sEnableNonClientDpiScaling;
 
-  // Wrapper for DefWindowProc that will enable non-client dpi scaling on the
-  // window during creation.
-  static LRESULT WINAPI
-  NonClientDpiScalingDefWindowProcW(HWND hWnd, UINT msg,
-                                    WPARAM wParam, LPARAM lParam);
-
 public:
   class AutoSystemDpiAware
   {
   public:
     AutoSystemDpiAware()
     {
       if (sSetThreadDpiAwarenessContext) {
         mPrevContext = sSetThreadDpiAwarenessContext(DPI_AWARENESS_CONTEXT_SYSTEM_AWARE);
@@ -186,21 +180,21 @@ public:
         sSetThreadDpiAwarenessContext(mPrevContext);
       }
     }
 
   private:
     DPI_AWARENESS_CONTEXT mPrevContext;
   };
 
-  static decltype(::DefWindowProcW)* GetDefWindowProc()
-  {
-    return sEnableNonClientDpiScaling ? NonClientDpiScalingDefWindowProcW :
-                                        ::DefWindowProcW;
-  }
+  // Wrapper for DefWindowProc that will enable non-client dpi scaling on the
+  // window during creation.
+  static LRESULT WINAPI
+  NonClientDpiScalingDefWindowProcW(HWND hWnd, UINT msg,
+                                    WPARAM wParam, LPARAM lParam);
 
   /**
    * Get the system's default logical-to-physical DPI scaling factor,
    * which is based on the primary display. Note however that unlike
    * LogToPhysFactor(GetPrimaryMonitor()), this will not change during
    * a session even if the displays are reconfigured. This scale factor
    * is used by Windows theme metrics etc, which do not fully support
    * dynamic resolution changes but are only updated on logout.
--- a/widget/windows/nsWindow.cpp
+++ b/widget/windows/nsWindow.cpp
@@ -1010,17 +1010,17 @@ nsWindow::RegisterWindowClass(const wcha
 {
   WNDCLASSW wc;
   if (::GetClassInfoW(nsToolkit::mDllInstance, aClassName, &wc)) {
     // already registered
     return aClassName;
   }
 
   wc.style         = CS_DBLCLKS | aExtraStyle;
-  wc.lpfnWndProc   = WinUtils::GetDefWindowProc();
+  wc.lpfnWndProc   = WinUtils::NonClientDpiScalingDefWindowProcW;
   wc.cbClsExtra    = 0;
   wc.cbWndExtra    = 0;
   wc.hInstance     = nsToolkit::mDllInstance;
   wc.hIcon         = aIconID ? ::LoadIconW(::GetModuleHandleW(nullptr), aIconID) : nullptr;
   wc.hCursor       = nullptr;
   wc.hbrBackground = mBrush;
   wc.lpszMenuName  = nullptr;
   wc.lpszClassName = aClassName;