diff options
Diffstat (limited to 'editor/libeditor/JoinNodeTransaction.cpp')
-rw-r--r-- | editor/libeditor/JoinNodeTransaction.cpp | 20 |
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; |