Bug 1260651 part.28 Rename SetDocTitleTxn to mozilla::SetDocumentTitleTransaction (and their files too) r?mccr8 draft
authorMasayuki Nakano <masayuki@d-toybox.com>
Thu, 07 Jul 2016 16:50:17 +0900
changeset 385718 5e88655303cc75082ba6f7a94813da7057fb1c60
parent 385717 20307bb4cda198a7b0ed9948ced8c91455652647
child 385719 728d69e58ecf4f2b69528554cd4ee36266de651c
push id22582
push usermasayuki@d-toybox.com
push dateSat, 09 Jul 2016 03:13:39 +0000
reviewersmccr8
bugs1260651
milestone50.0a1
Bug 1260651 part.28 Rename SetDocTitleTxn to mozilla::SetDocumentTitleTransaction (and their files too) r?mccr8 MozReview-Commit-ID: GmVEYr3ZJEl
editor/libeditor/SetDocTitleTxn.cpp
editor/libeditor/SetDocTitleTxn.h
editor/libeditor/SetDocumentTitleTransaction.cpp
editor/libeditor/SetDocumentTitleTransaction.h
editor/libeditor/moz.build
editor/libeditor/nsHTMLEditor.cpp
rename from editor/libeditor/SetDocTitleTxn.cpp
rename to editor/libeditor/SetDocumentTitleTransaction.cpp
--- a/editor/libeditor/SetDocTitleTxn.cpp
+++ b/editor/libeditor/SetDocumentTitleTransaction.cpp
@@ -1,71 +1,75 @@
 /* -*- 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 "SetDocTitleTxn.h"
+#include "SetDocumentTitleTransaction.h"
 #include "mozilla/dom/Element.h"        // for Element
 #include "nsAString.h"
 #include "nsCOMPtr.h"                   // for nsCOMPtr, getter_AddRefs, etc
 #include "nsDebug.h"                    // for NS_ENSURE_SUCCESS, etc
 #include "nsError.h"                    // for NS_OK, NS_ERROR_FAILURE, etc
 #include "nsIDOMCharacterData.h"        // for nsIDOMCharacterData
 #include "nsIDOMDocument.h"             // for nsIDOMDocument
 #include "nsIDOMElement.h"              // for nsIDOMElement
 #include "nsIDOMNode.h"                 // for nsIDOMNode
 #include "nsIDOMNodeList.h"             // for nsIDOMNodeList
 #include "nsIDOMText.h"                 // for nsIDOMText
 #include "nsIDocument.h"                // for nsIDocument
 #include "nsIEditor.h"                  // for nsIEditor
 #include "nsIHTMLEditor.h"              // for nsIHTMLEditor
 #include "nsLiteralString.h"            // for NS_LITERAL_STRING
 
-using namespace mozilla;
+namespace mozilla {
 
-// note that aEditor is not refcounted
-SetDocTitleTxn::SetDocTitleTxn()
-  : EditTxn()
-  , mEditor(nullptr)
+// Note that aEditor is not refcounted.
+SetDocumentTitleTransaction::SetDocumentTitleTransaction()
+  : mEditor(nullptr)
   , mIsTransient(false)
 {
 }
 
-NS_IMETHODIMP SetDocTitleTxn::Init(nsIHTMLEditor *aEditor,
-                                   const nsAString *aValue)
+NS_IMETHODIMP
+SetDocumentTitleTransaction::Init(nsIHTMLEditor* aEditor,
+                                  const nsAString* aValue)
 
 {
   NS_ASSERTION(aEditor && aValue, "null args");
   if (!aEditor || !aValue) { return NS_ERROR_NULL_POINTER; }
 
   mEditor = aEditor;
   mValue = *aValue;
 
   return NS_OK;
 }
 
-NS_IMETHODIMP SetDocTitleTxn::DoTransaction(void)
+NS_IMETHODIMP
+SetDocumentTitleTransaction::DoTransaction()
 {
   return SetDomTitle(mValue);
 }
 
-NS_IMETHODIMP SetDocTitleTxn::UndoTransaction(void)
+NS_IMETHODIMP
+SetDocumentTitleTransaction::UndoTransaction()
 {
   // No extra work required; the DOM changes alone are enough
   return NS_OK;
 }
 
-NS_IMETHODIMP SetDocTitleTxn::RedoTransaction(void)
+NS_IMETHODIMP
+SetDocumentTitleTransaction::RedoTransaction()
 {
   // No extra work required; the DOM changes alone are enough
   return NS_OK;
 }
 
-nsresult SetDocTitleTxn::SetDomTitle(const nsAString& aTitle)
+nsresult
+SetDocumentTitleTransaction::SetDomTitle(const nsAString& aTitle)
 {
   nsCOMPtr<nsIEditor> editor = do_QueryInterface(mEditor);
   NS_ENSURE_TRUE(editor, NS_ERROR_FAILURE);
   nsCOMPtr<nsIDOMDocument> domDoc;
   nsresult res = editor->GetDocument(getter_AddRefs(domDoc));
   NS_ENSURE_TRUE(domDoc, NS_ERROR_FAILURE);
 
   nsCOMPtr<nsIDOMNodeList> titleList;
@@ -162,22 +166,25 @@ nsresult SetDocTitleTxn::SetDomTitle(con
   if (newTitleNode)
   {
     // Undoable transaction to insert title+text together
     res = editor->InsertNode(titleNode, head->AsDOMNode(), newTitleIndex);
   }
   return res;
 }
 
-NS_IMETHODIMP SetDocTitleTxn::GetTxnDescription(nsAString& aString)
+NS_IMETHODIMP
+SetDocumentTitleTransaction::GetTxnDescription(nsAString& aString)
 {
-  aString.AssignLiteral("SetDocTitleTxn: ");
+  aString.AssignLiteral("SetDocumentTitleTransaction: ");
   aString += mValue;
   return NS_OK;
 }
 
-NS_IMETHODIMP SetDocTitleTxn::GetIsTransient(bool *aIsTransient)
+NS_IMETHODIMP
+SetDocumentTitleTransaction::GetIsTransient(bool* aIsTransient)
 {
   NS_ENSURE_TRUE(aIsTransient, NS_ERROR_NULL_POINTER);
   *aIsTransient = mIsTransient;
   return NS_OK;
 }
 
+} // namespace mozilla
rename from editor/libeditor/SetDocTitleTxn.h
rename to editor/libeditor/SetDocumentTitleTransaction.h
--- a/editor/libeditor/SetDocTitleTxn.h
+++ b/editor/libeditor/SetDocumentTitleTransaction.h
@@ -1,54 +1,60 @@
 /* -*- 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 SetDocTitleTxn_h__
-#define SetDocTitleTxn_h__
+#ifndef SetDocumentTitleTransaction_h
+#define SetDocumentTitleTransaction_h
 
 #include "EditTxn.h"                    // for EditTxn, NS_DECL_EDITTXN
 #include "nsString.h"                   // for nsString
 #include "nscore.h"                     // for NS_IMETHOD, nsAString, etc
 
 class nsIHTMLEditor;
 
+namespace mozilla {
+
 /**
  * A transaction that changes the document's title,
  *  which is a text node under the <title> tag in a page's <head> section
  * provides default concrete behavior for all nsITransaction methods.
  */
