diff --git a/widget/windows/WinMouseScrollHandler.cpp b/widget/windows/WinMouseScrollHandler.cpp index e4f1228a4a6e..e3244efcf533 100644 --- a/widget/windows/WinMouseScrollHandler.cpp +++ b/widget/windows/WinMouseScrollHandler.cpp @@ -412,14 +412,14 @@ MouseScrollHandler::ProcessNativeMouseWheelMessage(nsWindow* aWindow, // except plugin window (MozillaWindowClass), we should handle the message // on the window. if (WinUtils::IsOurProcessWindow(underCursorWnd)) { - nsWindow* destWindow = WinUtils::GetNSWindowPtr(underCursorWnd); + nsWindowBase* destWindow = WinUtils::GetNSWindowBasePtr(underCursorWnd); if (!destWindow) { PR_LOG(gMouseScrollLog, PR_LOG_ALWAYS, ("MouseScroll::ProcessNativeMouseWheelMessage: " "Found window under the cursor isn't managed by nsWindow...")); HWND wnd = ::GetParent(underCursorWnd); for (; wnd; wnd = ::GetParent(wnd)) { - destWindow = WinUtils::GetNSWindowPtr(wnd); + destWindow = WinUtils::GetNSWindowBasePtr(wnd); if (destWindow) { break; } @@ -1498,7 +1498,7 @@ MouseScrollHandler::SynthesizingEvent::NativeMessageReceived(nsWindow* aWindow, // If the target window is not ours and received window is our plugin // window, it comes from child window of the plugin. if (aWindow && aWindow->GetWindowType() == eWindowType_plugin && - !WinUtils::GetNSWindowPtr(mWnd)) { + !WinUtils::GetNSWindowBasePtr(mWnd)) { return; } // Otherwise, the message may not be sent by us. diff --git a/widget/windows/WinUtils.cpp b/widget/windows/WinUtils.cpp index 1da311bd0e33..01ab26afbeee 100644 --- a/widget/windows/WinUtils.cpp +++ b/widget/windows/WinUtils.cpp @@ -252,13 +252,20 @@ GetNSWindowPropName() /* static */ bool -WinUtils::SetNSWindowPtr(HWND aWnd, nsWindow* aWindow) +WinUtils::SetNSWindowBasePtr(HWND aWnd, nsWindowBase* aWidget) { - if (!aWindow) { + if (!aWidget) { ::RemovePropW(aWnd, GetNSWindowPropName()); return true; } - return ::SetPropW(aWnd, GetNSWindowPropName(), (HANDLE)aWindow); + return ::SetPropW(aWnd, GetNSWindowPropName(), (HANDLE)aWidget); +} + +/* static */ +nsWindowBase* +WinUtils::GetNSWindowBasePtr(HWND aWnd) +{ + return static_cast(::GetPropW(aWnd, GetNSWindowPropName())); } /* static */ diff --git a/widget/windows/WinUtils.h b/widget/windows/WinUtils.h index 0d74e5bf9ab8..cc1badc1bd6c 100644 --- a/widget/windows/WinUtils.h +++ b/widget/windows/WinUtils.h @@ -26,6 +26,7 @@ #include "mozilla/Attributes.h" class nsWindow; +class nsWindowBase; struct KeyPair; namespace mozilla { @@ -134,12 +135,15 @@ public: bool aStopIfNotPopup = true); /** - * SetNSWindowPtr() associates an nsWindow to aWnd. If aWindow is NULL, - * it dissociate any nsWindow pointer from aWnd. - * GetNSWindowPtr() returns an nsWindow pointer which was associated by - * SetNSWindowPtr(). + * SetNSWindowBasePtr() associates an nsWindowBase to aWnd. If aWidget is NULL, + * it dissociate any nsBaseWidget pointer from aWnd. + * GetNSWindowBasePtr() returns an nsWindowBase pointer which was associated by + * SetNSWindowBasePtr(). + * GetNSWindowPtr() is a legacy api for win32 nsWindow and should be avoided + * outside of nsWindow src. */ - static bool SetNSWindowPtr(HWND aWnd, nsWindow* aWindow); + static bool SetNSWindowBasePtr(HWND aWnd, nsWindowBase* aWidget); + static nsWindowBase* GetNSWindowBasePtr(HWND aWnd); static nsWindow* GetNSWindowPtr(HWND aWnd); /** diff --git a/widget/windows/nsNativeThemeWin.cpp b/widget/windows/nsNativeThemeWin.cpp index fe9880545174..ca3bed42867e 100644 --- a/widget/windows/nsNativeThemeWin.cpp +++ b/widget/windows/nsNativeThemeWin.cpp @@ -64,11 +64,11 @@ GetTopLevelWindowActiveState(nsIFrame *aFrame) // Get the widget. nsIFrame's GetNearestWidget walks up the view chain // until it finds a real window. nsIWidget* widget = aFrame->GetNearestWidget(); - nsWindow * window = static_cast(widget); + nsWindowBase * window = static_cast(widget); if (!window) return mozilla::widget::themeconst::FS_INACTIVE; if (widget && !window->IsTopLevelWidget() && - !(window = window->GetParentWindow(false))) + !(window = window->GetParentWindowBase(false))) return mozilla::widget::themeconst::FS_INACTIVE; if (window->GetWindowHandle() == ::GetActiveWindow()) diff --git a/widget/windows/nsWindow.cpp b/widget/windows/nsWindow.cpp index 7d71a6123756..277879a1ec69 100644 --- a/widget/windows/nsWindow.cpp +++ b/widget/windows/nsWindow.cpp @@ -886,7 +886,7 @@ void nsWindow::SubclassWindow(BOOL bState) } NS_ASSERTION(mPrevWndProc, "Null standard window procedure"); // connect the this pointer to the nsWindow handle - WinUtils::SetNSWindowPtr(mWnd, this); + WinUtils::SetNSWindowBasePtr(mWnd, this); } else { if (IsWindow(mWnd)) { if (mUnicodeWidget) { @@ -899,7 +899,7 @@ void nsWindow::SubclassWindow(BOOL bState) reinterpret_cast(mPrevWndProc)); } } - WinUtils::SetNSWindowPtr(mWnd, NULL); + WinUtils::SetNSWindowBasePtr(mWnd, NULL); mPrevWndProc = NULL; } } @@ -978,7 +978,14 @@ double nsWindow::GetDefaultScaleInternal() return gfxWindowsPlatform::GetPlatform()->GetDPIScale(); } -nsWindow* nsWindow::GetParentWindow(bool aIncludeOwner) +nsWindow* +nsWindow::GetParentWindow(bool aIncludeOwner) +{ + return static_cast(GetParentWindowBase(aIncludeOwner)); +} + +nsWindowBase* +nsWindow::GetParentWindowBase(bool aIncludeOwner) { if (mIsTopWidgetWindow) { // Must use a flag instead of mWindowType to tell if the window is the @@ -1017,7 +1024,7 @@ nsWindow* nsWindow::GetParentWindow(bool aIncludeOwner) } } - return widget; + return static_cast(widget); } BOOL CALLBACK diff --git a/widget/windows/nsWindow.h b/widget/windows/nsWindow.h index ad9586092e39..85330c0825bf 100644 --- a/widget/windows/nsWindow.h +++ b/widget/windows/nsWindow.h @@ -85,6 +85,8 @@ public: // nsWindowBase virtual void InitEvent(nsGUIEvent& aEvent, nsIntPoint* aPoint = nullptr) MOZ_OVERRIDE; virtual bool DispatchWindowEvent(nsGUIEvent* aEvent) MOZ_OVERRIDE; + virtual nsWindowBase* GetParentWindowBase(bool aIncludeOwner) MOZ_OVERRIDE; + virtual bool IsTopLevelWidget() MOZ_OVERRIDE { return mIsTopWidgetWindow; } // nsIWidget interface NS_IMETHOD Create(nsIWidget *aParent, @@ -227,7 +229,7 @@ public: * Misc. */ virtual bool AutoErase(HDC dc); - bool IsTopLevelWidget() { return mIsTopWidgetWindow; } + /** * Start allowing Direct3D9 to be used by widgets when GetLayerManager is * called. diff --git a/widget/windows/nsWindowBase.h b/widget/windows/nsWindowBase.h index 454a06c957c3..b66f9b8cdb16 100644 --- a/widget/windows/nsWindowBase.h +++ b/widget/windows/nsWindowBase.h @@ -15,7 +15,6 @@ * nsWindowBase - Base class of common methods other classes need to access * in both win32 and winrt window classes. */ - class nsWindowBase : public nsBaseWidget { public: @@ -26,6 +25,16 @@ public: return static_cast(GetNativeData(NS_NATIVE_WINDOW)); } + /* + * Return the parent window, if it exists. + */ + virtual nsWindowBase* GetParentWindowBase(bool aIncludeOwner) = 0; + + /* + * Return true if this is a top level widget. + */ + virtual bool IsTopLevelWidget() = 0; + /* * Init a standard gecko event for this widget. */