Bug 1454503: Remove unused RestyleManager refcounting. r?xidorn draft
authorEmilio Cobos Álvarez <emilio@crisal.io>
Mon, 16 Apr 2018 23:45:17 +0200
changeset 783313 0e098d4ee6ae8ac91609e72b6d1c5c299dd8eb75
parent 783312 e92e018760f5bf1131edc539415d766f52230449
child 783314 1e1ac88aa7be01128b53a723513450542d43b31f
push id106661
push userbmo:emilio@crisal.io
push dateMon, 16 Apr 2018 22:36:55 +0000
reviewersxidorn
bugs1454503
milestone61.0a1
Bug 1454503: Remove unused RestyleManager refcounting. r?xidorn MozReview-Commit-ID: DILRptmC8wJ
layout/base/RestyleManager.h
layout/base/nsPresContext.cpp
layout/base/nsPresContext.h
--- a/layout/base/RestyleManager.h
+++ b/layout/base/RestyleManager.h
@@ -184,31 +184,36 @@ enum class ServoPostTraversalFlags : uin
 class RestyleManager
 {
   friend class ServoStyleSet;
 
 public:
   typedef ServoElementSnapshotTable SnapshotTable;
   typedef mozilla::dom::Element Element;
 
-  NS_INLINE_DECL_REFCOUNTING(mozilla::RestyleManager)
-
   // Get an integer that increments every time we process pending restyles.
   // The value is never 0.
   uint64_t GetRestyleGeneration() const { return mRestyleGeneration; }
   // Unlike GetRestyleGeneration, which means the actual restyling count,
   // GetUndisplayedRestyleGeneration represents any possible DOM changes that
   // can cause restyling. This is needed for getComputedStyle to work with
   // non-styled (e.g. display: none) elements.
   uint64_t GetUndisplayedRestyleGeneration() const {
     return mUndisplayedRestyleGeneration;
   }
 
   void Disconnect() { mPresContext = nullptr; }
 
+  ~RestyleManager()
+  {
+    MOZ_ASSERT(!mAnimationsWithDestroyedFrame,
+               "leaving dangling pointers from AnimationsWithDestroyedFrame");
+    MOZ_ASSERT(!mReentrantChanges);
+  }
+
   static nsCString RestyleHintToString(nsRestyleHint aHint);
 
 #ifdef DEBUG
   static nsCString ChangeHintToString(nsChangeHint aHint);
 
   /**
    * DEBUG ONLY method to verify integrity of style tree versus frame tree
    */
@@ -444,23 +449,16 @@ protected:
   struct TextPostTraversalState;
   bool ProcessPostTraversalForText(nsIContent* aTextNode,
                                    TextPostTraversalState& aState,
                                    ServoRestyleState& aRestyleState,
                                    ServoPostTraversalFlags aFlags);
 
   ServoStyleSet* StyleSet() const { return PresContext()->StyleSet(); }
 
-  ~RestyleManager()
-  {
-    MOZ_ASSERT(!mAnimationsWithDestroyedFrame,
-               "leaving dangling pointers from AnimationsWithDestroyedFrame");
-    MOZ_ASSERT(!mReentrantChanges);
-  }
-
   void RestyleForEmptyChange(Element* aContainer);
   void MaybeRestyleForEdgeChildChange(Element* aContainer, nsIContent* aChangedChild);
 
   void ContentStateChangedInternal(Element* aElement,
                                    EventStates aStateMask,
                                    nsChangeHint* aOutChangeHint);
 
   bool IsDisconnected() const { return !mPresContext; }
--- a/layout/base/nsPresContext.cpp
+++ b/layout/base/nsPresContext.cpp
@@ -951,17 +951,17 @@ nsPresContext::Init(nsDeviceContext* aDe
 // Note: We don't hold a reference on the shell; it has a reference to
 // us
 void
 nsPresContext::AttachShell(nsIPresShell* aShell)
 {
   MOZ_ASSERT(!mShell);
   mShell = aShell;
 
-  mRestyleManager = new mozilla::RestyleManager(this);
+  mRestyleManager = MakeUnique<mozilla::RestyleManager>(this);
 
   // Since CounterStyleManager is also the name of a method of
   // nsPresContext, it is necessary to prefix the class with the mozilla
   // namespace here.
   mCounterStyleManager = new mozilla::CounterStyleManager(this);
 
   nsIDocument *doc = mShell->GetDocument();
   NS_ASSERTION(doc, "expect document here");
--- a/layout/base/nsPresContext.h
+++ b/layout/base/nsPresContext.h
@@ -242,17 +242,17 @@ public:
   nsTransitionManager* TransitionManager() { return mTransitionManager; }
   nsAnimationManager* AnimationManager() { return mAnimationManager; }
   const nsAnimationManager* AnimationManager() const { return mAnimationManager; }
 
   nsRefreshDriver* RefreshDriver() { return mRefreshDriver; }
 
   mozilla::RestyleManager* RestyleManager() {
     MOZ_ASSERT(mRestyleManager);
-    return mRestyleManager;
+    return mRestyleManager.get();
   }
 
   mozilla::CounterStyleManager* CounterStyleManager() const {
     return mCounterStyleManager;
   }
 
   /**
    * Rebuilds all style data by throwing out the old rule tree and
@@ -1295,17 +1295,17 @@ protected:
                                             // since there is no dependency
                                             // from gfx back to layout.
   RefPtr<mozilla::EventStateManager> mEventManager;
   RefPtr<nsRefreshDriver> mRefreshDriver;
   RefPtr<mozilla::AnimationEventDispatcher> mAnimationEventDispatcher;
   RefPtr<mozilla::EffectCompositor> mEffectCompositor;
   RefPtr<nsTransitionManager> mTransitionManager;
   RefPtr<nsAnimationManager> mAnimationManager;
-  RefPtr<mozilla::RestyleManager> mRestyleManager;
+  mozilla::UniquePtr<mozilla::RestyleManager> mRestyleManager;
   RefPtr<mozilla::CounterStyleManager> mCounterStyleManager;
   nsAtom* MOZ_UNSAFE_REF("always a static atom") mMedium; // initialized by subclass ctors
   RefPtr<nsAtom> mMediaEmulated;
   RefPtr<gfxFontFeatureValueSet> mFontFeatureValuesLookup;
 
   // This pointer is nulled out through SetLinkHandler() in the destructors of
   // the classes which set it. (using SetLinkHandler() again).
   nsILinkHandler* MOZ_NON_OWNING_REF mLinkHandler;