Make drag-n-drop of frame-less content work again. b=289667 r+sr=roc a=benjamin

git-svn-id: svn://10.0.0.236/trunk@175262 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
mats.palmgren%bredband.net
2005-06-28 21:40:15 +00:00
parent 515b074503
commit 74ac88465a
3 changed files with 29 additions and 10 deletions

View File

@@ -1214,7 +1214,7 @@ nsEventStateManager::FireContextClick()
// event and it will get reset on the very next event to the correct frame).
mCurrentTarget = nsnull;
if ( mGestureDownContent ) {
mPresContext->GetPresShell()->GetPrimaryFrameFor(mGestureDownContent,
mPresContext->GetPresShell()->GetPrimaryFrameFor(mGestureDownFrameOwner,
&mCurrentTarget);
if ( mCurrentTarget ) {
@@ -1293,8 +1293,9 @@ nsEventStateManager::FireContextClick()
}
// now check if the event has been handled. If so, stop tracking a drag
if ( status == nsEventStatus_eConsumeNoDefault )
if ( status == nsEventStatus_eConsumeNoDefault ) {
StopTrackingDragGesture();
}
KillClickHoldTimer();
@@ -1330,6 +1331,7 @@ nsEventStateManager::BeginTrackingDragGesture(nsPresContext* aPresContext,
inDownFrame->GetContentForEvent(aPresContext, inDownEvent,
getter_AddRefs(mGestureDownContent));
mGestureDownFrameOwner = inDownFrame->GetContent();
mGestureDownShift = inDownEvent->isShift;
mGestureDownControl = inDownEvent->isControl;
mGestureDownAlt = inDownEvent->isAlt;
@@ -1352,6 +1354,7 @@ void
nsEventStateManager::StopTrackingDragGesture()
{
mGestureDownContent = nsnull;
mGestureDownFrameOwner = nsnull;
}
@@ -1448,7 +1451,7 @@ nsEventStateManager::GenerateDragGesture(nsPresContext* aPresContext,
{
NS_WARN_IF_FALSE(aPresContext, "This shouldn't happen.");
if ( IsTrackingDragGesture() ) {
aPresContext->GetPresShell()->GetPrimaryFrameFor(mGestureDownContent,
aPresContext->GetPresShell()->GetPrimaryFrameFor(mGestureDownFrameOwner,
&mCurrentTarget);
if (!mCurrentTarget) {
StopTrackingDragGesture();

View File

@@ -20,6 +20,7 @@
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Mats Palmgren <mats.palmgren@bredband.net>
*
* 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"),
@@ -290,7 +291,12 @@ protected:
// member variables for the d&d gesture state machine
nsPoint mGestureDownPoint; // screen coordinates
// The content to use as target if we start a d&d (what we drag).
nsCOMPtr<nsIContent> mGestureDownContent;
// The content of the frame where the mouse-down event occurred. It's the same
// as the target in most cases but not always - for example when dragging
// an <area> of an image map this is the image. (bug 289667)
nsCOMPtr<nsIContent> mGestureDownFrameOwner;
// State of keys when the original gesture-down happened
PRPackedBool mGestureDownShift;
PRPackedBool mGestureDownControl;

View File

@@ -50,6 +50,7 @@
#include "nsIDocument.h"
#include "nsIContent.h"
#include "nsIPresShell.h"
#include "nsIViewManager.h"
#include "nsIDOMNode.h"
#include "nsPresContext.h"
@@ -208,13 +209,22 @@ nsBaseDragService::InvokeDragSession(nsIDOMNode *aDOMNode,
// When the mouse goes down, the selection code starts a mouse
// capture. However, this gets in the way of determining drag
// feedback for things like trees because the event coordinates
// are in the wrong coord system. Turn off capture by getting the
// frame associated with the DOM Node.
nsIFrame* dragFrame = nsnull;
nsCOMPtr<nsPresContext> context;
GetFrameFromNode(aDOMNode, &dragFrame, getter_AddRefs(context));
if (dragFrame && context)
dragFrame->CaptureMouse(context, PR_FALSE);
// are in the wrong coord system. Turn off mouse capture in
// the associated view manager.
nsCOMPtr<nsIContent> contentNode = do_QueryInterface(aDOMNode);
if (contentNode) {
nsIDocument* doc = contentNode->GetCurrentDoc();
if (doc) {
nsIPresShell* presShell = doc->GetShellAt(0);
if (presShell) {
nsIViewManager* vm = presShell->GetViewManager();
if (vm) {
PRBool notUsed;
vm->GrabMouseEvents(nsnull, notUsed);
}
}
}
}
return NS_OK;
}