Bug 1260651 part.51 Rename nsAutoLockRulesSniffing to mozilla::AutoLockRulesSniffing r=mccr8 draft
authorMasayuki Nakano <masayuki@d-toybox.com>
Fri, 24 Jun 2016 21:19:18 +0900
changeset 385883 160e1bd45fd77b6e979299a56d77409469736361
parent 385882 7c9184bf8bdfdc002d0039bd1770a08243dad213
child 385884 21a0009004e8e5f6a5755f7809b67dda864c4f78
push id22587
push usermasayuki@d-toybox.com
push dateSat, 09 Jul 2016 06:59:31 +0000
reviewersmccr8
bugs1260651
milestone50.0a1
Bug 1260651 part.51 Rename nsAutoLockRulesSniffing to mozilla::AutoLockRulesSniffing r=mccr8 MozReview-Commit-ID: BnZ1Y3YXfMK
editor/libeditor/HTMLEditRules.cpp
editor/libeditor/TextEditRules.cpp
editor/libeditor/TextEditRules.h
--- a/editor/libeditor/HTMLEditRules.cpp
+++ b/editor/libeditor/HTMLEditRules.cpp
@@ -256,17 +256,17 @@ HTMLEditRules::Init(nsPlaintextEditor* a
   }
 
   NS_ENSURE_STATE(node);
 
   mUtilRange = new nsRange(node);
 
   // set up mDocChangeRange to be whole doc
   // temporarily turn off rules sniffing
