From 1739a10bbde4b58283697f5be3d26c97ebfcd0f4 Mon Sep 17 00:00:00 2001 From: "kin%netscape.com" Date: Wed, 31 May 2000 03:20:02 +0000 Subject: [PATCH] Part2 of fix for bug #39821: Drag and Drop interferes with selection Made GetSelectionController() a public method on the nsIFrame interface, so that nsEventStateManager::GenerateDragGesture() has access to it. This prevents D&D from interfering with selection in Ender-Lite. layout/base/public/nsIFrame.h layout/events/src/nsEventStateManager.cpp layout/html/base/src/nsFrame.h layout/html/base/src/nsFrame.cpp r=buster@netscape.com,brade@netscape.com,cmanske@netscape.com a=beppe@netscape.com --- content/events/src/nsEventStateManager.cpp | 35 +++++++++++++++------- layout/base/public/nsIFrame.h | 8 +++++ layout/events/src/nsEventStateManager.cpp | 35 +++++++++++++++------- layout/generic/nsFrame.cpp | 2 +- layout/generic/nsFrame.h | 3 +- layout/generic/nsIFrame.h | 8 +++++ layout/html/base/src/nsFrame.cpp | 2 +- layout/html/base/src/nsFrame.h | 3 +- 8 files changed, 68 insertions(+), 28 deletions(-) diff --git a/content/events/src/nsEventStateManager.cpp b/content/events/src/nsEventStateManager.cpp index bcf88123cb3b..b717fffddd0b 100644 --- a/content/events/src/nsEventStateManager.cpp +++ b/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/layout/base/public/nsIFrame.h b/layout/base/public/nsIFrame.h index b42ea25b3099..c3a239f1d54f 100644 --- a/layout/base/public/nsIFrame.h +++ b/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/layout/events/src/nsEventStateManager.cpp b/layout/events/src/nsEventStateManager.cpp index bcf88123cb3b..b717fffddd0b 100644 --- a/layout/events/src/nsEventStateManager.cpp +++ b/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/layout/generic/nsFrame.cpp b/layout/generic/nsFrame.cpp index d734237a7393..954a7da16ab0 100644 --- a/layout/generic/nsFrame.cpp +++ b/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/layout/generic/nsFrame.h b/layout/generic/nsFrame.h index 9acd2849826f..7c4d36752ce3 100644 --- a/layout/generic/nsFrame.h +++ b/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/layout/generic/nsIFrame.h b/layout/generic/nsIFrame.h index b42ea25b3099..c3a239f1d54f 100644 --- a/layout/generic/nsIFrame.h +++ b/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/layout/html/base/src/nsFrame.cpp b/layout/html/base/src/nsFrame.cpp index d734237a7393..954a7da16ab0 100644 --- a/layout/html/base/src/nsFrame.cpp +++ b/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/layout/html/base/src/nsFrame.h b/layout/html/base/src/nsFrame.h index 9acd2849826f..7c4d36752ce3 100644 --- a/layout/html/base/src/nsFrame.h +++ b/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;