Bug 1260651 part.19 Rename mozilla::dom::CreateElementTxn to mozilla::CreateElementTransaction (and their files too) r=mccr8
authorMasayuki Nakano <masayuki@d-toybox.com>
Thu, 07 Jul 2016 14:33:56 +0900
changeset 304314 d191b334df8125badd530ebdaf0e3ee167e7ae9a
parent 304313 8caae37fda3d60afdd6539ea7ca4fece63a26fa5
child 304315 2737bb4b73708c38fba0c1453d46797d3a90f723
push id79299
push usermasayuki@d-toybox.com
push dateSat, 09 Jul 2016 08:01:22 +0000
treeherdermozilla-inbound@942dac383054 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmccr8
bugs1260651
milestone50.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1260651 part.19 Rename mozilla::dom::CreateElementTxn to mozilla::CreateElementTransaction (and their files too) r=mccr8 MozReview-Commit-ID: 7RckfPHq1Y
editor/libeditor/CreateElementTransaction.cpp
editor/libeditor/CreateElementTransaction.h
editor/libeditor/CreateElementTxn.cpp
editor/libeditor/CreateElementTxn.h
editor/libeditor/moz.build
editor/libeditor/nsEditor.cpp
editor/libeditor/nsEditor.h
rename from editor/libeditor/CreateElementTxn.cpp
rename to editor/libeditor/CreateElementTransaction.cpp
--- a/editor/libeditor/CreateElementTxn.cpp
+++ b/editor/libeditor/CreateElementTransaction.cpp
@@ -1,14 +1,14 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * 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 "CreateElementTxn.h"
+#include "CreateElementTransaction.h"
 
 #include <algorithm>
 #include <stdio.h>
 
 #include "mozilla/dom/Element.h"
 #include "mozilla/dom/Selection.h"
 
 #include "mozilla/Casting.h"
@@ -23,48 +23,49 @@
 #include "nsIEditor.h"
 #include "nsINode.h"
 #include "nsISupportsUtils.h"
 #include "nsMemory.h"
 #include "nsReadableUtils.h"
 #include "nsStringFwd.h"
 #include "nsString.h"
 
