Bug 1260651 part.17 Rename mozilla::dom::ChangeAttributeTxn to mozilla::ChangeAttributeTransaction (and their files too) r=mccr8 draft
authorMasayuki Nakano <masayuki@d-toybox.com>
Thu, 07 Jul 2016 14:12:30 +0900
changeset 385849 80a00db65a92bf6006854257183f5936dee909a1
parent 385848 f930df6ac779821ebde9190509b84df4034a275a
child 385850 83f109a345f3ffbf5772ccaa87929f1bce5e7b13
push id22587
push usermasayuki@d-toybox.com
push dateSat, 09 Jul 2016 06:59:31 +0000
reviewersmccr8
bugs1260651
milestone50.0a1
Bug 1260651 part.17 Rename mozilla::dom::ChangeAttributeTxn to mozilla::ChangeAttributeTransaction (and their files too) r=mccr8 MozReview-Commit-ID: B15OBauxqSN
editor/libeditor/ChangeAttributeTransaction.cpp
editor/libeditor/ChangeAttributeTransaction.h
editor/libeditor/ChangeAttributeTxn.cpp
editor/libeditor/ChangeAttributeTxn.h
editor/libeditor/moz.build
editor/libeditor/nsEditor.cpp
editor/libeditor/nsEditor.h
rename from editor/libeditor/ChangeAttributeTxn.cpp
rename to editor/libeditor/ChangeAttributeTransaction.cpp
--- a/editor/libeditor/ChangeAttributeTxn.cpp
+++ b/editor/libeditor/ChangeAttributeTransaction.cpp
@@ -1,49 +1,51 @@
 /* -*- 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 "ChangeAttributeTxn.h"
+#include "ChangeAttributeTransaction.h"
 
 #include "mozilla/dom/Element.h"        // for Element
 
 #include "nsAString.h"
 #include "nsError.h"                    // for NS_ERROR_NOT_INITIALIZED, etc
 
-using namespace mozilla;
-using namespace mozilla::dom;
+namespace mozilla {
+
+using namespace dom;
 
-ChangeAttributeTxn::ChangeAttributeTxn(Element& aElement, nsIAtom& aAttribute,
-                                       const nsAString* aValue)
+ChangeAttributeTransaction::ChangeAttributeTransaction(Element& aElement,
+                                                       nsIAtom& aAttribute,
+                                                       const nsAString* aValue)
   : EditTxn()
   , mElement(&aElement)
   , mAttribute(&aAttribute)
   , mValue(aValue ? *aValue : EmptyString())
   , mRemoveAttribute(!aValue)
   , mAttributeWasSet(false)
   , mUndoValue()
 {
 }
 
-ChangeAttributeTxn::~ChangeAttributeTxn()
+ChangeAttributeTransaction::~ChangeAttributeTransaction()
 {
 }
 
-NS_IMPL_CYCLE_COLLECTION_INHERITED(ChangeAttributeTxn, EditTxn,
+NS_IMPL_CYCLE_COLLECTION_INHERITED(ChangeAttributeTransaction, EditTxn,
                                    mElement)
 
-NS_IMPL_ADDREF_INHERITED(ChangeAttributeTxn, EditTxn)
-NS_IMPL_RELEASE_INHERITED(ChangeAttributeTxn, EditTxn)
-NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(ChangeAttributeTxn)
+NS_IMPL_ADDREF_INHERITED(ChangeAttributeTransaction, EditTxn)
+NS_IMPL_RELEASE_INHERITED(ChangeAttributeTransaction, EditTxn)
+NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(ChangeAttributeTransaction)
 NS_INTERFACE_MAP_END_INHERITING(EditTxn)
 
 NS_IMETHODIMP
-ChangeAttributeTxn::DoTransaction()
+ChangeAttributeTransaction::DoTransaction()
 {
   // Need to get the current value of the attribute and save it, and set
   // mAttributeWasSet
   mAttributeWasSet = mElement->GetAttr(kNameSpaceID_None, mAttribute,
                                        mUndoValue);
 
   // XXX: hack until attribute-was-set code is implemented
   if (!mUndoValue.IsEmpty()) {
@@ -55,39 +57,41 @@ ChangeAttributeTxn::DoTransaction()
   if (mRemoveAttribute) {
     return mElement->UnsetAttr(kNameSpaceID_None, mAttribute, true);
   }
 
   return mElement->SetAttr(kNameSpaceID_None, mAttribute, mValue, true);
 }
 
 NS_IMETHODIMP
-ChangeAttributeTxn::UndoTransaction()
+ChangeAttributeTransaction::UndoTransaction()
 {
   if (mAttributeWasSet) {
     return mElement->SetAttr(kNameSpaceID_None, mAttribute, mUndoValue, true);
   }
   return mElement->UnsetAttr(kNameSpaceID_None, mAttribute, true);
 }
 
 NS_IMETHODIMP
-ChangeAttributeTxn::RedoTransaction()
+ChangeAttributeTransaction::RedoTransaction()
 {
   if (mRemoveAttribute) {
     return mElement->UnsetAttr(kNameSpaceID_None, mAttribute, true);
   }
 
   return mElement->SetAttr(kNameSpaceID_None, mAttribute, mValue, true);
 }
 
 NS_IMETHODIMP
-ChangeAttributeTxn::GetTxnDescription(nsAString& aString)
+ChangeAttributeTransaction::GetTxnDescription(nsAString& aString)
 {
-  aString.AssignLiteral("ChangeAttributeTxn: [mRemoveAttribute == ");
+  aString.AssignLiteral("ChangeAttributeTransaction: [mRemoveAttribute == ");
 
   if (mRemoveAttribute) {
     aString.AppendLiteral("true] ");
   } else {
     aString.AppendLiteral("false] ");
   }
   aString += nsDependentAtomString(mAttribute);
   return NS_OK;
 }
+
+} // namespace mozilla
rename from editor/libeditor/ChangeAttributeTxn.h
rename to editor/libeditor/ChangeAttributeTransaction.h
--- a/editor/libeditor/ChangeAttributeTxn.h
+++ b/editor/libeditor/ChangeAttributeTransaction.h
@@ -1,69 +1,71 @@
 /* -*- 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 ChangeAttributeTxn_h__
-#define ChangeAttributeTxn_h__
+#ifndef ChangeAttributeTransaction_h
+#define ChangeAttributeTransaction_h
 
 #include "EditTxn.h"                      // base class
 #include "mozilla/Attributes.h"           // override
 #include "nsCOMPtr.h"                     // nsCOMPtr members
 #include "nsCycleCollectionParticipant.h" // NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED
 #include "nsISupportsImpl.h"              // NS_DECL_ISUPPORTS_INHERITED
 #include "nsString.h"                     // nsString members
 
 class nsIAtom;
 
 namespace mozilla {
+
 namespace dom {
-
 class Element;
+} // namespace dom
 
 /**
  * A transaction that changes an attribute of a content node.  This transaction
  * covers add, remove, and change attribute.
  */
