Bug 1260651 part.15 Rename nsAutoEditInitRulesTrigger to mozilla::AutoEditInitRulesTrigger r=mccr8 draft
authorMasayuki Nakano <masayuki@d-toybox.com>
Thu, 23 Jun 2016 19:18:13 +0900
changeset 385705 1c10d837dc6fc9fb04729eab4e2c2706febc003f
parent 385704 5931c0c7cf3825b04245db0d265caeb616746a95
child 385706 de2f4956d4481632d0ad84ed575266ca79903a79
push id22582
push usermasayuki@d-toybox.com
push dateSat, 09 Jul 2016 03:13:39 +0000
reviewersmccr8
bugs1260651
milestone50.0a1
Bug 1260651 part.15 Rename nsAutoEditInitRulesTrigger to mozilla::AutoEditInitRulesTrigger r=mccr8 MozReview-Commit-ID: Hp2BfbbGckt
editor/libeditor/TextEditUtils.cpp
editor/libeditor/TextEditUtils.h
editor/libeditor/nsHTMLEditor.cpp
editor/libeditor/nsPlaintextEditor.cpp
editor/libeditor/nsPlaintextEditor.h
--- a/editor/libeditor/TextEditUtils.cpp
+++ b/editor/libeditor/TextEditUtils.cpp
@@ -18,16 +18,20 @@
 #include "nsIDOMNode.h"
 #include "nsNameSpaceManager.h"
 #include "nsLiteralString.h"
 #include "nsPlaintextEditor.h"
 #include "nsString.h"
 
 namespace mozilla {
 
+/******************************************************************************
+ * TextEditUtils
+ ******************************************************************************/
+
 /**
  * IsBody() returns true if aNode is an html body node.
  */
 bool
 TextEditUtils::IsBody(nsIDOMNode* aNode)
 {
   return nsEditor::NodeIsType(aNode, nsGkAtoms::body);
 }
@@ -81,23 +85,31 @@ TextEditUtils::HasMozAttr(nsIDOMNode* aN
   if (!element) {
     return false;
   }
   nsAutoString typeAttrVal;
   nsresult rv = element->GetAttribute(NS_LITERAL_STRING("type"), typeAttrVal);
   return NS_SUCCEEDED(rv) && typeAttrVal.LowerCaseEqualsLiteral("_moz");
 }
 
-} // namespace mozilla
+/******************************************************************************
+ * AutoEditInitRulesTrigger
+ ******************************************************************************/
 
-///////////////////////////////////////////////////////////////////////////
-// nsAutoEditInitRulesTrigger methods
-//
-nsAutoEditInitRulesTrigger::nsAutoEditInitRulesTrigger( nsPlaintextEditor *aEd, nsresult &aRes) : mEd(aEd), mRes(aRes)
+AutoEditInitRulesTrigger::AutoEditInitRulesTrigger(
+                            nsPlaintextEditor* aTextEditor,
+                            nsresult& aResult)
+  : mTextEditor(aTextEditor)
+  , mResult(aResult)
 {
-    if (mEd) mEd->BeginEditorInit();
+  if (mTextEditor) {
+    mTextEditor->BeginEditorInit();
+  }
 }
 
-nsAutoEditInitRulesTrigger::~nsAutoEditInitRulesTrigger()
+AutoEditInitRulesTrigger::~AutoEditInitRulesTrigger()
 {
-    if (mEd) mRes = mEd->EndEditorInit();
+  if (mTextEditor) {
+    mResult = mTextEditor->EndEditorInit();
+  }
 }
 
+} // namespace mozilla
--- a/editor/libeditor/TextEditUtils.h
+++ b/editor/libeditor/TextEditUtils.h
@@ -21,25 +21,26 @@ public:
   static bool IsBody(nsIDOMNode* aNode);
   static bool IsBreak(nsIDOMNode* aNode);
   static bool IsBreak(nsINode* aNode);
   static bool IsMozBR(nsIDOMNode* aNode);
   static bool IsMozBR(nsINode* aNode);
   static bool HasMozAttr(nsIDOMNode* aNode);
 };
 
-} // naemspace mozilla
-
 /***************************************************************************
  * stack based helper class for detecting end of editor initialization, in
  * order to trigger "end of init" initialization of the edit rules.
  */