-using namespace mozilla;
-using namespace mozilla::dom;
+namespace mozilla {
+
+using namespace dom;
 
-CreateElementTxn::CreateElementTxn(nsEditor& aEditor,
-                                   nsIAtom& aTag,
-                                   nsINode& aParent,
-                                   int32_t aOffsetInParent)
+CreateElementTransaction::CreateElementTransaction(nsEditor& aEditor,
+                                                   nsIAtom& aTag,
+                                                   nsINode& aParent,
+                                                   int32_t aOffsetInParent)
   : EditTxn()
   , mEditor(&aEditor)
   , mTag(&aTag)
   , mParent(&aParent)
   , mOffsetInParent(aOffsetInParent)
 {
 }
 
-CreateElementTxn::~CreateElementTxn()
+CreateElementTransaction::~CreateElementTransaction()
 {
 }
 
-NS_IMPL_CYCLE_COLLECTION_INHERITED(CreateElementTxn, EditTxn,
+NS_IMPL_CYCLE_COLLECTION_INHERITED(CreateElementTransaction, EditTxn,
                                    mParent,
                                    mNewNode,
                                    mRefNode)
 
-NS_IMPL_ADDREF_INHERITED(CreateElementTxn, EditTxn)
-NS_IMPL_RELEASE_INHERITED(CreateElementTxn, EditTxn)
-NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(CreateElementTxn)
+NS_IMPL_ADDREF_INHERITED(CreateElementTransaction, EditTxn)
+NS_IMPL_RELEASE_INHERITED(CreateElementTransaction, EditTxn)
+NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(CreateElementTransaction)
 NS_INTERFACE_MAP_END_INHERITING(EditTxn)
 
 
 NS_IMETHODIMP
-CreateElementTxn::DoTransaction()
+CreateElementTransaction::DoTransaction()
 {
   MOZ_ASSERT(mEditor && mTag && mParent);
 
   mNewNode = mEditor->CreateHTMLContent(mTag);
   NS_ENSURE_STATE(mNewNode);
 
   // Try to insert formatting whitespace for the new node:
   mEditor->MarkNodeDirty(GetAsDOMNode(mNewNode));
@@ -96,46 +97,48 @@ CreateElementTxn::DoTransaction()
 
   rv = selection->CollapseNative(mParent, mParent->IndexOf(mNewNode) + 1);
   NS_ASSERTION(!rv.Failed(),
                "selection could not be collapsed after insert");
   return NS_OK;
 }
 
 NS_IMETHODIMP
-CreateElementTxn::UndoTransaction()
+CreateElementTransaction::UndoTransaction()
 {
   MOZ_ASSERT(mEditor && mParent);
 
   ErrorResult rv;
   mParent->RemoveChild(*mNewNode, rv);
 
   return rv.StealNSResult();
 }
 
 NS_IMETHODIMP
-CreateElementTxn::RedoTransaction()
+CreateElementTransaction::RedoTransaction()
 {
   MOZ_ASSERT(mEditor && mParent);
 
   // First, reset mNewNode so it has no attributes or content
   // XXX We never actually did this, we only cleared mNewNode's contents if it
   // was a CharacterData node (which it's not, it's an Element)
 
   // Now, reinsert mNewNode
   ErrorResult rv;
   mParent->InsertBefore(*mNewNode, mRefNode, rv);
   return rv.StealNSResult();
 }
 
 NS_IMETHODIMP
-CreateElementTxn::GetTxnDescription(nsAString& aString)
+CreateElementTransaction::GetTxnDescription(nsAString& aString)
 {
-  aString.AssignLiteral("CreateElementTxn: ");
+  aString.AssignLiteral("CreateElementTransaction: ");
   aString += nsDependentAtomString(mTag);
   return NS_OK;
 }
 
 already_AddRefed<Element>
-CreateElementTxn::GetNewNode()
+CreateElementTransaction::GetNewNode()
 {
   return nsCOMPtr<Element>(mNewNode).forget();
 }
+
+} // namespace mozilla
rename from editor/libeditor/CreateElementTxn.h
rename to editor/libeditor/CreateElementTransaction.h
--- a/editor/libeditor/CreateElementTxn.h
+++ b/editor/libeditor/CreateElementTransaction.h
@@ -1,76 +1,79 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * 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 CreateElementTxn_h__
-#define CreateElementTxn_h__
+#ifndef CreateElementTransaction_h
+#define CreateElementTransaction_h
 
 #include "EditTxn.h"
 #include "nsCOMPtr.h"
 #include "nsCycleCollectionParticipant.h"
 #include "nsISupportsImpl.h"
 
 class nsEditor;
 class nsIAtom;
 class nsIContent;
 class nsINode;
 
 /**
  * A transaction that creates a new node in the content tree.
  */
 namespace mozilla {
+
 namespace dom {
-
 class Element;
+} // namespace dom
 
-class CreateElementTxn : public EditTxn
+class CreateElementTransaction final : public EditTxn
 {
 public:
-  /** Initialize the transaction.
-    * @param aEditor the provider of basic editing functionality
-    * @param aTag    the tag (P, HR, TABLE, etc.) for the new element
-    * @param aParent the node into which the new element will be inserted
-    * @param aOffsetInParent the location in aParent to insert the new element
-    *                        if eAppend, the new element is appended as the last child
-    */
-  CreateElementTxn(nsEditor& aEditor,
-                   nsIAtom& aTag,
-                   nsINode& aParent,
-                   int32_t aOffsetInParent);
+  /**
+   * Initialize the transaction.
+   * @param aEditor         The provider of basic editing functionality.
+   * @param aTag            The tag (P, HR, TABLE, etc.) for the new element.
+   * @param aParent         The node into which the new element will be
+   *                        inserted.
+   * @param aOffsetInParent The location in aParent to insert the new element.
+   *                        If eAppend, the new element is appended as the last
+   *                        child.
+   */
+  CreateElementTransaction(nsEditor& aEditor,
+                           nsIAtom& aTag,
+                           nsINode& aParent,
+                           int32_t aOffsetInParent);
 
   NS_DECL_ISUPPORTS_INHERITED
-  NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(CreateElementTxn, EditTxn)
+  NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(CreateElementTransaction, EditTxn)
 
   NS_DECL_EDITTXN
 
   NS_IMETHOD RedoTransaction() override;
 
-  already_AddRefed<Element> GetNewNode();
+  already_AddRefed<dom::Element> GetNewNode();
 
 protected:
-  virtual ~CreateElementTxn();
+  virtual ~CreateElementTransaction();
 
-  /** the document into which the new node will be inserted */
+  // The document into which the new node will be inserted.
   nsEditor* mEditor;
 
-  /** the tag (mapping to object type) for the new element */
+  // The tag (mapping to object type) for the new element.
   nsCOMPtr<nsIAtom> mTag;
 
-  /** the node into which the new node will be inserted */
+  // The node into which the new node will be inserted.
   nsCOMPtr<nsINode> mParent;
 
-  /** the index in mParent for the new node */
+  // The index in mParent for the new node.
   int32_t mOffsetInParent;
 
-  /** the new node to insert */
-  nsCOMPtr<Element> mNewNode;
+  // The new node to insert.
+  nsCOMPtr<dom::Element> mNewNode;
 
-  /** the node we will insert mNewNode before.  We compute this ourselves. */
+  // The node we will insert mNewNode before.  We compute this ourselves.
   nsCOMPtr<nsIContent> mRefNode;
 };
 
-} // namespace dom
 } // namespace mozilla
 
