Bug 530070. r=jmathies
This commit is contained in:
Родитель
270f417ab5
Коммит
5cd44494c3
|
@ -62,7 +62,7 @@ static POINTL gDragLastPoint;
|
|||
*/
|
||||
nsNativeDragTarget::nsNativeDragTarget(nsIWidget * aWnd)
|
||||
: m_cRef(0), mWindow(aWnd), mCanMove(PR_TRUE), mTookOwnRef(PR_FALSE),
|
||||
mDropTargetHelper(nsnull), mDragCancelled(PR_FALSE)
|
||||
mDropTargetHelper(nsnull)
|
||||
{
|
||||
mHWnd = (HWND)mWindow->GetNativeData(NS_NATIVE_WINDOW);
|
||||
|
||||
|
@ -297,6 +297,12 @@ nsNativeDragTarget::DragOver(DWORD grfKeyState,
|
|||
return E_FAIL;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDragSession> currentDragSession;
|
||||
mDragService->GetCurrentSession(getter_AddRefs(currentDragSession));
|
||||
if (!currentDragSession) {
|
||||
return S_OK; // Drag was canceled.
|
||||
}
|
||||
|
||||
// without the AddRef() |this| can get destroyed in an event handler
|
||||
this->AddRef();
|
||||
|
||||
|
@ -307,10 +313,8 @@ nsNativeDragTarget::DragOver(DWORD grfKeyState,
|
|||
}
|
||||
|
||||
mDragService->FireDragEventAtSource(NS_DRAGDROP_DRAG);
|
||||
if (!mDragCancelled) {
|
||||
// Now process the native drag state and then dispatch the event
|
||||
ProcessDrag(nsnull, NS_DRAGDROP_OVER, grfKeyState, ptl, pdwEffect);
|
||||
}
|
||||
// Now process the native drag state and then dispatch the event
|
||||
ProcessDrag(nsnull, NS_DRAGDROP_OVER, grfKeyState, ptl, pdwEffect);
|
||||
|
||||
this->Release();
|
||||
|
||||
|
@ -358,6 +362,22 @@ nsNativeDragTarget::DragLeave()
|
|||
return S_OK;
|
||||
}
|
||||
|
||||
void
|
||||
nsNativeDragTarget::DragCancel()
|
||||
{
|
||||
if (mDropTargetHelper) {
|
||||
mDropTargetHelper->DragLeave();
|
||||
}
|
||||
if (mDragService) {
|
||||
mDragService->EndDragSession(PR_FALSE);
|
||||
}
|
||||
// release the ref that we might have taken in DragEnter
|
||||
if (mTookOwnRef) {
|
||||
this->Release();
|
||||
mTookOwnRef = PR_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
STDMETHODIMP
|
||||
nsNativeDragTarget::Drop(LPDATAOBJECT pData,
|
||||
DWORD grfKeyState,
|
||||
|
|
|
@ -95,8 +95,10 @@ public:
|
|||
// E_FAIL.
|
||||
STDMETHODIMP Drop(LPDATAOBJECT pSource, DWORD grfKeyState,
|
||||
POINTL point, DWORD* pEffect);
|
||||
|
||||
PRBool mDragCancelled;
|
||||
/**
|
||||
* Cancel the current drag session, if any.
|
||||
*/
|
||||
void DragCancel();
|
||||
|
||||
protected:
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
* Masayuki Nakano <masayuki@d-toybox.com>
|
||||
* Dainis Jonitis <Dainis_Jonitis@swh-t.lv>
|
||||
* Christian Biesinger <cbiesinger@web.de>
|
||||
* Mats Palmgren <mats.palmgren@bredband.net>
|
||||
* Mats Palmgren <matspal@gmail.com>
|
||||
* Ningjie Chen <chenn@email.uc.edu>
|
||||
* Jim Mathies <jmathies@mozilla.com>
|
||||
* Kyle Huey <me@kylehuey.com>
|
||||
|
@ -523,10 +523,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) {
|
||||
|
@ -983,6 +985,8 @@ BOOL nsWindow::SetNSWindowPtr(HWND aWnd, nsWindow * ptr)
|
|||
// Get and set parent widgets
|
||||
NS_IMETHODIMP nsWindow::SetParent(nsIWidget *aNewParent)
|
||||
{
|
||||
mParent = aNewParent;
|
||||
|
||||
if (aNewParent) {
|
||||
nsCOMPtr<nsIWidget> kungFuDeathGrip(this);
|
||||
|
||||
|
@ -2712,6 +2716,8 @@ nsIntPoint nsWindow::WidgetToScreenOffset()
|
|||
#if !defined(WINCE) // implemented in nsWindowCE.cpp
|
||||
NS_METHOD nsWindow::EnableDragDrop(PRBool aEnable)
|
||||
{
|
||||
NS_ASSERTION(mWnd, "nsWindow::EnableDragDrop() called after Destroy()");
|
||||
|
||||
nsresult rv = NS_ERROR_FAILURE;
|
||||
if (aEnable) {
|
||||
if (nsnull == mNativeDragTarget) {
|
||||
|
@ -2731,7 +2737,7 @@ NS_METHOD nsWindow::EnableDragDrop(PRBool aEnable)
|
|||
if (S_OK == ::CoLockObjectExternal((LPUNKNOWN)mNativeDragTarget, FALSE, TRUE)) {
|
||||
rv = NS_OK;
|
||||
}
|
||||
mNativeDragTarget->mDragCancelled = PR_TRUE;
|
||||
mNativeDragTarget->DragCancel();
|
||||
NS_RELEASE(mNativeDragTarget);
|
||||
}
|
||||
}
|
||||
|
@ -6226,6 +6232,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);
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
* Masayuki Nakano <masayuki@d-toybox.com>
|
||||
* Ningjie Chen <chenn@email.uc.edu>
|
||||
* Jim Mathies <jmathies@mozilla.com>.
|
||||
* Mats Palmgren <matspal@gmail.com>
|
||||
*
|
||||
* 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
|
||||
|
@ -424,6 +425,7 @@ protected:
|
|||
#endif // ACCESSIBILITY
|
||||
|
||||
protected:
|
||||
nsCOMPtr<nsIWidget> mParent;
|
||||
nsIntSize mLastSize;
|
||||
nsIntPoint mLastPoint;
|
||||
HWND mWnd;
|
||||
|
|
|
@ -538,6 +538,7 @@ NS_IMETHODIMP nsXULWindow::Destroy()
|
|||
}
|
||||
if (mWindow) {
|
||||
mWindow->SetClientData(0); // nsWebShellWindow hackery
|
||||
mWindow->Destroy();
|
||||
mWindow = nsnull;
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче