From 6a2714943db5706430a8699c8c7b75cf605233cb Mon Sep 17 00:00:00 2001 From: Mats Palmgren Date: Sun, 11 Apr 2010 02:14:55 +0200 Subject: [PATCH] Bug 530070. r=jmathies --- widget/src/windows/nsWindow.cpp | 11 ++++++++--- widget/src/windows/nsWindow.h | 2 ++ 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/widget/src/windows/nsWindow.cpp b/widget/src/windows/nsWindow.cpp index e2afb3bea5de..c6692582929f 100644 --- a/widget/src/windows/nsWindow.cpp +++ b/widget/src/windows/nsWindow.cpp @@ -33,7 +33,7 @@ * Masayuki Nakano * Dainis Jonitis * Christian Biesinger - * Mats Palmgren + * Mats Palmgren * Ningjie Chen * Jim Mathies * Kyle Huey @@ -538,10 +538,12 @@ nsWindow::Create(nsIWidget *aParent, aAppShell, aToolkit, aInitData); HWND parent; - if (nsnull != aParent) { // has a nsIWidget parent - parent = ((aParent) ? (HWND)aParent->GetNativeData(NS_NATIVE_WINDOW) : nsnull); + if (aParent) { // has a nsIWidget parent + parent = aParent ? (HWND)aParent->GetNativeData(NS_NATIVE_WINDOW) : NULL; + mParent = aParent; } else { // has a nsNative parent parent = (HWND)aNativeParent; + mParent = aNativeParent ? GetNSWindowPtr((HWND)aNativeParent) : nsnull; } if (nsnull != aInitData) { @@ -1000,6 +1002,8 @@ BOOL nsWindow::SetNSWindowPtr(HWND aWnd, nsWindow * ptr) // Get and set parent widgets NS_IMETHODIMP nsWindow::SetParent(nsIWidget *aNewParent) { + mParent = aNewParent; + if (aNewParent) { nsCOMPtr kungFuDeathGrip(this); @@ -6191,6 +6195,7 @@ void nsWindow::OnDestroy() // XXX Windows will take care of this in the proper order, and SetParent(nsnull)'s // remove child on the parent already took place in nsBaseWidget's Destroy call above. //SetParent(nsnull); + mParent = nsnull; // We have to destroy the native drag target before we null out our window pointer. EnableDragDrop(PR_FALSE); diff --git a/widget/src/windows/nsWindow.h b/widget/src/windows/nsWindow.h index ed2f67b79cb8..3f8ed53574ec 100644 --- a/widget/src/windows/nsWindow.h +++ b/widget/src/windows/nsWindow.h @@ -27,6 +27,7 @@ * Masayuki Nakano * Ningjie Chen * Jim Mathies . + * Mats Palmgren * * Alternatively, the contents of this file may be used under the terms of * either the GNU General Public License Version 2 or later (the "GPL"), or @@ -420,6 +421,7 @@ protected: #endif // ACCESSIBILITY protected: + nsCOMPtr mParent; nsIntSize mLastSize; nsIntPoint mLastPoint; HWND mWnd;