-class SetDocTitleTxn : public EditTxn
+class SetDocumentTitleTransaction final : public EditTxn
 {
 public:
-  /** Initialize the transaction.
-    * @param aEditor the object providing core editing operations
-    * @param aValue  the new value for document title
-    */
-  NS_IMETHOD Init(nsIHTMLEditor  *aEditor,
-                  const nsAString *aValue);
-  SetDocTitleTxn();
+  /**
+   * Initialize the transaction.
+   * @param aEditor     The object providing core editing operations.
+   * @param aValue      The new value for document title.
+   */
+  NS_IMETHOD Init(nsIHTMLEditor* aEditor,
+                  const nsAString* aValue);
+  SetDocumentTitleTransaction();
+
 private:
   nsresult SetDomTitle(const nsAString& aTitle);
 
 public:
   NS_DECL_EDITTXN
 
   NS_IMETHOD RedoTransaction() override;
   NS_IMETHOD GetIsTransient(bool *aIsTransient) override;
 
 protected:
 
-  /** the editor that created this transaction */
-  nsIHTMLEditor*  mEditor;
+  // The editor that created this transaction.
+  nsIHTMLEditor* mEditor;
 
-  /** The new title string */
-  nsString    mValue;
+  // The new title string.
+  nsString mValue;
 
-  /** The previous title string to use for undo */
-  nsString    mUndoValue;
+  // The previous title string to use for undo.
+  nsString mUndoValue;
 
-  /** Set true if we dont' really change the title during Do() */
+  // Set true if we dont' really change the title during Do().
   bool mIsTransient;
 };
 