-class ChangeAttributeTxn : public EditTxn
+class ChangeAttributeTransaction final : public EditTxn
 {
 public:
-  /** @param aElement the element whose attribute will be changed
-    * @param aAttribute the name of the attribute to change
-    * @param aValue     the new value for aAttribute, or null to remove
-    */
-  ChangeAttributeTxn(Element& aElement, nsIAtom& aAttribute,
-                     const nsAString* aValue);
+  /**
+   * @param aElement   the element whose attribute will be changed
+   * @param aAttribute the name of the attribute to change
+   * @param aValue     the new value for aAttribute, or null to remove
+   */
+  ChangeAttributeTransaction(dom::Element& aElement,
+                             nsIAtom& aAttribute,
+                             const nsAString* aValue);
 
   NS_DECL_ISUPPORTS_INHERITED
-  NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(ChangeAttributeTxn, EditTxn)
+  NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(ChangeAttributeTransaction, EditTxn)
 
   NS_DECL_EDITTXN
 
   NS_IMETHOD RedoTransaction() override;
 
 private:
-  virtual ~ChangeAttributeTxn();
+  virtual ~ChangeAttributeTransaction();
 
-  /** The element to operate upon */
-  nsCOMPtr<Element> mElement;
+  // The element to operate upon
+  nsCOMPtr<dom::Element> mElement;
 
-  /** The attribute to change */
+  // The attribute to change
   nsCOMPtr<nsIAtom> mAttribute;
 
-  /** The value to set the attribute to (ignored if mRemoveAttribute==true) */
+  // The value to set the attribute to (ignored if mRemoveAttribute==true)
   nsString mValue;
 
-  /** True if the operation is to remove mAttribute from mElement */
+  // True if the operation is to remove mAttribute from mElement
   bool mRemoveAttribute;
 
-  /** True if the mAttribute was set on mElement at the time of execution */
+  // True if the mAttribute was set on mElement at the time of execution
   bool mAttributeWasSet;
 
-  /** The value to set the attribute to for undo */
+  // The value to set the attribute to for undo
   nsString mUndoValue;
 };
 
