diff options
author | wolfbeast <mcwerewolf@gmail.com> | 2018-02-08 12:06:30 +0100 |
---|---|---|
committer | wolfbeast <mcwerewolf@gmail.com> | 2018-02-08 12:06:30 +0100 |
commit | 44cd9f2a915a4879371c5e0b059acc3e5a2378b0 (patch) | |
tree | 8cb1a4758b16d9caae55f525b73f5fca3824b4f7 /editor/libeditor/InsertTextTransaction.cpp | |
parent | f8d1830b530cd553d788b3579d41725d35c4da7f (diff) | |
parent | b62fce0dc0c77a5788c331db32b3996e4020e2a5 (diff) | |
download | UXP-44cd9f2a915a4879371c5e0b059acc3e5a2378b0.tar UXP-44cd9f2a915a4879371c5e0b059acc3e5a2378b0.tar.gz UXP-44cd9f2a915a4879371c5e0b059acc3e5a2378b0.tar.lz UXP-44cd9f2a915a4879371c5e0b059acc3e5a2378b0.tar.xz UXP-44cd9f2a915a4879371c5e0b059acc3e5a2378b0.zip |
Merge branch 'ported-upstream'
Diffstat (limited to 'editor/libeditor/InsertTextTransaction.cpp')
-rw-r--r-- | editor/libeditor/InsertTextTransaction.cpp | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/editor/libeditor/InsertTextTransaction.cpp b/editor/libeditor/InsertTextTransaction.cpp index 009b2d023..0434b2dd5 100644 --- a/editor/libeditor/InsertTextTransaction.cpp +++ b/editor/libeditor/InsertTextTransaction.cpp @@ -26,7 +26,7 @@ InsertTextTransaction::InsertTextTransaction(Text& aTextNode, : mTextNode(&aTextNode) , mOffset(aOffset) , mStringToInsert(aStringToInsert) - , mEditorBase(aEditorBase) + , mEditorBase(&aEditorBase) , mRangeUpdater(aRangeUpdater) { } @@ -36,6 +36,7 @@ InsertTextTransaction::~InsertTextTransaction() } NS_IMPL_CYCLE_COLLECTION_INHERITED(InsertTextTransaction, EditTransactionBase, + mEditorBase, mTextNode) NS_IMPL_ADDREF_INHERITED(InsertTextTransaction, EditTransactionBase) @@ -50,12 +51,16 @@ NS_INTERFACE_MAP_END_INHERITING(EditTransactionBase) NS_IMETHODIMP InsertTextTransaction::DoTransaction() { + if (NS_WARN_IF(!mEditorBase) || NS_WARN_IF(!mTextNode)) { + return NS_ERROR_NOT_AVAILABLE; + } + nsresult rv = mTextNode->InsertData(mOffset, mStringToInsert); NS_ENSURE_SUCCESS(rv, rv); // Only set selection to insertion point if editor gives permission - if (mEditorBase.GetShouldTxnSetSelection()) { - RefPtr<Selection> selection = mEditorBase.GetSelection(); + if (mEditorBase->GetShouldTxnSetSelection()) { + RefPtr<Selection> selection = mEditorBase->GetSelection(); NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER); DebugOnly<nsresult> rv = selection->Collapse(mTextNode, mOffset + mStringToInsert.Length()); |