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
This commit is contained in:
sfraser%netscape.com
2000-06-29 22:36:10 +00:00
parent f3d839b628
commit 3ace47ff12
2 changed files with 23 additions and 6 deletions

View File

@@ -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<nsIContent> 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<nsIDOMEventReceiver> 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;