зеркало из https://github.com/mozilla/gecko-dev.git
Fix bug 200745 -- we were using the wrong event coords to start a drag. Fix the ESM to use the coords of the mouse down, not the mouse move, so that dragging small objects is easier. r=jkeiser, sr=bryner.
This commit is contained in:
Родитель
b2460d9842
Коммит
100bc42605
|
@ -153,6 +153,7 @@ enum {
|
||||||
|
|
||||||
nsEventStateManager::nsEventStateManager()
|
nsEventStateManager::nsEventStateManager()
|
||||||
: mGestureDownPoint(0,0),
|
: mGestureDownPoint(0,0),
|
||||||
|
mGestureDownRefPoint(0,0),
|
||||||
mCurrentFocusFrame(nsnull),
|
mCurrentFocusFrame(nsnull),
|
||||||
m_haveShutdown(PR_FALSE),
|
m_haveShutdown(PR_FALSE),
|
||||||
mClearedFrameRefsDuringEvent(PR_FALSE),
|
mClearedFrameRefsDuringEvent(PR_FALSE),
|
||||||
|
@ -1296,6 +1297,7 @@ nsEventStateManager :: BeginTrackingDragGesture ( nsIPresContext* aPresContext,
|
||||||
{
|
{
|
||||||
mIsTrackingDragGesture = PR_TRUE;
|
mIsTrackingDragGesture = PR_TRUE;
|
||||||
mGestureDownPoint = inDownEvent->point;
|
mGestureDownPoint = inDownEvent->point;
|
||||||
|
mGestureDownRefPoint = inDownEvent->refPoint;
|
||||||
mGestureDownFrame = inDownFrame;
|
mGestureDownFrame = inDownFrame;
|
||||||
|
|
||||||
#ifdef CLICK_HOLD_CONTEXT_MENUS
|
#ifdef CLICK_HOLD_CONTEXT_MENUS
|
||||||
|
@ -1317,6 +1319,7 @@ nsEventStateManager :: StopTrackingDragGesture ( )
|
||||||
{
|
{
|
||||||
mIsTrackingDragGesture = PR_FALSE;
|
mIsTrackingDragGesture = PR_FALSE;
|
||||||
mGestureDownPoint = nsPoint(0,0);
|
mGestureDownPoint = nsPoint(0,0);
|
||||||
|
mGestureDownRefPoint = nsPoint(0,0);
|
||||||
mGestureDownFrame = nsnull;
|
mGestureDownFrame = nsnull;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1411,14 +1414,21 @@ nsEventStateManager :: GenerateDragGesture ( nsIPresContext* aPresContext, nsGUI
|
||||||
KillClickHoldTimer();
|
KillClickHoldTimer();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// get the widget from the target frame
|
||||||
|
nsCOMPtr<nsIWidget> targetWidget;
|
||||||
|
mGestureDownFrame->GetWindow(aPresContext, getter_AddRefs(targetWidget));
|
||||||
|
|
||||||
nsEventStatus status = nsEventStatus_eIgnore;
|
nsEventStatus status = nsEventStatus_eIgnore;
|
||||||
nsMouseEvent event;
|
nsMouseEvent event;
|
||||||
event.eventStructType = NS_DRAGDROP_EVENT;
|
event.eventStructType = NS_DRAGDROP_EVENT;
|
||||||
event.message = NS_DRAGDROP_GESTURE;
|
event.message = NS_DRAGDROP_GESTURE;
|
||||||
event.widget = aEvent->widget;
|
event.widget = targetWidget;
|
||||||
event.clickCount = 0;
|
event.clickCount = 0;
|
||||||
event.point = aEvent->point;
|
event.point = mGestureDownPoint;
|
||||||
event.refPoint = aEvent->refPoint;
|
event.refPoint = mGestureDownRefPoint;
|
||||||
|
// ideally, we should get the modifiers from the original event too,
|
||||||
|
// but the drag code looks at modifiers at the end of the drag, so this
|
||||||
|
// is probably OK.
|
||||||
event.isShift = ((nsMouseEvent*)aEvent)->isShift;
|
event.isShift = ((nsMouseEvent*)aEvent)->isShift;
|
||||||
event.isControl = ((nsMouseEvent*)aEvent)->isControl;
|
event.isControl = ((nsMouseEvent*)aEvent)->isControl;
|
||||||
event.isAlt = ((nsMouseEvent*)aEvent)->isAlt;
|
event.isAlt = ((nsMouseEvent*)aEvent)->isAlt;
|
||||||
|
@ -1431,16 +1441,29 @@ nsEventStateManager :: GenerateDragGesture ( nsIPresContext* aPresContext, nsGUI
|
||||||
// when we're through because no one else is doing anything more with this
|
// when we're through because no one else is doing anything more with this
|
||||||
// event and it will get reset on the very next event to the correct frame).
|
// event and it will get reset on the very next event to the correct frame).
|
||||||
mCurrentTarget = mGestureDownFrame;
|
mCurrentTarget = mGestureDownFrame;
|
||||||
nsCOMPtr<nsIContent> lastContent;
|
|
||||||
if ( mGestureDownFrame ) {
|
if ( mGestureDownFrame ) {
|
||||||
mGestureDownFrame->GetContentForEvent(aPresContext, aEvent, getter_AddRefs(lastContent));
|
// Get the content for our synthesised event, not the mouse move event
|
||||||
|
nsCOMPtr<nsIContent> lastContent;
|
||||||
|
mGestureDownFrame->GetContentForEvent(aPresContext, &event, getter_AddRefs(lastContent));
|
||||||
|
|
||||||
|
// Hold onto old target content through the event and reset after.
|
||||||
|
nsCOMPtr<nsIContent> targetBeforeEvent = mCurrentTargetContent;
|
||||||
|
// Set the current target to the content for the mouse down
|
||||||
|
mCurrentTargetContent = lastContent;
|
||||||
|
|
||||||
|
// Dispatch to DOM
|
||||||
if ( lastContent )
|
if ( lastContent )
|
||||||
lastContent->HandleDOMEvent(aPresContext, &event, nsnull, NS_EVENT_FLAG_INIT, &status);
|
lastContent->HandleDOMEvent(aPresContext, &event, nsnull, NS_EVENT_FLAG_INIT, &status);
|
||||||
}
|
|
||||||
|
|
||||||
// dispatch to the frame
|
// Firing the DOM event could have caused mGestureDownFrame to
|
||||||
if ( mGestureDownFrame )
|
// be destroyed. So, null-check it again.
|
||||||
mGestureDownFrame->HandleEvent(aPresContext, &event, &status);
|
if ( mGestureDownFrame )
|
||||||
|
mGestureDownFrame->HandleEvent(aPresContext, &event, &status);
|
||||||
|
|
||||||
|
// Reset mCurretTargetContent to what it was
|
||||||
|
mCurrentTargetContent = targetBeforeEvent;
|
||||||
|
}
|
||||||
|
|
||||||
StopTrackingDragGesture();
|
StopTrackingDragGesture();
|
||||||
}
|
}
|
||||||
|
|
|
@ -259,6 +259,7 @@ protected:
|
||||||
// member variables for the d&d gesture state machine
|
// member variables for the d&d gesture state machine
|
||||||
PRBool mIsTrackingDragGesture;
|
PRBool mIsTrackingDragGesture;
|
||||||
nsPoint mGestureDownPoint;
|
nsPoint mGestureDownPoint;
|
||||||
|
nsPoint mGestureDownRefPoint;
|
||||||
nsIFrame* mGestureDownFrame;
|
nsIFrame* mGestureDownFrame;
|
||||||
|
|
||||||
nsCOMPtr<nsIContent> mLastLeftMouseDownContent;
|
nsCOMPtr<nsIContent> mLastLeftMouseDownContent;
|
||||||
|
|
Загрузка…
Ссылка в новой задаче