mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-10 20:05:49 +00:00
adding batching for selection.
This commit is contained in:
parent
571bb3e4a9
commit
b3cb7695a5
@ -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…
Reference in New Issue
Block a user