diff --git a/layout/generic/nsFrameSelection.h b/layout/generic/nsFrameSelection.h index 245e99a2617..5852e5e9a8b 100644 --- a/layout/generic/nsFrameSelection.h +++ b/layout/generic/nsFrameSelection.h @@ -378,6 +378,11 @@ public: return sDraggingFrameSelection; } + /** + * Call AbortDragForSelection() when we abort handling the drag as selecting. + */ + void AbortDragForSelection(); + /** if we are in table cell selection mode. aka ctrl click in table cell */ @@ -616,7 +621,11 @@ public: nsIPresShell *GetShell()const { return mShell; } - void DisconnectFromPresShell() { StopAutoScrollTimer(); mShell = nsnull; } + void DisconnectFromPresShell() + { + AbortDragForSelection(); + mShell = nsnull; + } private: nsresult TakeFocus(nsIContent *aNewFocus, PRUint32 aContentOffset, diff --git a/layout/generic/nsSelection.cpp b/layout/generic/nsSelection.cpp index ba07eca956b..6a030782321 100644 --- a/layout/generic/nsSelection.cpp +++ b/layout/generic/nsSelection.cpp @@ -1927,15 +1927,33 @@ nsFrameSelection::SetMouseDownState(PRBool aState) mMouseDownState = aState; if (mMouseDownState) { + if (sDraggingFrameSelection) { + sDraggingFrameSelection->AbortDragForSelection(); + } sDraggingFrameSelection = this; } else { - sDraggingFrameSelection = nsnull; + if (sDraggingFrameSelection == this) { + sDraggingFrameSelection = nsnull; + } mDragSelectingCells = PR_FALSE; PostReason(nsISelectionListener::MOUSEUP_REASON); NotifySelectionListeners(nsISelectionController::SELECTION_NORMAL); //notify that reason is mouse up please. } } +void +nsFrameSelection::AbortDragForSelection() +{ + if (sDraggingFrameSelection == this) { + sDraggingFrameSelection = nsnull; + mMouseDownState = PR_FALSE; + mDragSelectingCells = PR_FALSE; + PostReason(nsISelectionListener::NO_REASON); + NotifySelectionListeners(nsISelectionController::SELECTION_NORMAL); + } + StopAutoScrollTimer(); +} + nsISelection* nsFrameSelection::GetSelection(SelectionType aType) const {