-#endif
+#endif // #ifndef CreateElementTransaction_h
--- a/editor/libeditor/moz.build
+++ b/editor/libeditor/moz.build
@@ -11,17 +11,17 @@ MOCHITEST_MANIFESTS += [
 
 MOCHITEST_CHROME_MANIFESTS += ['tests/chrome.ini']
 
 BROWSER_CHROME_MANIFESTS += ['tests/browser.ini']
 
 UNIFIED_SOURCES += [
     'ChangeAttributeTransaction.cpp',
     'ChangeStyleTransaction.cpp',
-    'CreateElementTxn.cpp',
+    'CreateElementTransaction.cpp',
     'DeleteNodeTxn.cpp',
     'DeleteRangeTxn.cpp',
     'DeleteTextTxn.cpp',
     'EditAggregateTxn.cpp',
     'EditorUtils.cpp',
     'EditTxn.cpp',
     'HTMLEditUtils.cpp',
     'IMETextTxn.cpp',
--- a/editor/libeditor/nsEditor.cpp
+++ b/editor/libeditor/nsEditor.cpp
@@ -6,17 +6,17 @@
 #include "nsEditor.h"
 
 #include "mozilla/DebugOnly.h"          // for DebugOnly
 
 #include <stdio.h>                      // for nullptr, stdout
 #include <string.h>                     // for strcmp
 
 #include "ChangeAttributeTransaction.h" // for ChangeAttributeTransaction
-#include "CreateElementTxn.h"           // for CreateElementTxn
+#include "CreateElementTransaction.h"   // for CreateElementTransaction
 #include "DeleteNodeTxn.h"              // for DeleteNodeTxn
 #include "DeleteRangeTxn.h"             // for DeleteRangeTxn
 #include "DeleteTextTxn.h"              // for DeleteTextTxn
 #include "EditAggregateTxn.h"           // for EditAggregateTxn
 #include "EditorUtils.h"                // for AutoRules, etc
 #include "EditTxn.h"                    // for EditTxn
 #include "IMETextTxn.h"                 // for IMETextTxn
 #include "InsertNodeTxn.h"              // for InsertNodeTxn
@@ -1350,21 +1350,21 @@ nsEditor::CreateNode(nsIAtom* aTag,
 
   for (auto& listener : mActionListeners) {
     listener->WillCreateNode(nsDependentAtomString(aTag),
                              GetAsDOMNode(aParent), aPosition);
   }
 
   nsCOMPtr<Element> ret;
 
-  RefPtr<CreateElementTxn> txn =
+  RefPtr<CreateElementTransaction> transaction =
     CreateTxnForCreateElement(*aTag, *aParent, aPosition);
-  nsresult res = DoTransaction(txn);
+  nsresult res = DoTransaction(transaction);
   if (NS_SUCCEEDED(res)) {
-    ret = txn->GetNewNode();
+    ret = transaction->GetNewNode();
     MOZ_ASSERT(ret);
   }
 
   mRangeUpdater.SelAdjCreateNode(aParent, aPosition);
 
   for (auto& listener : mActionListeners) {
     listener->DidCreateNode(nsDependentAtomString(aTag), GetAsDOMNode(ret),
                             GetAsDOMNode(aParent), aPosition, res);
@@ -4187,25 +4187,25 @@ nsEditor::CreateTxnForRemoveAttribute(El
 {
   RefPtr<ChangeAttributeTransaction> transaction =
     new ChangeAttributeTransaction(aElement, aAttribute, nullptr);
 
   return transaction.forget();
 }
 
 
-already_AddRefed<CreateElementTxn>
+already_AddRefed<CreateElementTransaction>
 nsEditor::CreateTxnForCreateElement(nsIAtom& aTag,
                                     nsINode& aParent,
                                     int32_t aPosition)
 {
-  RefPtr<CreateElementTxn> txn =
-    new CreateElementTxn(*this, aTag, aParent, aPosition);
-
-  return txn.forget();
+  RefPtr<CreateElementTransaction> transaction =
+    new CreateElementTransaction(*this, aTag, aParent, aPosition);
+
+  return transaction.forget();
 }
 
 
 already_AddRefed<InsertNodeTxn>
 nsEditor::CreateTxnForInsertNode(nsIContent& aNode,
                                  nsINode& aParent,
                                  int32_t aPosition)
 {
--- a/editor/libeditor/nsEditor.h
+++ b/editor/libeditor/nsEditor.h
@@ -53,22 +53,22 @@ class nsRange;
 class nsString;
 class nsTransactionManager;
 
 namespace mozilla {
 class AutoRules;
 class AutoSelectionRestorer;
 class AutoTransactionsConserveSelection;
 class ChangeAttributeTransaction;
+class CreateElementTransaction;
 class ErrorResult;
 class TextComposition;
 struct EditorDOMPoint;
 
 namespace dom {
-class CreateElementTxn;
 class DataTransfer;
 class DeleteTextTxn;
 class Element;
 class EventTarget;
 class IMETextTxn;
 class InsertTextTxn;
 class InsertNodeTxn;
 class JoinNodeTxn;
@@ -263,17 +263,17 @@ protected:
   /** Create a transaction for removing aAttribute on aElement.  Never returns
     * null.
     */
   already_AddRefed<mozilla::ChangeAttributeTransaction>
   CreateTxnForRemoveAttribute(Element& aElement, nsIAtom& aAttribute);
 
   /** create a transaction for creating a new child node of aParent of type aTag.
     */
-  already_AddRefed<mozilla::dom::CreateElementTxn>
+  already_AddRefed<mozilla::CreateElementTransaction>
   CreateTxnForCreateElement(nsIAtom& aTag,
                             nsINode& aParent,
                             int32_t aPosition);
 
   already_AddRefed<Element> CreateNode(nsIAtom* aTag, nsINode* aParent,
                                        int32_t aPosition);
 
   /** create a transaction for inserting aNode as a child of aParent.