adding batching for selection.
git-svn-id: svn://10.0.0.236/trunk@21355 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
parent
46236d416a
commit
25715df9ea
@ -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;
|
||||
}
|
||||
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user