diff --git a/mozilla/content/events/src/nsEventStateManager.cpp b/mozilla/content/events/src/nsEventStateManager.cpp index bcf88123cb3..b717fffddd0 100644 --- a/mozilla/content/events/src/nsEventStateManager.cpp +++ b/mozilla/content/events/src/nsEventStateManager.cpp @@ -690,17 +690,30 @@ nsEventStateManager :: GenerateDragGesture ( nsIPresContext* aPresContext, nsGUI // Check if selection is tracking drag gestures, if so // don't interfere! - nsCOMPtr shell; - nsresult rv = aPresContext->GetShell(getter_AddRefs(shell)); - if (NS_SUCCEEDED(rv) && shell){ - nsCOMPtr frameSel; - rv = shell->GetFrameSelection(getter_AddRefs(frameSel)); - if (NS_SUCCEEDED(rv) && frameSel){ - PRBool mouseDownState = PR_TRUE; - frameSel->GetMouseDownState(&mouseDownState); - if (mouseDownState) { - StopTrackingDragGesture(); - return; + if (mGestureDownFrame) { + nsCOMPtr selCon; + nsresult rv = mGestureDownFrame->GetSelectionController(aPresContext, getter_AddRefs(selCon)); + + if (NS_SUCCEEDED(rv) && selCon) { + nsCOMPtr frameSel; + + frameSel = do_QueryInterface(selCon); + + if (! frameSel) { + nsCOMPtr shell; + nsresult rv = aPresContext->GetShell(getter_AddRefs(shell)); + + if (NS_SUCCEEDED(rv) && shell) + rv = shell->GetFrameSelection(getter_AddRefs(frameSel)); + } + + if (NS_SUCCEEDED(rv) && frameSel) { + PRBool mouseDownState = PR_TRUE; + frameSel->GetMouseDownState(&mouseDownState); + if (mouseDownState) { + StopTrackingDragGesture(); + return; + } } } } diff --git a/mozilla/layout/base/public/nsIFrame.h b/mozilla/layout/base/public/nsIFrame.h index b42ea25b309..c3a239f1d54 100644 --- a/mozilla/layout/base/public/nsIFrame.h +++ b/mozilla/layout/base/public/nsIFrame.h @@ -74,6 +74,7 @@ struct nsRect; struct nsStyleStruct; class nsIDOMRange; class nsICaret; +class nsISelectionController; struct PRLogModuleInfo; // IID for the nsIFrame interface @@ -971,6 +972,13 @@ public: NS_IMETHOD GetSelected(PRBool *aSelected) const = 0; + /** + * Called to retrieve the SelectionController associated with the frame. + * @param aSelCon will contain the selection controller associated with + * the frame. + */ + NS_IMETHOD GetSelectionController(nsIPresContext *aPresContext, nsISelectionController **aSelCon) = 0; + /** EndSelection related calls */ diff --git a/mozilla/layout/events/src/nsEventStateManager.cpp b/mozilla/layout/events/src/nsEventStateManager.cpp index bcf88123cb3..b717fffddd0 100644 --- a/mozilla/layout/events/src/nsEventStateManager.cpp +++ b/mozilla/layout/events/src/nsEventStateManager.cpp @@ -690,17 +690,30 @@ nsEventStateManager :: GenerateDragGesture ( nsIPresContext* aPresContext, nsGUI // Check if selection is tracking drag gestures, if so // don't interfere! - nsCOMPtr shell; - nsresult rv = aPresContext->GetShell(getter_AddRefs(shell)); - if (NS_SUCCEEDED(rv) && shell){ - nsCOMPtr frameSel; - rv = shell->GetFrameSelection(getter_AddRefs(frameSel)); - if (NS_SUCCEEDED(rv) && frameSel){ - PRBool mouseDownState = PR_TRUE; - frameSel->GetMouseDownState(&mouseDownState); - if (mouseDownState) { - StopTrackingDragGesture(); - return; + if (mGestureDownFrame) { + nsCOMPtr selCon; + nsresult rv = mGestureDownFrame->GetSelectionController(aPresContext, getter_AddRefs(selCon)); + + if (NS_SUCCEEDED(rv) && selCon) { + nsCOMPtr frameSel; + + frameSel = do_QueryInterface(selCon); + + if (! frameSel) { + nsCOMPtr shell; + nsresult rv = aPresContext->GetShell(getter_AddRefs(shell)); + + if (NS_SUCCEEDED(rv) && shell) + rv = shell->GetFrameSelection(getter_AddRefs(frameSel)); + } + + if (NS_SUCCEEDED(rv) && frameSel) { + PRBool mouseDownState = PR_TRUE; + frameSel->GetMouseDownState(&mouseDownState); + if (mouseDownState) { + StopTrackingDragGesture(); + return; + } } } } diff --git a/mozilla/layout/generic/nsFrame.cpp b/mozilla/layout/generic/nsFrame.cpp index d734237a739..954a7da16ab 100644 --- a/mozilla/layout/generic/nsFrame.cpp +++ b/mozilla/layout/generic/nsFrame.cpp @@ -2166,7 +2166,7 @@ nsFrame::ParentDisablesSelection() const -nsresult +NS_IMETHODIMP nsFrame::GetSelectionController(nsIPresContext *aPresContext, nsISelectionController **aSelCon) { if (!aPresContext || !aSelCon) diff --git a/mozilla/layout/generic/nsFrame.h b/mozilla/layout/generic/nsFrame.h index 9acd2849826..7c4d36752ce 100644 --- a/mozilla/layout/generic/nsFrame.h +++ b/mozilla/layout/generic/nsFrame.h @@ -262,6 +262,7 @@ public: #endif NS_IMETHOD SetSelected(nsIPresContext* aPresContext, nsIDOMRange *aRange,PRBool aSelected, nsSpread aSpread); NS_IMETHOD GetSelected(PRBool *aSelected) const; + NS_IMETHOD GetSelectionController(nsIPresContext *aPresContext, nsISelectionController **aSelCon); NS_IMETHOD PeekOffset(nsIPresContext* aPresContext, nsPeekOffsetStruct *aPos) ; NS_IMETHOD PeekOffsetParagraph(nsIPresContext* aPresContext, nsPeekOffsetStruct *aPos); @@ -439,8 +440,6 @@ protected: // applies to its situation. void SetOverflowClipRect(nsIRenderingContext& aRenderingContext); - NS_IMETHOD GetSelectionController(nsIPresContext *aPresContext, nsISelectionController **aSelCon); - nsRect mRect; nsIContent* mContent; nsIStyleContext* mStyleContext; diff --git a/mozilla/layout/generic/nsIFrame.h b/mozilla/layout/generic/nsIFrame.h index b42ea25b309..c3a239f1d54 100644 --- a/mozilla/layout/generic/nsIFrame.h +++ b/mozilla/layout/generic/nsIFrame.h @@ -74,6 +74,7 @@ struct nsRect; struct nsStyleStruct; class nsIDOMRange; class nsICaret; +class nsISelectionController; struct PRLogModuleInfo; // IID for the nsIFrame interface @@ -971,6 +972,13 @@ public: NS_IMETHOD GetSelected(PRBool *aSelected) const = 0; + /** + * Called to retrieve the SelectionController associated with the frame. + * @param aSelCon will contain the selection controller associated with + * the frame. + */ + NS_IMETHOD GetSelectionController(nsIPresContext *aPresContext, nsISelectionController **aSelCon) = 0; + /** EndSelection related calls */ diff --git a/mozilla/layout/html/base/src/nsFrame.cpp b/mozilla/layout/html/base/src/nsFrame.cpp index d734237a739..954a7da16ab 100644 --- a/mozilla/layout/html/base/src/nsFrame.cpp +++ b/mozilla/layout/html/base/src/nsFrame.cpp @@ -2166,7 +2166,7 @@ nsFrame::ParentDisablesSelection() const -nsresult +NS_IMETHODIMP nsFrame::GetSelectionController(nsIPresContext *aPresContext, nsISelectionController **aSelCon) { if (!aPresContext || !aSelCon) diff --git a/mozilla/layout/html/base/src/nsFrame.h b/mozilla/layout/html/base/src/nsFrame.h index 9acd2849826..7c4d36752ce 100644 --- a/mozilla/layout/html/base/src/nsFrame.h +++ b/mozilla/layout/html/base/src/nsFrame.h @@ -262,6 +262,7 @@ public: #endif NS_IMETHOD SetSelected(nsIPresContext* aPresContext, nsIDOMRange *aRange,PRBool aSelected, nsSpread aSpread); NS_IMETHOD GetSelected(PRBool *aSelected) const; + NS_IMETHOD GetSelectionController(nsIPresContext *aPresContext, nsISelectionController **aSelCon); NS_IMETHOD PeekOffset(nsIPresContext* aPresContext, nsPeekOffsetStruct *aPos) ; NS_IMETHOD PeekOffsetParagraph(nsIPresContext* aPresContext, nsPeekOffsetStruct *aPos); @@ -439,8 +440,6 @@ protected: // applies to its situation. void SetOverflowClipRect(nsIRenderingContext& aRenderingContext); - NS_IMETHOD GetSelectionController(nsIPresContext *aPresContext, nsISelectionController **aSelCon); - nsRect mRect; nsIContent* mContent; nsIStyleContext* mStyleContext;