From 3ace47ff12d46de01661ca16f2d377183641fc4b Mon Sep 17 00:00:00 2001 From: "sfraser%netscape.com" Date: Thu, 29 Jun 2000 22:36:10 +0000 Subject: [PATCH] Fix for 44118 and nsbeta2+ bug 42625, r=kin. Update selection-based commands (e.g. cut/copy) when the selection changes from collapsed to non-collapsed and vice versa, not just when it is uncollapsed. git-svn-id: svn://10.0.0.236/trunk@73554 18797224-902f-48f8-a5cc-f745e15eee43 --- .../html/forms/src/nsGfxTextControlFrame2.cpp | 23 +++++++++++++++---- .../html/forms/src/nsGfxTextControlFrame2.h | 6 +++-- 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/mozilla/layout/html/forms/src/nsGfxTextControlFrame2.cpp b/mozilla/layout/html/forms/src/nsGfxTextControlFrame2.cpp index 5c5c8a6a5c8..016847678cb 100644 --- a/mozilla/layout/html/forms/src/nsGfxTextControlFrame2.cpp +++ b/mozilla/layout/html/forms/src/nsGfxTextControlFrame2.cpp @@ -206,8 +206,12 @@ public: protected: + nsGfxTextControlFrame2* mFrame; // weak reference nsString mFocusedValue; + + PRPackedBool mSelectionWasCollapsed; + PRPackedBool mKnowSelectionCollapsed; }; @@ -221,6 +225,9 @@ NS_IMPL_RELEASE(nsTextInputListener) nsTextInputListener::nsTextInputListener() +: mFrame(nsnull) +, mSelectionWasCollapsed(PR_TRUE) +, mKnowSelectionCollapsed(PR_FALSE) { NS_INIT_REFCNT(); } @@ -298,8 +305,16 @@ NS_IMETHODIMP nsTextInputListener::NotifySelectionChanged(nsIDOMDocument* aDoc, nsIDOMSelection* aSel, PRInt16 aReason) { PRBool collapsed; - if (!mFrame || !aDoc || !aSel || NS_FAILED(aSel->GetIsCollapsed(&collapsed)) || collapsed) - return NS_OK;//no update if collapsed + if (!mFrame || !aDoc || !aSel || NS_FAILED(aSel->GetIsCollapsed(&collapsed))) + return NS_OK; + + // if the collapsed state did not change, don't fire notifications + if (mKnowSelectionCollapsed && collapsed == mSelectionWasCollapsed) + return NS_OK; + + mSelectionWasCollapsed = collapsed; + mKnowSelectionCollapsed = PR_TRUE; + nsCOMPtr content; nsresult rv = mFrame->GetContent(getter_AddRefs(content)); if (NS_FAILED(rv) || !content ) @@ -2566,8 +2581,8 @@ nsGfxTextControlFrame2::SetInitialChildList(nsIPresContext* aPresContext, first->QueryInterface(NS_GET_IID(nsIScrollableFrame), (void **) &scrollableFrame); if (scrollableFrame) scrollableFrame->SetScrollbarVisibility(aPresContext,PR_FALSE,PR_FALSE); - } + //register keylistener nsCOMPtr erP; if (NS_SUCCEEDED(mContent->QueryInterface(NS_GET_IID(nsIDOMEventReceiver), getter_AddRefs(erP))) && erP) @@ -2581,8 +2596,8 @@ nsGfxTextControlFrame2::SetInitialChildList(nsIPresContext* aPresContext, nsresult rv = aPresContext->GetShell(getter_AddRefs(shell)); if (NS_FAILED(rv) || !shell) return rv?rv:NS_ERROR_FAILURE; - } + while(first) { nsIScrollableView *scrollView; diff --git a/mozilla/layout/html/forms/src/nsGfxTextControlFrame2.h b/mozilla/layout/html/forms/src/nsGfxTextControlFrame2.h index c1d5946bf84..54cf736c48e 100644 --- a/mozilla/layout/html/forms/src/nsGfxTextControlFrame2.h +++ b/mozilla/layout/html/forms/src/nsGfxTextControlFrame2.h @@ -221,6 +221,7 @@ private: NS_IMETHODIMP GetFirstTextNode(nsIDOMCharacterData* *aFirstTextNode); nsresult SelectAllContents(); nsresult SetSelectionEndPoints(PRInt32 aSelStart, PRInt32 aSelEnd); + private: nsCOMPtr mEditor; nsCOMPtr mSelCon; @@ -231,11 +232,12 @@ private: nscoord mSuggestedHeight; nsSize mSize; - PRBool mIsProcessing; + PRPackedBool mIsProcessing; + PRPackedBool mNotifyOnInput;//default this to off to stop any notifications until setup is complete + nsFormFrame *mFormFrame; nsTextInputSelectionImpl *mTextSelImpl; nsTextInputListener *mTextListener; - PRBool mNotifyOnInput;//default this to off to stop any notifications until setup is complete }; #endif