Bug 1260651 part.26 Rename mozilla::dom::JoinNodeTxn to mozilla::JoinNodeTransaction (and their files too) r=mccr8

MozReview-Commit-ID: ChcoinM0sfU

--HG--
rename : editor/libeditor/JoinNodeTxn.cpp => editor/libeditor/JoinNodeTransaction.cpp
rename : editor/libeditor/JoinNodeTxn.h => editor/libeditor/JoinNodeTransaction.h
This commit is contained in:
Masayuki Nakano 2016-07-07 16:16:12 +09:00
parent 0818979e3d
commit 658478a3fc
5 changed files with 51 additions and 48 deletions

View File

@ -3,7 +3,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "JoinNodeTxn.h"
#include "JoinNodeTransaction.h"
#include "nsAString.h"
#include "nsDebug.h" // for NS_ASSERTION, etc
#include "nsEditor.h" // for nsEditor
@ -13,30 +13,30 @@
#include "nsIEditor.h" // for nsEditor::IsModifiableNode
#include "nsISupportsImpl.h" // for EditTxn::QueryInterface, etc
using namespace mozilla;
using namespace mozilla::dom;
namespace mozilla {
JoinNodeTxn::JoinNodeTxn(nsEditor& aEditor, nsINode& aLeftNode,
nsINode& aRightNode)
: EditTxn()
, mEditor(aEditor)
using namespace dom;
JoinNodeTransaction::JoinNodeTransaction(nsEditor& aEditor,
nsINode& aLeftNode,
nsINode& aRightNode)
: mEditor(aEditor)
, mLeftNode(&aLeftNode)
, mRightNode(&aRightNode)
, mOffset(0)
, mParent(nullptr)
{
}
NS_IMPL_CYCLE_COLLECTION_INHERITED(JoinNodeTxn, EditTxn,
NS_IMPL_CYCLE_COLLECTION_INHERITED(JoinNodeTransaction, EditTxn,
mLeftNode,
mRightNode,
mParent)
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(JoinNodeTxn)
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(JoinNodeTransaction)
NS_INTERFACE_MAP_END_INHERITING(EditTxn)
nsresult
JoinNodeTxn::CheckValidity()
JoinNodeTransaction::CheckValidity()
{
if (!mEditor.IsModifiableNode(mLeftNode->GetParentNode())) {
return NS_ERROR_FAILURE;
@ -47,7 +47,7 @@ JoinNodeTxn::CheckValidity()
// After DoTransaction() and RedoTransaction(), the left node is removed from
// the content tree and right node remains.
NS_IMETHODIMP
JoinNodeTxn::DoTransaction()
JoinNodeTransaction::DoTransaction()
{
// Get the parent node
nsCOMPtr<nsINode> leftParent = mLeftNode->GetParentNode();
@ -70,7 +70,7 @@ JoinNodeTxn::DoTransaction()
//XXX: What if instead of split, we just deleted the unneeded children of
// mRight and re-inserted mLeft?
NS_IMETHODIMP
JoinNodeTxn::UndoTransaction()
JoinNodeTransaction::UndoTransaction()
{
MOZ_ASSERT(mParent);
@ -98,8 +98,10 @@ JoinNodeTxn::UndoTransaction()
}
NS_IMETHODIMP
JoinNodeTxn::GetTxnDescription(nsAString& aString)
JoinNodeTransaction::GetTxnDescription(nsAString& aString)
{
aString.AssignLiteral("JoinNodeTxn");
aString.AssignLiteral("JoinNodeTransaction");
return NS_OK;
}
} // namespace mozilla

View File

@ -3,8 +3,8 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef JoinNodeTxn_h__
#define JoinNodeTxn_h__
#ifndef JoinNodeTransaction_h
#define JoinNodeTransaction_h
#include "EditTxn.h" // for EditTxn, NS_DECL_EDITTXN
#include "nsCOMPtr.h" // for nsCOMPtr
@ -16,7 +16,6 @@ class nsEditor;
class nsINode;
namespace mozilla {
namespace dom {
/**
* A transaction that joins two nodes E1 (left node) and E2 (right node) into a
@ -24,19 +23,23 @@ namespace dom {
* children of E2. After DoTransaction() and RedoTransaction(), E1 is removed
* from the content tree and E2 remains.
*/
class JoinNodeTxn : public EditTxn
class JoinNodeTransaction final : public EditTxn
{
public:
/** @param aEditor the provider of core editing operations
* @param aLeftNode the first of two nodes to join
* @param aRightNode the second of two nodes to join
*/
JoinNodeTxn(nsEditor& aEditor, nsINode& aLeftNode, nsINode& aRightNode);
/**
* @param aEditor The provider of core editing operations.
* @param aLeftNode The first of two nodes to join.
* @param aRightNode The second of two nodes to join.
*/
JoinNodeTransaction(nsEditor& aEditor,
nsINode& aLeftNode, nsINode& aRightNode);
/* Call this after constructing to ensure the inputs are correct */
/**
* Call this after constructing to ensure the inputs are correct.
*/
nsresult CheckValidity();
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(JoinNodeTxn, EditTxn)
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(JoinNodeTransaction, EditTxn)
NS_IMETHOD QueryInterface(REFNSIID aIID, void** aInstancePtr) override;
NS_DECL_EDITTXN
@ -44,23 +47,20 @@ public:
protected:
nsEditor& mEditor;
/** The nodes to operate upon. After the merge, mRightNode remains and
* mLeftNode is removed from the content tree.
*/
// The nodes to operate upon. After the merge, mRightNode remains and
// mLeftNode is removed from the content tree.
nsCOMPtr<nsINode> mLeftNode;
nsCOMPtr<nsINode> mRightNode;
/** The offset into mNode where the children of mElement are split (for
* undo). mOffset is the index of the first child in the right node. -1
* means the left node had no children.
*/
// The offset into mNode where the children of mElement are split (for
// undo). mOffset is the index of the first child in the right node. -1
// means the left node had no children.
uint32_t mOffset;
/** The parent node containing mLeftNode and mRightNode */
// The parent node containing mLeftNode and mRightNode.
nsCOMPtr<nsINode> mParent;
};
} // namespace dom
} // namespace mozilla
#endif
#endif // #ifndef JoinNodeTransaction_h

View File

@ -27,7 +27,7 @@ UNIFIED_SOURCES += [
'HTMLEditUtils.cpp',
'InsertNodeTransaction.cpp',
'InsertTextTransaction.cpp',
'JoinNodeTxn.cpp',
'JoinNodeTransaction.cpp',
'nsEditor.cpp',
'nsEditorCommands.cpp',
'nsEditorController.cpp',

View File

@ -21,7 +21,7 @@
#include "EditTxn.h" // for EditTxn
#include "InsertNodeTransaction.h" // for InsertNodeTransaction
#include "InsertTextTransaction.h" // for InsertTextTransaction
#include "JoinNodeTxn.h" // for JoinNodeTxn
#include "JoinNodeTransaction.h" // for JoinNodeTransaction
#include "PlaceholderTxn.h" // for PlaceholderTxn
#include "SplitNodeTxn.h" // for SplitNodeTxn
#include "TextEditUtils.h" // for TextEditUtils
@ -1483,9 +1483,10 @@ nsEditor::JoinNodes(nsINode& aLeftNode, nsINode& aRightNode)
}
nsresult result = NS_OK;
RefPtr<JoinNodeTxn> txn = CreateTxnForJoinNode(aLeftNode, aRightNode);
if (txn) {
result = DoTransaction(txn);
RefPtr<JoinNodeTransaction> transaction =
CreateTxnForJoinNode(aLeftNode, aRightNode);
if (transaction) {
result = DoTransaction(transaction);
}
mRangeUpdater.SelAdjJoinNodes(aLeftNode, aRightNode, *parent, offset,
@ -2636,17 +2637,17 @@ nsEditor::CreateTxnForSplitNode(nsIContent& aNode, uint32_t aOffset)
return txn.forget();
}
already_AddRefed<JoinNodeTxn>
already_AddRefed<JoinNodeTransaction>
nsEditor::CreateTxnForJoinNode(nsINode& aLeftNode, nsINode& aRightNode)
{
RefPtr<JoinNodeTxn> txn = new JoinNodeTxn(*this, aLeftNode, aRightNode);
RefPtr<JoinNodeTransaction> transaction =
new JoinNodeTransaction(*this, aLeftNode, aRightNode);
NS_ENSURE_SUCCESS(txn->CheckValidity(), nullptr);
NS_ENSURE_SUCCESS(transaction->CheckValidity(), nullptr);
return txn.forget();
return transaction.forget();
}
// END nsEditor core implementation

View File

@ -64,6 +64,7 @@ class DeleteTextTransaction;
class ErrorResult;
class InsertNodeTransaction;
class InsertTextTransaction;
class JoinNodeTransaction;
class TextComposition;
struct EditorDOMPoint;
@ -71,7 +72,6 @@ namespace dom {
class DataTransfer;
class Element;
class EventTarget;
class JoinNodeTxn;
class Selection;
class SplitNodeTxn;
class Text;
@ -338,7 +338,7 @@ protected:
already_AddRefed<mozilla::dom::SplitNodeTxn>
CreateTxnForSplitNode(nsIContent& aNode, uint32_t aOffset);
already_AddRefed<mozilla::dom::JoinNodeTxn>
already_AddRefed<mozilla::JoinNodeTransaction>
CreateTxnForJoinNode(nsINode& aLeftNode, nsINode& aRightNode);
/**