-  nsAutoLockRulesSniffing lockIt(static_cast<TextEditRules*>(this));
+  AutoLockRulesSniffing lockIt(this);
   if (!mDocChangeRange) {
     mDocChangeRange = new nsRange(node);
   }
 
   if (node->IsElement()) {
     ErrorResult rv;
     mDocChangeRange->SelectNode(*node, rv);
     NS_ENSURE_TRUE(!rv.Failed(), rv.StealNSResult());
@@ -295,17 +295,17 @@ HTMLEditRules::BeforeEdit(EditAction act
 {
   if (mLockRulesSniffing) {
     return NS_OK;
   }
 
   NS_ENSURE_STATE(mHTMLEditor);
   nsCOMPtr<nsIEditor> kungFuDeathGrip(mHTMLEditor);
 
-  nsAutoLockRulesSniffing lockIt(this);
+  AutoLockRulesSniffing lockIt(this);
   mDidExplicitlySetInterline = false;
 
   if (!mActionNesting) {
     mActionNesting++;
 
     // Clear our flag about if just deleted a range
     mDidRangedDelete = false;
 
@@ -377,17 +377,17 @@ HTMLEditRules::AfterEdit(EditAction acti
 {
   if (mLockRulesSniffing) {
     return NS_OK;
   }
 
   NS_ENSURE_STATE(mHTMLEditor);
   nsCOMPtr<nsIEditor> kungFuDeathGrip(mHTMLEditor);
 
-  nsAutoLockRulesSniffing lockIt(this);
+  AutoLockRulesSniffing lockIt(this);
 
   MOZ_ASSERT(mActionNesting > 0);
   nsresult rv = NS_OK;
   mActionNesting--;
   if (!mActionNesting) {
     // Do all the tricky stuff
     rv = AfterEditInner(action, aDirection);
 
--- a/editor/libeditor/TextEditRules.cpp
+++ b/editor/libeditor/TextEditRules.cpp
@@ -172,17 +172,17 @@ TextEditRules::DetachEditor()
 }
 
 NS_IMETHODIMP
 TextEditRules::BeforeEdit(EditAction action,
                           nsIEditor::EDirection aDirection)
 {
   if (mLockRulesSniffing) return NS_OK;
 
-  nsAutoLockRulesSniffing lockIt(this);
+  AutoLockRulesSniffing lockIt(this);
   mDidExplicitlySetInterline = false;
   if (!mActionNesting)
   {
     // let rules remember the top level action
     mTheAction = action;
   }
   mActionNesting++;
 
@@ -198,17 +198,17 @@ TextEditRules::BeforeEdit(EditAction act
 }
 
 NS_IMETHODIMP
 TextEditRules::AfterEdit(EditAction action,
                          nsIEditor::EDirection aDirection)
 {
   if (mLockRulesSniffing) return NS_OK;
 
-  nsAutoLockRulesSniffing lockIt(this);
+  AutoLockRulesSniffing lockIt(this);
 
   NS_PRECONDITION(mActionNesting>0, "bad action nesting!");
   nsresult res = NS_OK;
   if (!--mActionNesting)
   {
     NS_ENSURE_STATE(mEditor);
     RefPtr<Selection> selection = mEditor->GetSelection();
     NS_ENSURE_STATE(selection);
--- a/editor/libeditor/TextEditRules.h
+++ b/editor/libeditor/TextEditRules.h
@@ -11,23 +11,23 @@
 #include "nsEditRules.h"
 #include "nsEditor.h"
 #include "nsIEditor.h"
 #include "nsISupportsImpl.h"
 #include "nsITimer.h"
 #include "nsString.h"
 #include "nscore.h"
 
-class nsAutoLockRulesSniffing;
 class nsIDOMElement;
 class nsIDOMNode;
 class nsPlaintextEditor;
 
 namespace mozilla {
 
+class AutoLockRulesSniffing;
 namespace dom {
 class Selection;
 } // namespace dom
 
 /**
  * Object that encapsulates HTML text-specific editing rules.
  *
  * To be a good citizen, edit rules must live by these restrictions:
@@ -245,17 +245,17 @@ protected:
   bool mDeleteBidiImmediately;
   // The top level editor action.
   EditAction mTheAction;
   nsCOMPtr<nsITimer> mTimer;
   uint32_t mLastStart;
   uint32_t mLastLength;
 
   // friends
-  friend class nsAutoLockRulesSniffing;
+  friend class AutoLockRulesSniffing;
 };
 
 class TextRulesInfo final : public nsRulesInfo
 {
 public:
   explicit TextRulesInfo(EditAction aAction)
     : nsRulesInfo(aAction)
     , inString(nullptr)
@@ -292,37 +292,44 @@ public:
 
   // kMakeBasicBlock
   const nsAString* blockType;
 
   // kInsertElement
   const nsIDOMElement* insertElement;
 };
 
-} // namespace mozilla
-
-/***************************************************************************
- * stack based helper class for StartOperation()/EndOperation() sandwich.
- * this class sets a bool letting us know to ignore any rules sniffing
+/**
+ * Stack based helper class for StartOperation()/EndOperation() sandwich.
+ * This class sets a bool letting us know to ignore any rules sniffing
  * that tries to occur reentrantly.
  */
-class nsAutoLockRulesSniffing
+class MOZ_STACK_CLASS AutoLockRulesSniffing final
 {
-  public:
+public:
+  explicit AutoLockRulesSniffing(TextEditRules* aRules)
+    : mRules(aRules)
+  {
+    if (mRules) {
+      mRules->mLockRulesSniffing = true;
+    }
+  }
 
-  explicit nsAutoLockRulesSniffing(mozilla::TextEditRules *rules) : mRules(rules)
-                 {if (mRules) mRules->mLockRulesSniffing = true;}
-  ~nsAutoLockRulesSniffing()
-                 {if (mRules) mRules->mLockRulesSniffing = false;}
+  ~AutoLockRulesSniffing()
+  {
+    if (mRules) {
+      mRules->mLockRulesSniffing = false;
+    }
+  }
 
-  protected:
-  mozilla::TextEditRules *mRules;
+protected:
+  TextEditRules* mRules;
 };
 
-
+} // namespace mozilla
 
 /***************************************************************************
  * stack based helper class for turning on/off the edit listener.
  */
 class nsAutoLockListener
 {
 public: