Bug 1454503: Remove unused RestyleManager refcounting. r=xidorn
authorEmilio Cobos Álvarez <emilio@crisal.io>
Mon, 16 Apr 2018 23:45:17 +0200
changeset 467618 40a157e04cbc852d7292bb0a016a2b428a6d0e05
parent 467617 20b1c2e6fceba63ebb758cb6b8d9659cf7466631
child 467619 761677ac644f072389c1ea4ada13d1db90dbc9c3
push id9165
push userasasaki@mozilla.com
push dateThu, 26 Apr 2018 21:04:54 +0000
treeherdermozilla-beta@064c3804de2e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersxidorn
bugs1454503
milestone61.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
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;