From 1089ca4946fcb8875f4aff00eebb22b6cb24ed33 Mon Sep 17 00:00:00 2001 From: Masayuki Nakano Date: Mon, 11 Jul 2011 13:20:46 +0900 Subject: [PATCH] Bug 670058 Stop drag handling for selection when the dragging frame selection detaches presShell r=smaug --- layout/generic/nsFrameSelection.h | 11 ++++++++++- layout/generic/nsSelection.cpp | 20 +++++++++++++++++++- 2 files changed, 29 insertions(+), 2 deletions(-) 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 {