diff --git a/mozilla/content/base/src/nsDocumentViewer.cpp b/mozilla/content/base/src/nsDocumentViewer.cpp index 6af9db9f62d..fa6b6e1558f 100644 --- a/mozilla/content/base/src/nsDocumentViewer.cpp +++ b/mozilla/content/base/src/nsDocumentViewer.cpp @@ -377,6 +377,13 @@ DocumentViewerImpl::~DocumentViewerImpl() if (mPresShell) { // Break circular reference (or something) mPresShell->EndObservingDocument(); + nsCOMPtr selection; + nsresult rv; + rv = GetDocumentSelection(getter_AddRefs(selection)); + if (NS_FAILED(rv) || !selection) + return; + if (mSelectionListener) + selection->RemoveSelectionListener(mSelectionListener); } } @@ -1661,7 +1668,7 @@ nsresult nsDocViwerSelectionListener::Init(DocumentViewerImpl *aDocViewer) } -NS_IMETHODIMP nsDocViwerSelectionListener::NotifySelectionChanged(nsIDOMDocument *, nsIDOMSelection *) +NS_IMETHODIMP nsDocViwerSelectionListener::NotifySelectionChanged(nsIDOMDocument *, nsIDOMSelection *, short) { NS_ASSERTION(mDocViewer, "Should have doc viewer!"); diff --git a/mozilla/content/base/src/nsSelection.cpp b/mozilla/content/base/src/nsSelection.cpp index 2489ee9b9c1..017047b67b3 100644 --- a/mozilla/content/base/src/nsSelection.cpp +++ b/mozilla/content/base/src/nsSelection.cpp @@ -1681,6 +1681,7 @@ nsSelection::SetMouseDownState(PRBool aState) mSelectingTableCells = PR_FALSE; mStartSelectedCell = nsnull; mEndSelectedCell = nsnull; + NotifySelectionListeners(SELECTION_NORMAL); } return NS_OK; } @@ -1999,7 +2000,7 @@ nsSelection::NotifySelectionListeners(SelectionType aType) nsCOMPtr isupports(dont_AddRef(mSelectionListeners->ElementAt(i))); nsCOMPtr thisListener = do_QueryInterface(isupports); if (thisListener) - thisListener->NotifySelectionChanged(domdoc,mDomSelections[idx]); + thisListener->NotifySelectionChanged(domdoc,mDomSelections[idx], (short) mMouseDownState); } return NS_OK; } diff --git a/mozilla/layout/base/nsAutoCopy.cpp b/mozilla/layout/base/nsAutoCopy.cpp index 9b91c26f857..48ca5d8a7ad 100644 --- a/mozilla/layout/base/nsAutoCopy.cpp +++ b/mozilla/layout/base/nsAutoCopy.cpp @@ -49,7 +49,7 @@ public: //end nsIAutoCopyService //nsIDOMSelectionListener interfaces - NS_IMETHOD NotifySelectionChanged(nsIDOMDocument *aDoc, nsIDOMSelection *aSel); + NS_IMETHOD NotifySelectionChanged(nsIDOMDocument *aDoc, nsIDOMSelection *aSel, short aReason); //end nsIDOMSelectionListener protected: nsCOMPtr mClipboard; @@ -109,8 +109,11 @@ nsAutoCopyService::Listen(nsIDOMSelection *aDomSelection) * - maybe we should just never clear the X clipboard? That would make this * problem just go away, which is very tempting. */ + +#define DRAGGING 1 + NS_IMETHODIMP -nsAutoCopyService::NotifySelectionChanged(nsIDOMDocument *aDoc, nsIDOMSelection *aSel) +nsAutoCopyService::NotifySelectionChanged(nsIDOMDocument *aDoc, nsIDOMSelection *aSel, short aReason) { nsresult rv; @@ -120,7 +123,8 @@ nsAutoCopyService::NotifySelectionChanged(nsIDOMDocument *aDoc, nsIDOMSelection if (NS_FAILED(rv)) return rv; } - + if (DRAGGING == aReason) + return NS_OK;//dont care if we are still dragging. PRBool collapsed; if (!aDoc || !aSel || NS_FAILED(aSel->GetIsCollapsed(&collapsed)) || collapsed) { #ifdef DEBUG_CLIPBOARD diff --git a/mozilla/layout/base/nsCaret.cpp b/mozilla/layout/base/nsCaret.cpp index ac4271f50f3..2686dca4c09 100644 --- a/mozilla/layout/base/nsCaret.cpp +++ b/mozilla/layout/base/nsCaret.cpp @@ -308,7 +308,7 @@ NS_IMETHODIMP nsCaret::ClearFrameRefs(nsIFrame* aFrame) #endif //----------------------------------------------------------------------------- -NS_IMETHODIMP nsCaret::NotifySelectionChanged(nsIDOMDocument *, nsIDOMSelection *) +NS_IMETHODIMP nsCaret::NotifySelectionChanged(nsIDOMDocument *, nsIDOMSelection *, short) { if (mVisible) @@ -596,6 +596,7 @@ void nsCaret::DrawCaretWithContext(nsIRenderingContext* inRendContext) mLastCaretFrame->GetPointFromOffset(presContext, localRC, mLastContentOffset, &framePos); caretRect += framePos; + //printf("Content offset %ld, frame offset %ld\n", focusOffset, framePos.x); diff --git a/mozilla/layout/base/nsCaret.h b/mozilla/layout/base/nsCaret.h index 3df76ea7d51..f2aa093d8fa 100644 --- a/mozilla/layout/base/nsCaret.h +++ b/mozilla/layout/base/nsCaret.h @@ -57,7 +57,7 @@ class nsCaret : public nsICaret, NS_IMETHOD ClearFrameRefs(nsIFrame* aFrame); //nsIDOMSelectionListener interface - NS_IMETHOD NotifySelectionChanged(nsIDOMDocument *aDoc, nsIDOMSelection *aSel); + NS_IMETHOD NotifySelectionChanged(nsIDOMDocument *aDoc, nsIDOMSelection *aSel, short aReason); static void CaretBlinkCallback(nsITimer *aTimer, void *aClosure); diff --git a/mozilla/layout/base/nsDocumentViewer.cpp b/mozilla/layout/base/nsDocumentViewer.cpp index 6af9db9f62d..fa6b6e1558f 100644 --- a/mozilla/layout/base/nsDocumentViewer.cpp +++ b/mozilla/layout/base/nsDocumentViewer.cpp @@ -377,6 +377,13 @@ DocumentViewerImpl::~DocumentViewerImpl() if (mPresShell) { // Break circular reference (or something) mPresShell->EndObservingDocument(); + nsCOMPtr selection; + nsresult rv; + rv = GetDocumentSelection(getter_AddRefs(selection)); + if (NS_FAILED(rv) || !selection) + return; + if (mSelectionListener) + selection->RemoveSelectionListener(mSelectionListener); } } @@ -1661,7 +1668,7 @@ nsresult nsDocViwerSelectionListener::Init(DocumentViewerImpl *aDocViewer) } -NS_IMETHODIMP nsDocViwerSelectionListener::NotifySelectionChanged(nsIDOMDocument *, nsIDOMSelection *) +NS_IMETHODIMP nsDocViwerSelectionListener::NotifySelectionChanged(nsIDOMDocument *, nsIDOMSelection *, short) { NS_ASSERTION(mDocViewer, "Should have doc viewer!"); diff --git a/mozilla/layout/base/src/nsAutoCopy.cpp b/mozilla/layout/base/src/nsAutoCopy.cpp index 9b91c26f857..48ca5d8a7ad 100644 --- a/mozilla/layout/base/src/nsAutoCopy.cpp +++ b/mozilla/layout/base/src/nsAutoCopy.cpp @@ -49,7 +49,7 @@ public: //end nsIAutoCopyService //nsIDOMSelectionListener interfaces - NS_IMETHOD NotifySelectionChanged(nsIDOMDocument *aDoc, nsIDOMSelection *aSel); + NS_IMETHOD NotifySelectionChanged(nsIDOMDocument *aDoc, nsIDOMSelection *aSel, short aReason); //end nsIDOMSelectionListener protected: nsCOMPtr mClipboard; @@ -109,8 +109,11 @@ nsAutoCopyService::Listen(nsIDOMSelection *aDomSelection) * - maybe we should just never clear the X clipboard? That would make this * problem just go away, which is very tempting. */ + +#define DRAGGING 1 + NS_IMETHODIMP -nsAutoCopyService::NotifySelectionChanged(nsIDOMDocument *aDoc, nsIDOMSelection *aSel) +nsAutoCopyService::NotifySelectionChanged(nsIDOMDocument *aDoc, nsIDOMSelection *aSel, short aReason) { nsresult rv; @@ -120,7 +123,8 @@ nsAutoCopyService::NotifySelectionChanged(nsIDOMDocument *aDoc, nsIDOMSelection if (NS_FAILED(rv)) return rv; } - + if (DRAGGING == aReason) + return NS_OK;//dont care if we are still dragging. PRBool collapsed; if (!aDoc || !aSel || NS_FAILED(aSel->GetIsCollapsed(&collapsed)) || collapsed) { #ifdef DEBUG_CLIPBOARD diff --git a/mozilla/layout/base/src/nsCaret.cpp b/mozilla/layout/base/src/nsCaret.cpp index ac4271f50f3..2686dca4c09 100644 --- a/mozilla/layout/base/src/nsCaret.cpp +++ b/mozilla/layout/base/src/nsCaret.cpp @@ -308,7 +308,7 @@ NS_IMETHODIMP nsCaret::ClearFrameRefs(nsIFrame* aFrame) #endif //----------------------------------------------------------------------------- -NS_IMETHODIMP nsCaret::NotifySelectionChanged(nsIDOMDocument *, nsIDOMSelection *) +NS_IMETHODIMP nsCaret::NotifySelectionChanged(nsIDOMDocument *, nsIDOMSelection *, short) { if (mVisible) @@ -596,6 +596,7 @@ void nsCaret::DrawCaretWithContext(nsIRenderingContext* inRendContext) mLastCaretFrame->GetPointFromOffset(presContext, localRC, mLastContentOffset, &framePos); caretRect += framePos; + //printf("Content offset %ld, frame offset %ld\n", focusOffset, framePos.x); diff --git a/mozilla/layout/base/src/nsCaret.h b/mozilla/layout/base/src/nsCaret.h index 3df76ea7d51..f2aa093d8fa 100644 --- a/mozilla/layout/base/src/nsCaret.h +++ b/mozilla/layout/base/src/nsCaret.h @@ -57,7 +57,7 @@ class nsCaret : public nsICaret, NS_IMETHOD ClearFrameRefs(nsIFrame* aFrame); //nsIDOMSelectionListener interface - NS_IMETHOD NotifySelectionChanged(nsIDOMDocument *aDoc, nsIDOMSelection *aSel); + NS_IMETHOD NotifySelectionChanged(nsIDOMDocument *aDoc, nsIDOMSelection *aSel, short aReason); static void CaretBlinkCallback(nsITimer *aTimer, void *aClosure); diff --git a/mozilla/layout/base/src/nsDocumentViewer.cpp b/mozilla/layout/base/src/nsDocumentViewer.cpp index 6af9db9f62d..fa6b6e1558f 100644 --- a/mozilla/layout/base/src/nsDocumentViewer.cpp +++ b/mozilla/layout/base/src/nsDocumentViewer.cpp @@ -377,6 +377,13 @@ DocumentViewerImpl::~DocumentViewerImpl() if (mPresShell) { // Break circular reference (or something) mPresShell->EndObservingDocument(); + nsCOMPtr selection; + nsresult rv; + rv = GetDocumentSelection(getter_AddRefs(selection)); + if (NS_FAILED(rv) || !selection) + return; + if (mSelectionListener) + selection->RemoveSelectionListener(mSelectionListener); } } @@ -1661,7 +1668,7 @@ nsresult nsDocViwerSelectionListener::Init(DocumentViewerImpl *aDocViewer) } -NS_IMETHODIMP nsDocViwerSelectionListener::NotifySelectionChanged(nsIDOMDocument *, nsIDOMSelection *) +NS_IMETHODIMP nsDocViwerSelectionListener::NotifySelectionChanged(nsIDOMDocument *, nsIDOMSelection *, short) { NS_ASSERTION(mDocViewer, "Should have doc viewer!"); diff --git a/mozilla/layout/base/src/nsSelection.cpp b/mozilla/layout/base/src/nsSelection.cpp index 2489ee9b9c1..017047b67b3 100644 --- a/mozilla/layout/base/src/nsSelection.cpp +++ b/mozilla/layout/base/src/nsSelection.cpp @@ -1681,6 +1681,7 @@ nsSelection::SetMouseDownState(PRBool aState) mSelectingTableCells = PR_FALSE; mStartSelectedCell = nsnull; mEndSelectedCell = nsnull; + NotifySelectionListeners(SELECTION_NORMAL); } return NS_OK; } @@ -1999,7 +2000,7 @@ nsSelection::NotifySelectionListeners(SelectionType aType) nsCOMPtr isupports(dont_AddRef(mSelectionListeners->ElementAt(i))); nsCOMPtr thisListener = do_QueryInterface(isupports); if (thisListener) - thisListener->NotifySelectionChanged(domdoc,mDomSelections[idx]); + thisListener->NotifySelectionChanged(domdoc,mDomSelections[idx], (short) mMouseDownState); } return NS_OK; } diff --git a/mozilla/layout/generic/nsSelection.cpp b/mozilla/layout/generic/nsSelection.cpp index 2489ee9b9c1..017047b67b3 100644 --- a/mozilla/layout/generic/nsSelection.cpp +++ b/mozilla/layout/generic/nsSelection.cpp @@ -1681,6 +1681,7 @@ nsSelection::SetMouseDownState(PRBool aState) mSelectingTableCells = PR_FALSE; mStartSelectedCell = nsnull; mEndSelectedCell = nsnull; + NotifySelectionListeners(SELECTION_NORMAL); } return NS_OK; } @@ -1999,7 +2000,7 @@ nsSelection::NotifySelectionListeners(SelectionType aType) nsCOMPtr isupports(dont_AddRef(mSelectionListeners->ElementAt(i))); nsCOMPtr thisListener = do_QueryInterface(isupports); if (thisListener) - thisListener->NotifySelectionChanged(domdoc,mDomSelections[idx]); + thisListener->NotifySelectionChanged(domdoc,mDomSelections[idx], (short) mMouseDownState); } return NS_OK; } diff --git a/mozilla/layout/html/forms/src/nsGfxTextControlFrame.cpp b/mozilla/layout/html/forms/src/nsGfxTextControlFrame.cpp index c600c1e3102..5bbe24dbd26 100644 --- a/mozilla/layout/html/forms/src/nsGfxTextControlFrame.cpp +++ b/mozilla/layout/html/forms/src/nsGfxTextControlFrame.cpp @@ -4552,7 +4552,7 @@ nsEnderEventListener::Blur(nsIDOMEvent* aEvent) } NS_IMETHODIMP -nsEnderEventListener::NotifySelectionChanged(nsIDOMDocument *, nsIDOMSelection *) +nsEnderEventListener::NotifySelectionChanged(nsIDOMDocument *, nsIDOMSelection *, short) { nsGfxTextControlFrame *gfxFrame = mFrame.Reference(); if (gfxFrame && mContent) diff --git a/mozilla/layout/html/forms/src/nsGfxTextControlFrame.h b/mozilla/layout/html/forms/src/nsGfxTextControlFrame.h index 992a3067519..58dccff04e4 100644 --- a/mozilla/layout/html/forms/src/nsGfxTextControlFrame.h +++ b/mozilla/layout/html/forms/src/nsGfxTextControlFrame.h @@ -251,7 +251,7 @@ public: /** nsIDOMSelectionListener interfaces * @see nsIDOMSelectionListener */ - NS_IMETHOD NotifySelectionChanged(nsIDOMDocument *, nsIDOMSelection *); + NS_IMETHOD NotifySelectionChanged(nsIDOMDocument *, nsIDOMSelection *, short); /*END interfaces from nsIDOMSelectionListener*/ /** nsITransactionListener interfaces