adding batching for selection.

git-svn-id: svn://10.0.0.236/trunk@21355 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
mjudge%netscape.com 1999-02-19 23:41:49 +00:00
parent 46236d416a
commit 25715df9ea
2 changed files with 12 additions and 4 deletions

View File

@ -54,13 +54,17 @@ nsresult InsertTextTxn::Init(nsIDOMCharacterData *aElement,
nsresult InsertTextTxn::Do(void)
{
nsresult res = mElement->InsertData(mOffset, mStringToInsert);
// advance caret: This requires the presentation shell to get the selection.
nsCOMPtr<nsIDOMSelection> selection;
res = mPresShell->GetSelection(getter_AddRefs(selection));
nsresult res = mPresShell->GetSelection(getter_AddRefs(selection));
selection->StartBatchChanges();
res = mElement->InsertData(mOffset, mStringToInsert);
if (NS_SUCCEEDED(res)) {
res = selection->Collapse(mElement, mOffset+mStringToInsert.Length());
}
else
NS_ASSERTION(PR_FALSE,"Could not get selection in InsertTextTxn::Do\n");
selection->EndBatchChanges();
return res;
}

View File

@ -54,13 +54,17 @@ nsresult InsertTextTxn::Init(nsIDOMCharacterData *aElement,
nsresult InsertTextTxn::Do(void)
{
nsresult res = mElement->InsertData(mOffset, mStringToInsert);
// advance caret: This requires the presentation shell to get the selection.
nsCOMPtr<nsIDOMSelection> selection;
res = mPresShell->GetSelection(getter_AddRefs(selection));
nsresult res = mPresShell->GetSelection(getter_AddRefs(selection));
selection->StartBatchChanges();
res = mElement->InsertData(mOffset, mStringToInsert);
if (NS_SUCCEEDED(res)) {
res = selection->Collapse(mElement, mOffset+mStringToInsert.Length());
}
else
NS_ASSERTION(PR_FALSE,"Could not get selection in InsertTextTxn::Do\n");
selection->EndBatchChanges();
return res;
}