summaryrefslogtreecommitdiffstats
path: root/editor/libeditor/CreateElementTransaction.cpp
diff options
context:
space:
mode:
authorwolfbeast <mcwerewolf@gmail.com>2018-02-07 21:36:37 +0100
committerwolfbeast <mcwerewolf@gmail.com>2018-02-07 21:36:37 +0100
commitd773eca3316f2c99db9a1dd77929bcbd157eeacb (patch)
treebe0efc8413575e2db60480a9ba5991261929b144 /editor/libeditor/CreateElementTransaction.cpp
parent1e55a5d9188b87da8632e217b238838effb1cdeb (diff)
downloadUXP-d773eca3316f2c99db9a1dd77929bcbd157eeacb.tar
UXP-d773eca3316f2c99db9a1dd77929bcbd157eeacb.tar.gz
UXP-d773eca3316f2c99db9a1dd77929bcbd157eeacb.tar.lz
UXP-d773eca3316f2c99db9a1dd77929bcbd157eeacb.tar.xz
UXP-d773eca3316f2c99db9a1dd77929bcbd157eeacb.zip
Edit transactions should store their editor instance with strong reference
Edit transactions should store their editor instance with a strong reference, and they should be released when the editor is destroyed.
Diffstat (limited to 'editor/libeditor/CreateElementTransaction.cpp')
-rw-r--r--editor/libeditor/CreateElementTransaction.cpp13
1 files changed, 10 insertions, 3 deletions
diff --git a/editor/libeditor/CreateElementTransaction.cpp b/editor/libeditor/CreateElementTransaction.cpp
index 5e4bd961c..5e2b9e1ad 100644
--- a/editor/libeditor/CreateElementTransaction.cpp
+++ b/editor/libeditor/CreateElementTransaction.cpp
@@ -50,6 +50,7 @@ CreateElementTransaction::~CreateElementTransaction()
NS_IMPL_CYCLE_COLLECTION_INHERITED(CreateElementTransaction,
EditTransactionBase,
+ mEditorBase,
mParent,
mNewNode,
mRefNode)
@@ -63,7 +64,9 @@ NS_INTERFACE_MAP_END_INHERITING(EditTransactionBase)
NS_IMETHODIMP
CreateElementTransaction::DoTransaction()
{
- MOZ_ASSERT(mEditorBase && mTag && mParent);
+ if (NS_WARN_IF(!mEditorBase) || NS_WARN_IF(!mTag) || NS_WARN_IF(!mParent)) {
+ return NS_ERROR_NOT_INITIALIZED;
+ }
mNewNode = mEditorBase->CreateHTMLContent(mTag);
NS_ENSURE_STATE(mNewNode);
@@ -106,7 +109,9 @@ CreateElementTransaction::DoTransaction()
NS_IMETHODIMP
CreateElementTransaction::UndoTransaction()
{
- MOZ_ASSERT(mEditorBase && mParent);
+ if (NS_WARN_IF(!mEditorBase) || NS_WARN_IF(!mParent)) {
+ return NS_ERROR_NOT_INITIALIZED;
+ }
ErrorResult rv;
mParent->RemoveChild(*mNewNode, rv);
@@ -117,7 +122,9 @@ CreateElementTransaction::UndoTransaction()
NS_IMETHODIMP
CreateElementTransaction::RedoTransaction()
{
- MOZ_ASSERT(mEditorBase && mParent);
+ if (NS_WARN_IF(!mEditorBase) || NS_WARN_IF(!mParent)) {
+ return NS_ERROR_NOT_INITIALIZED;
+ }
// First, reset mNewNode so it has no attributes or content
// XXX We never actually did this, we only cleared mNewNode's contents if it