-class nsAutoEditInitRulesTrigger
+class AutoEditInitRulesTrigger final
 {
 private:
-  nsPlaintextEditor* mEd;
-  nsresult& mRes;
+  nsPlaintextEditor* mTextEditor;
+  nsresult& mResult;
+
 public:
-  nsAutoEditInitRulesTrigger(nsPlaintextEditor* aEd, nsresult& aRes);
-  ~nsAutoEditInitRulesTrigger();
+  AutoEditInitRulesTrigger(nsPlaintextEditor* aTextEditor, nsresult& aResult);
+  ~AutoEditInitRulesTrigger();
 };
 
+} // naemspace mozilla
+
 #endif // #ifndef TextEditUtils_h
--- a/editor/libeditor/nsHTMLEditor.cpp
+++ b/editor/libeditor/nsHTMLEditor.cpp
@@ -261,18 +261,18 @@ nsHTMLEditor::Init(nsIDOMDocument *aDoc,
   NS_PRECONDITION(aDoc && !aSelCon, "bad arg");
   NS_ENSURE_TRUE(aDoc, NS_ERROR_NULL_POINTER);
   MOZ_ASSERT(aInitialValue.IsEmpty(), "Non-empty initial values not supported");
 
   nsresult result = NS_OK, rulesRes = NS_OK;
 
   if (1)
   {
-    // block to scope nsAutoEditInitRulesTrigger
-    nsAutoEditInitRulesTrigger rulesTrigger(static_cast<nsPlaintextEditor*>(this), rulesRes);
+    // block to scope AutoEditInitRulesTrigger
+    AutoEditInitRulesTrigger rulesTrigger(this, rulesRes);
 
     // Init the plaintext editor
     result = nsPlaintextEditor::Init(aDoc, aRoot, nullptr, aFlags, aInitialValue);
     if (NS_FAILED(result)) { return result; }
 
     // Init mutation observer
     nsCOMPtr<nsINode> document = do_QueryInterface(aDoc);
     document->AddMutationObserverUnlessExists(this);
--- a/editor/libeditor/nsPlaintextEditor.cpp
+++ b/editor/libeditor/nsPlaintextEditor.cpp
@@ -124,18 +124,18 @@ NS_IMETHODIMP nsPlaintextEditor::Init(ns
   NS_ENSURE_TRUE(aDoc, NS_ERROR_NULL_POINTER);
 
   nsresult res = NS_OK, rulesRes = NS_OK;
   if (mRules) {
     mRules->DetachEditor();
   }
 
   {
-    // block to scope nsAutoEditInitRulesTrigger
-    nsAutoEditInitRulesTrigger rulesTrigger(this, rulesRes);
+    // block to scope AutoEditInitRulesTrigger
+    AutoEditInitRulesTrigger rulesTrigger(this, rulesRes);
 
     // Init the base editor
     res = nsEditor::Init(aDoc, aRoot, aSelCon, aFlags, aInitialValue);
   }
 
   NS_ENSURE_SUCCESS(rulesRes, rulesRes);
 
   // mRules may not have been initialized yet, when this is called via
--- a/editor/libeditor/nsPlaintextEditor.h
+++ b/editor/libeditor/nsPlaintextEditor.h
@@ -23,16 +23,17 @@ class nsIDOMKeyEvent;
 class nsIDOMNode;
 class nsIDocumentEncoder;
 class nsIEditRules;
 class nsIOutputStream;
 class nsISelectionController;
 class nsITransferable;
 
 namespace mozilla {
+class AutoEditInitRulesTrigger;
 namespace dom {
 class Selection;
 } // namespace dom
 } // namespace mozilla
 
 /**
  * The text editor implementation.
  * Use to edit text document represented as a DOM tree.
@@ -218,17 +219,16 @@ protected:
 
   nsCOMPtr<nsIEditRules>        mRules;
   int32_t mWrapColumn;
   int32_t mMaxTextLength;
   int32_t mInitTriggerCounter;
   int32_t mNewlineHandling;
   int32_t mCaretStyle;
 
-// friends
-friend class nsHTMLEditRules;
-friend class nsTextEditRules;
-friend class nsAutoEditInitRulesTrigger;
-
+  // friends
+  friend class mozilla::AutoEditInitRulesTrigger;
+  friend class nsHTMLEditRules;
+  friend class nsTextEditRules;
 };
 
 #endif //nsPlaintextEditor_h__