-#endif
+} // namespace mozilla
+
+#endif // #ifndef SetDocumentTitleTransaction_h
--- a/editor/libeditor/moz.build
+++ b/editor/libeditor/moz.build
@@ -48,17 +48,17 @@ UNIFIED_SOURCES += [
     'nsPlaintextEditor.cpp',
     'nsSelectionState.cpp',
     'nsStyleSheetTxns.cpp',
     'nsTableEditor.cpp',
     'nsTextEditRules.cpp',
     'nsTextEditRulesBidi.cpp',
     'nsWSRunObject.cpp',
     'PlaceholderTransaction.cpp',
-    'SetDocTitleTxn.cpp',
+    'SetDocumentTitleTransaction.cpp',
     'SplitNodeTxn.cpp',
     'TextEditorTest.cpp',
     'TextEditUtils.cpp',
     'TypeInState.cpp',
 ]
 
 LOCAL_INCLUDES += [
     '/dom/base',
--- a/editor/libeditor/nsHTMLEditor.cpp
+++ b/editor/libeditor/nsHTMLEditor.cpp
@@ -9,16 +9,17 @@
 #include "mozilla/EventStates.h"
 #include "mozilla/TextEvents.h"
 
 #include "nsCRT.h"
 
 #include "nsUnicharUtils.h"
 
 #include "HTMLEditUtils.h"
+#include "SetDocumentTitleTransaction.h"
 #include "TextEditUtils.h"
 #include "nsHTMLEditRules.h"
 
 #include "nsHTMLEditorEventListener.h"
 #include "TypeInState.h"
 
 #include "nsHTMLURIRefObject.h"
 
@@ -42,17 +43,16 @@
 
 #include "nsIContent.h"
 #include "nsIContentIterator.h"
 #include "nsISupportsArray.h"
 #include "nsContentUtils.h"
 #include "nsIDocumentEncoder.h"
 #include "nsIPresShell.h"
 #include "nsPresContext.h"
-#include "SetDocTitleTxn.h"
 #include "nsFocusManager.h"
 #include "nsPIDOMWindow.h"
 
 // netwerk
 #include "nsIURI.h"
 #include "nsNetUtil.h"
 
 // Transactionas
@@ -818,25 +818,26 @@ nsHTMLEditor::IsBlockNode(nsINode *aNode
 {
   return aNode && NodeIsBlockStatic(aNode);
 }
 
 // Non-static version for the nsIEditor interface and JavaScript
 NS_IMETHODIMP
 nsHTMLEditor::SetDocumentTitle(const nsAString &aTitle)
 {
-  RefPtr<SetDocTitleTxn> txn = new SetDocTitleTxn();
-  NS_ENSURE_TRUE(txn, NS_ERROR_OUT_OF_MEMORY);
-
-  nsresult result = txn->Init(this, &aTitle);
-  NS_ENSURE_SUCCESS(result, result);
+  RefPtr<SetDocumentTitleTransaction> transaction =
+    new SetDocumentTitleTransaction();
+  NS_ENSURE_TRUE(transaction, NS_ERROR_OUT_OF_MEMORY);
+
+  nsresult rv = transaction->Init(this, &aTitle);
+  NS_ENSURE_SUCCESS(rv, rv);
 
   //Don't let Rules System change the selection
   AutoTransactionsConserveSelection dontChangeSelection(this);
-  return nsEditor::DoTransaction(txn);
+  return nsEditor::DoTransaction(transaction);
 }
 
 /* ------------ Block methods moved from nsEditor -------------- */
 ///////////////////////////////////////////////////////////////////////////
 // GetBlockNodeParent: returns enclosing block level ancestor, if any
 //
 Element*
 nsHTMLEditor::GetBlockNodeParent(nsINode* aNode)