-} // namespace dom
 } // namespace mozilla
 
-#endif
+#endif // #ifndef ChangeAttributeTransaction_h
--- a/editor/libeditor/moz.build
+++ b/editor/libeditor/moz.build
@@ -9,17 +9,17 @@ MOCHITEST_MANIFESTS += [
     'tests/mochitest.ini',
 ]
 
 MOCHITEST_CHROME_MANIFESTS += ['tests/chrome.ini']
 
 BROWSER_CHROME_MANIFESTS += ['tests/browser.ini']
 
 UNIFIED_SOURCES += [
-    'ChangeAttributeTxn.cpp',
+    'ChangeAttributeTransaction.cpp',
     'ChangeStyleTxn.cpp',
     'CreateElementTxn.cpp',
     'DeleteNodeTxn.cpp',
     'DeleteRangeTxn.cpp',
     'DeleteTextTxn.cpp',
     'EditAggregateTxn.cpp',
     'EditorUtils.cpp',
     'EditTxn.cpp',
--- a/editor/libeditor/nsEditor.cpp
+++ b/editor/libeditor/nsEditor.cpp
@@ -5,17 +5,17 @@
 
 #include "nsEditor.h"
 
 #include "mozilla/DebugOnly.h"          // for DebugOnly
 
 #include <stdio.h>                      // for nullptr, stdout
 #include <string.h>                     // for strcmp
 
-#include "ChangeAttributeTxn.h"         // for ChangeAttributeTxn
+#include "ChangeAttributeTransaction.h" // for ChangeAttributeTransaction
 #include "CreateElementTxn.h"           // for CreateElementTxn
 #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
@@ -1194,19 +1194,19 @@ nsEditor::CanPasteTransferable(nsITransf
 NS_IMETHODIMP
 nsEditor::SetAttribute(nsIDOMElement* aElement, const nsAString& aAttribute,
                        const nsAString& aValue)
 {
   nsCOMPtr<Element> element = do_QueryInterface(aElement);
   NS_ENSURE_TRUE(element, NS_ERROR_NULL_POINTER);
   nsCOMPtr<nsIAtom> attribute = NS_Atomize(aAttribute);
 
-  RefPtr<ChangeAttributeTxn> txn =
+  RefPtr<ChangeAttributeTransaction> transaction =
     CreateTxnForSetAttribute(*element, *attribute, aValue);
-  return DoTransaction(txn);
+  return DoTransaction(transaction);
 }
 
 NS_IMETHODIMP
 nsEditor::GetAttributeValue(nsIDOMElement *aElement,
                             const nsAString & aAttribute,
                             nsAString & aResultValue,
                             bool *aResultIsSet)
 {
@@ -1227,19 +1227,19 @@ nsEditor::GetAttributeValue(nsIDOMElemen
 
 NS_IMETHODIMP
 nsEditor::RemoveAttribute(nsIDOMElement* aElement, const nsAString& aAttribute)
 {
   nsCOMPtr<Element> element = do_QueryInterface(aElement);
   NS_ENSURE_TRUE(element, NS_ERROR_NULL_POINTER);
   nsCOMPtr<nsIAtom> attribute = NS_Atomize(aAttribute);
 
-  RefPtr<ChangeAttributeTxn> txn =
+  RefPtr<ChangeAttributeTransaction> transaction =
     CreateTxnForRemoveAttribute(*element, *attribute);
-  return DoTransaction(txn);
+  return DoTransaction(transaction);
 }
 
 
 bool
 nsEditor::OutputsMozDirty()
 {
   // Return true for Composer (!eEditorAllowInteraction) or mail
   // (eEditorMailMask), but false for webpages.
@@ -4166,34 +4166,34 @@ nsEditor::DoAfterUndoTransaction()
 
 void
 nsEditor::DoAfterRedoTransaction()
 {
   // all redoable transactions are non-transient
   MOZ_ALWAYS_SUCCEEDS(IncrementModificationCount(1));
 }
 
-already_AddRefed<ChangeAttributeTxn>
+already_AddRefed<ChangeAttributeTransaction>
 nsEditor::CreateTxnForSetAttribute(Element& aElement, nsIAtom& aAttribute,
                                    const nsAString& aValue)
 {
-  RefPtr<ChangeAttributeTxn> txn =
-    new ChangeAttributeTxn(aElement, aAttribute, &aValue);
-
-  return txn.forget();
-}
-
-
-already_AddRefed<ChangeAttributeTxn>
+  RefPtr<ChangeAttributeTransaction> transaction =
+    new ChangeAttributeTransaction(aElement, aAttribute, &aValue);
+
+  return transaction.forget();
+}
+
+
+already_AddRefed<ChangeAttributeTransaction>
 nsEditor::CreateTxnForRemoveAttribute(Element& aElement, nsIAtom& aAttribute)
 {
-  RefPtr<ChangeAttributeTxn> txn =
-    new ChangeAttributeTxn(aElement, aAttribute, nullptr);
-
-  return txn.forget();
+  RefPtr<ChangeAttributeTransaction> transaction =
+    new ChangeAttributeTransaction(aElement, aAttribute, nullptr);
+
+  return transaction.forget();
 }
 
 
 already_AddRefed<CreateElementTxn>
 nsEditor::CreateTxnForCreateElement(nsIAtom& aTag,
                                     nsINode& aParent,
                                     int32_t aPosition)
 {
--- a/editor/libeditor/nsEditor.h
+++ b/editor/libeditor/nsEditor.h
@@ -52,22 +52,22 @@ class nsIWidget;
 class nsRange;
 class nsString;
 class nsTransactionManager;
 
 namespace mozilla {
 class AutoRules;
 class AutoSelectionRestorer;
 class AutoTransactionsConserveSelection;
+class ChangeAttributeTransaction;
 class ErrorResult;
 class TextComposition;
 struct EditorDOMPoint;
 
 namespace dom {
-class ChangeAttributeTxn;
 class CreateElementTxn;
 class DataTransfer;
 class DeleteTextTxn;
 class Element;
 class EventTarget;
 class IMETextTxn;
 class InsertTextTxn;
 class InsertNodeTxn;
@@ -251,24 +251,24 @@ public:
 
 protected:
   nsresult DetermineCurrentDirection();
   void FireInputEvent();
 
   /** Create a transaction for setting aAttribute to aValue on aElement.  Never
     * returns null.
     */
-  already_AddRefed<mozilla::dom::ChangeAttributeTxn>
+  already_AddRefed<mozilla::ChangeAttributeTransaction>
   CreateTxnForSetAttribute(Element& aElement, nsIAtom& aAttribute,
                            const nsAString& aValue);
 
   /** Create a transaction for removing aAttribute on aElement.  Never returns
     * null.
     */
-  already_AddRefed<mozilla::dom::ChangeAttributeTxn>
+  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>
   CreateTxnForCreateElement(nsIAtom& aTag,
                             nsINode& aParent,
                             int32_t aPosition);