summaryrefslogtreecommitdiffstats
path: root/editor/libeditor/JoinNodeTransaction.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/JoinNodeTransaction.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/JoinNodeTransaction.cpp')
-rw-r--r--editor/libeditor/JoinNodeTransaction.cpp20
1 files changed, 16 insertions, 4 deletions
diff --git a/editor/libeditor/JoinNodeTransaction.cpp b/editor/libeditor/JoinNodeTransaction.cpp
index 228d1f4d6..50727cce1 100644
--- a/editor/libeditor/JoinNodeTransaction.cpp
+++ b/editor/libeditor/JoinNodeTransaction.cpp
@@ -21,7 +21,7 @@ using namespace dom;
JoinNodeTransaction::JoinNodeTransaction(EditorBase& aEditorBase,
nsINode& aLeftNode,
nsINode& aRightNode)
- : mEditorBase(aEditorBase)
+ : mEditorBase(&aEditorBase)
, mLeftNode(&aLeftNode)
, mRightNode(&aRightNode)
, mOffset(0)
@@ -29,6 +29,7 @@ JoinNodeTransaction::JoinNodeTransaction(EditorBase& aEditorBase,
}
NS_IMPL_CYCLE_COLLECTION_INHERITED(JoinNodeTransaction, EditTransactionBase,
+ mEditorBase,
mLeftNode,
mRightNode,
mParent)
@@ -39,7 +40,8 @@ NS_INTERFACE_MAP_END_INHERITING(EditTransactionBase)
nsresult
JoinNodeTransaction::CheckValidity()
{
- if (!mEditorBase.IsModifiableNode(mLeftNode->GetParentNode())) {
+ if (NS_WARN_IF(!mEditorBase) ||
+ !mEditorBase->IsModifiableNode(mLeftNode->GetParentNode())) {
return NS_ERROR_FAILURE;
}
return NS_OK;
@@ -50,6 +52,12 @@ JoinNodeTransaction::CheckValidity()
NS_IMETHODIMP
JoinNodeTransaction::DoTransaction()
{
+ if (NS_WARN_IF(!mEditorBase) ||
+ NS_WARN_IF(!mLeftNode) ||
+ NS_WARN_IF(!mRightNode)) {
+ return NS_ERROR_NOT_INITIALIZED;
+ }
+
// Get the parent node
nsCOMPtr<nsINode> leftParent = mLeftNode->GetParentNode();
NS_ENSURE_TRUE(leftParent, NS_ERROR_NULL_POINTER);
@@ -65,7 +73,7 @@ JoinNodeTransaction::DoTransaction()
mParent = leftParent;
mOffset = mLeftNode->Length();
- return mEditorBase.JoinNodesImpl(mRightNode, mLeftNode, mParent);
+ return mEditorBase->JoinNodesImpl(mRightNode, mLeftNode, mParent);
}
//XXX: What if instead of split, we just deleted the unneeded children of
@@ -73,7 +81,11 @@ JoinNodeTransaction::DoTransaction()
NS_IMETHODIMP
JoinNodeTransaction::UndoTransaction()
{
- MOZ_ASSERT(mParent);
+ if (NS_WARN_IF(!mParent) ||
+ NS_WARN_IF(!mRightNode) ||
+ NS_WARN_IF(!mLeftNode)) {
+ return NS_ERROR_NOT_INITIALIZED;
+ }
// First, massage the existing node so it is in its post-split state
ErrorResult rv;