From 3d9664eaf8fb85e27d63991b823767edc8667674 Mon Sep 17 00:00:00 2001 From: "bugzilla%standard8.demon.co.uk" Date: Fri, 12 May 2006 16:30:53 +0000 Subject: [PATCH] Bug 336241 canDrop isn't called when just the drag and drop action changes. r=Neil,sr=roc --- .../xul/base/src/tree/src/nsTreeBodyFrame.cpp | 19 ++++++++++++++++--- .../xul/base/src/tree/src/nsTreeBodyFrame.h | 4 ++++ 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/layout/xul/base/src/tree/src/nsTreeBodyFrame.cpp b/layout/xul/base/src/tree/src/nsTreeBodyFrame.cpp index ffe39009b47f..757cb89f20ea 100644 --- a/layout/xul/base/src/tree/src/nsTreeBodyFrame.cpp +++ b/layout/xul/base/src/tree/src/nsTreeBodyFrame.cpp @@ -30,6 +30,7 @@ * Pierre Chanial * Rene Pronk * Nate Nielsen + * Mark Banner * * Alternatively, the contents of this file may be used under the terms of * either of the GNU General Public License Version 2 or later (the "GPL"), @@ -2167,9 +2168,13 @@ nsTreeBodyFrame::HandleEvent(nsPresContext* aPresContext, // Cache the drag session. nsCOMPtr dragService = do_GetService("@mozilla.org/widget/dragservice;1"); - nsCOMPtr dragSession; dragService->GetCurrentSession(getter_AddRefs(mSlots->mDragSession)); NS_ASSERTION(mSlots->mDragSession, "can't get drag session"); + + if (mSlots->mDragSession) + mSlots->mDragSession->GetDragAction(&mSlots->mDragAction); + else + mSlots->mDragAction = 0; } else if (aEvent->message == NS_DRAGDROP_OVER) { // The mouse is hovering over this tree. If we determine things are @@ -2189,6 +2194,11 @@ nsTreeBodyFrame::HandleEvent(nsPresContext* aPresContext, PRInt16 lastDropOrient = mSlots->mDropOrient; PRInt16 lastScrollLines = mSlots->mScrollLines; + // Find out the current drag action + PRUint32 lastDragAction = mSlots->mDragAction; + if (mSlots->mDragSession) + mSlots->mDragSession->GetDragAction(&mSlots->mDragAction); + // Compute the row mouse is over and the above/below/on state. // Below we'll use this to see if anything changed. // Also check if we want to auto-scroll. @@ -2223,7 +2233,10 @@ nsTreeBodyFrame::HandleEvent(nsPresContext* aPresContext, // If changed from last time, invalidate primary cell at the old location and if allowed, // invalidate primary cell at the new location. If nothing changed, just bail. - if (mSlots->mDropRow != lastDropRow || mSlots->mDropOrient != lastDropOrient) { + if (mSlots->mDropRow != lastDropRow || + mSlots->mDropOrient != lastDropOrient || + mSlots->mDragAction != lastDragAction) { + // Invalidate row at the old location. if (mSlots->mDropAllowed) { mSlots->mDropAllowed = PR_FALSE; @@ -2264,7 +2277,7 @@ nsTreeBodyFrame::HandleEvent(nsPresContext* aPresContext, } } } - + // Alert the drag session we accept the drop. We have to do this every time // since the |canDrop| attribute is reset before we're called. if (mSlots->mDropAllowed && mSlots->mDragSession) diff --git a/layout/xul/base/src/tree/src/nsTreeBodyFrame.h b/layout/xul/base/src/tree/src/nsTreeBodyFrame.h index 4ac410b8b068..a31d0b3c3bc8 100644 --- a/layout/xul/base/src/tree/src/nsTreeBodyFrame.h +++ b/layout/xul/base/src/tree/src/nsTreeBodyFrame.h @@ -25,6 +25,7 @@ * Brian Ryner * Jan Varga * Nate Nielsen + * Mark Banner * * Alternatively, the contents of this file may be used under the terms of * either of the GNU General Public License Version 2 or later (the "GPL"), @@ -446,6 +447,9 @@ protected: // Data Members // Number of lines to be scrolled. PRInt16 mScrollLines; + // The drag action that was received for this slot + PRUint32 mDragAction; + nsCOMPtr mDragSession; // Timer for opening/closing spring loaded folders or scrolling the tree.