Bug 670058 Stop drag handling for selection when the dragging frame selection detaches presShell r=smaug

This commit is contained in:
Masayuki Nakano
2011-07-11 13:20:46 +09:00
parent 6b087db789
commit 58c5291d47
2 changed files with 29 additions and 2 deletions

View File

@@ -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,

View File

@@ -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
{