Bug 1260651 part.8 Rename mozilla::dom::ChangeAttributeTxn to mozilla::ChangeAttributeTransaction r?ehsan draft
authorMasayuki Nakano <masayuki@d-toybox.com>
Fri, 15 Apr 2016 23:58:23 +0900
changeset 354807 1ced37a6e9ae2ac9e998fad7edf3936451e1cbf5
parent 354806 82a7ef528c75a95c3ac1a6c34f2ec714da6c64e0
child 354808 1b3625846dab1c92527143a4cce4aa5d86bb0bbc
push id16162
push usermasayuki@d-toybox.com
push dateThu, 21 Apr 2016 15:03:04 +0000
reviewersehsan
bugs1260651
milestone48.0a1
Bug 1260651 part.8 Rename mozilla::dom::ChangeAttributeTxn to mozilla::ChangeAttributeTransaction r?ehsan MozReview-Commit-ID: Gg3Re7rUPVI
editor/libeditor/ChangeAttributeTransaction.cpp
editor/libeditor/ChangeAttributeTransaction.h
editor/libeditor/ChangeAttributeTxn.cpp
editor/libeditor/ChangeAttributeTxn.h
editor/libeditor/EditorBase.cpp
editor/libeditor/EditorBase.h
editor/libeditor/moz.build
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,56 +1,58 @@
 /* -*- 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;
+  nsCOMPtr<dom::Element> mElement;
 
   /** The attribute to change */
   nsCOMPtr<nsIAtom> mAttribute;
 
   /** The value to set the attribute to (ignored if mRemoveAttribute==true) */
   nsString mValue;
 
   /** True if the operation is to remove mAttribute from mElement */
@@ -58,12 +60,11 @@ private:
 
   /** True if the mAttribute was set on mElement at the time of execution */
   bool mAttributeWasSet;
 
   /** The value to set the attribute to for undo */
   nsString mUndoValue;
 };
 
-} // namespace dom
 } // namespace mozilla
 
-#endif
+#endif // #ifndef ChangeAttributeTranaction_h_
--- a/editor/libeditor/EditorBase.cpp
+++ b/editor/libeditor/EditorBase.cpp
@@ -5,17 +5,17 @@
 
 #include "EditorBase.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 "EditorCommonEventListener.h"  // for EditorCommonEventListener
 #include "EditTxn.h"                    // for EditTxn
 #include "IMETextTxn.h"                 // for IMETextTxn
@@ -1210,19 +1210,19 @@ NS_IMETHODIMP
 EditorBase::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
 EditorBase::GetAttributeValue(nsIDOMElement* aElement,
                               const nsAString& aAttribute,
                               nsAString& aResultValue,
                               bool* aResultIsSet)
 {
@@ -1244,19 +1244,19 @@ EditorBase::GetAttributeValue(nsIDOMElem
 NS_IMETHODIMP
 EditorBase::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
 EditorBase::OutputsMozDirty()
 {
   // Return true for Composer (!eEditorAllowInteraction) or mail
   // (eEditorMailMask), but false for webpages.
@@ -4241,38 +4241,34 @@ EditorBase::DoAfterUndoTransaction()
 
 void
 EditorBase::DoAfterRedoTransaction()
 {
   // all redoable transactions are non-transient
   MOZ_ALWAYS_SUCCEEDS(IncrementModificationCount(1));
 }
 
-already_AddRefed<ChangeAttributeTxn>
+already_AddRefed<ChangeAttributeTransaction>
 EditorBase::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>
 EditorBase::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>
 EditorBase::CreateTxnForCreateElement(nsIAtom& aTag,
                                       nsINode& aParent,
                                       int32_t aPosition)
 {
   RefPtr<CreateElementTxn> txn =
     new CreateElementTxn(*this, aTag, aParent, aPosition);
--- a/editor/libeditor/EditorBase.h
+++ b/editor/libeditor/EditorBase.h
@@ -55,21 +55,21 @@ class nsISupports;
 class nsITransaction;
 class nsIWidget;
 class nsRange;
 class nsString;
 class nsTransactionManager;
 struct DOMPoint;
 
 namespace mozilla {
+class ChangeAttributeTransaction;
 class ErrorResult;
 class TextComposition;
 
 namespace dom {
-class ChangeAttributeTxn;
 class CreateElementTxn;
 class DataTransfer;
 class DeleteTextTxn;
 class Element;
 class EventTarget;
 class IMETextTxn;
 class InsertTextTxn;
 class InsertNodeTxn;
@@ -249,24 +249,24 @@ public:
 
 protected:
   nsresult DetermineCurrentDirection();
   void FireInputEvent();
 
   /** Create a transaction for setting aAttribute to aValue on aElement.  Never
     * returns null.
     */
-  already_AddRefed<dom::ChangeAttributeTxn>
+  already_AddRefed<ChangeAttributeTransaction>
   CreateTxnForSetAttribute(dom::Element& aElement,
                            nsIAtom& aAttribute, const nsAString& aValue);
 
   /** Create a transaction for removing aAttribute on aElement.  Never returns
     * null.
     */
-  already_AddRefed<dom::ChangeAttributeTxn>
+  already_AddRefed<ChangeAttributeTransaction>
   CreateTxnForRemoveAttribute(dom::Element& aElement,
                               nsIAtom& aAttribute);
 
   /** create a transaction for creating a new child node of aParent of type aTag.
     */
   already_AddRefed<dom::CreateElementTxn>
   CreateTxnForCreateElement(nsIAtom& aTag,
                             nsINode& aParent,
--- 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',
     'EditorBase.cpp',
     'EditorCommonEventListener.cpp',