mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-10 11:55:49 +00:00
Bug 879562 - Convert WinUtils::GetNSWindowPtr to WinUtils::GetNSWindowBasePtr. r=masayuki
This commit is contained in:
parent
b85b9e909d
commit
20af71bdf0
@ -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.
|
||||
|
@ -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<nsWindowBase*>(::GetPropW(aWnd, GetNSWindowPropName()));
|
||||
}
|
||||
|
||||
/* static */
|
||||
|
@ -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);
|
||||
|
||||
/**
|
||||
|
@ -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<nsWindow*>(widget);
|
||||
nsWindowBase * window = static_cast<nsWindowBase*>(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())
|
||||
|
@ -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<LONG_PTR>(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<nsWindow*>(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<nsWindowBase*>(widget);
|
||||
}
|
||||
|
||||
BOOL CALLBACK
|
||||
|
@ -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.
|
||||
|
@ -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<HWND>(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.
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user