diff --git a/editor/libeditor/EditorBase.cpp b/editor/libeditor/EditorBase.cpp index 747437dcc2af..f0593becde30 100644 --- a/editor/libeditor/EditorBase.cpp +++ b/editor/libeditor/EditorBase.cpp @@ -1571,12 +1571,14 @@ EditorBase::SplitNode(const EditorRawDOMPoint& aStartOfRightNode, } RefPtr transaction = - CreateTxnForSplitNode(aStartOfRightNode); + SplitNodeTransaction::Create(*this, aStartOfRightNode); aError = DoTransaction(transaction); nsCOMPtr newNode = transaction->GetNewNode(); NS_WARNING_ASSERTION(newNode, "Failed to create a new left node"); + // XXX Some other transactions manage range updater by themselves. + // Why doesn't SplitNodeTransaction do it? mRangeUpdater.SelAdjSplitNode(*aStartOfRightNode.GetContainerAsContent(), newNode); @@ -3043,15 +3045,6 @@ EditorBase::DeleteText(nsGenericDOMDataNode& aCharData, return rv; } -already_AddRefed -EditorBase::CreateTxnForSplitNode(const EditorRawDOMPoint& aStartOfRightNode) -{ - MOZ_ASSERT(aStartOfRightNode.IsSetAndValid()); - RefPtr transaction = - new SplitNodeTransaction(*this, aStartOfRightNode); - return transaction.forget(); -} - already_AddRefed EditorBase::CreateTxnForJoinNode(nsINode& aLeftNode, nsINode& aRightNode) diff --git a/editor/libeditor/EditorBase.h b/editor/libeditor/EditorBase.h index 38a25f98f959..4f88d689814a 100644 --- a/editor/libeditor/EditorBase.h +++ b/editor/libeditor/EditorBase.h @@ -590,21 +590,6 @@ protected: nsresult DeleteText(nsGenericDOMDataNode& aElement, uint32_t aOffset, uint32_t aLength); - /** - * CreateTxnForSplitNode() creates a transaction to create a new node - * (left node) identical to an existing node (right node), and split the - * contents between the same point in both nodes. - * - * @param aStartOfRightNode The point to split. Its container will be - * the right node, i.e., become the new node's - * next sibling. And the point will be start - * of the right node. - * @return The new transaction to split the container of - * aStartOfRightNode. - */ - already_AddRefed - CreateTxnForSplitNode(const EditorRawDOMPoint& aStartOfRightNode); - already_AddRefed CreateTxnForJoinNode(nsINode& aLeftNode, nsINode& aRightNode); diff --git a/editor/libeditor/SplitNodeTransaction.cpp b/editor/libeditor/SplitNodeTransaction.cpp index a98e33a52b8f..c3c537f8748c 100644 --- a/editor/libeditor/SplitNodeTransaction.cpp +++ b/editor/libeditor/SplitNodeTransaction.cpp @@ -17,6 +17,16 @@ namespace mozilla { using namespace dom; +// static +already_AddRefed +SplitNodeTransaction::Create(EditorBase& aEditorBase, + const EditorRawDOMPoint& aStartOfRightNode) +{ + RefPtr transaction = + new SplitNodeTransaction(aEditorBase, aStartOfRightNode); + return transaction.forget(); +} + SplitNodeTransaction::SplitNodeTransaction( EditorBase& aEditorBase, const EditorRawDOMPoint& aStartOfRightNode) diff --git a/editor/libeditor/SplitNodeTransaction.h b/editor/libeditor/SplitNodeTransaction.h index 6ddb342c5d66..27b32e97ae59 100644 --- a/editor/libeditor/SplitNodeTransaction.h +++ b/editor/libeditor/SplitNodeTransaction.h @@ -26,16 +26,25 @@ class EditorBase; */ class SplitNodeTransaction final : public EditTransactionBase { +private: + SplitNodeTransaction(EditorBase& aEditorBase, + const EditorRawDOMPoint& aStartOfRightNode); + public: /** + * Creates a transaction to create a new node (left node) identical to an + * existing node (right node), and split the contents between the same point + * in both nodes. + * * @param aEditorBase The provider of core editing operations. * @param aStartOfRightNode The point to split. Its container will be * the right node, i.e., become the new node's * next sibling. And the point will be start * of the right node. */ - SplitNodeTransaction(EditorBase& aEditorBase, - const EditorRawDOMPoint& aStartOfRightNode); + static already_AddRefed + Create(EditorBase& aEditorBase, + const EditorRawDOMPoint& aStartOfRightNode); NS_DECL_ISUPPORTS_INHERITED NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(SplitNodeTransaction,