Bug 1297899 - Part 5: Move refcounting from concrete restyle manager classes up to RestyleManager. r?bholley draft
authorCameron McCormack <cam@mcc.id.au>
Mon, 13 Feb 2017 11:21:33 +0800
changeset 482519 4209bb77b6e17e9657c34fa03ff73cf23b7554a9
parent 482518 be994b79d7d26ab25087bc6ffc931254cc60b703
child 482520 6e364104360676f2599d51bfbe15f78d1edd7d76
push id45090
push userbmo:cam@mcc.id.au
push dateMon, 13 Feb 2017 03:22:33 +0000
reviewersbholley
bugs1297899
milestone54.0a1
Bug 1297899 - Part 5: Move refcounting from concrete restyle manager classes up to RestyleManager. r?bholley MozReview-Commit-ID: 2KNfNCQzIIE
layout/base/GeckoRestyleManager.h
layout/base/RestyleManager.h
layout/base/ServoRestyleManager.h
--- a/layout/base/GeckoRestyleManager.h
+++ b/layout/base/GeckoRestyleManager.h
@@ -39,27 +39,24 @@ class GeckoRestyleManager final : public
 public:
   typedef RestyleManager base_type;
 
   friend class RestyleTracker;
   friend class ElementRestyler;
 
   explicit GeckoRestyleManager(nsPresContext* aPresContext);
 
-private:
-  // Private destructor, to discourage deletion outside of Release():
-  ~GeckoRestyleManager()
+protected:
+  ~GeckoRestyleManager() override
   {
     MOZ_ASSERT(!mReframingStyleContexts,
                "temporary member should be nulled out before destruction");
   }
 
 public:
-  NS_INLINE_DECL_REFCOUNTING(mozilla::GeckoRestyleManager)
-
   // Forwarded nsIDocumentObserver method, to handle restyling (and
   // passing the notification to the frame).
   nsresult ContentStateChanged(nsIContent*   aContent,
                                EventStates aStateMask);
 
   // Forwarded nsIMutationObserver method, to handle restyling.
   void AttributeWillChange(Element* aElement,
                            int32_t  aNameSpaceID,
--- a/layout/base/RestyleManager.h
+++ b/layout/base/RestyleManager.h
@@ -26,22 +26,21 @@ class Element;
 }
 
 /**
  * Class for sharing data and logic common to both GeckoRestyleManager and
  * ServoRestyleManager.
  */
 class RestyleManager
 {
-protected:
-  RestyleManager(StyleBackendType aType, nsPresContext* aPresContext);
-
 public:
   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.
   uint32_t GetRestyleGeneration() const { return mRestyleGeneration; }
 
   // Get an integer that increments every time there is a style change
   // as a result of a change to the :hover content state.
   uint32_t GetHoverGeneration() const { return mHoverGeneration; }
 
@@ -137,17 +136,20 @@ public:
    * Return the current AnimationsWithDestroyedFrame struct, or null if we're
    * not currently in a restyling operation.
    */
   AnimationsWithDestroyedFrame* GetAnimationsWithDestroyedFrame() {
     return mAnimationsWithDestroyedFrame;
   }
 
 protected:
-  ~RestyleManager() {
+  RestyleManager(StyleBackendType aType, nsPresContext* aPresContext);
+
+  virtual ~RestyleManager()
+  {
     MOZ_ASSERT(!mAnimationsWithDestroyedFrame,
                "leaving dangling pointers from AnimationsWithDestroyedFrame");
   }
 
   void ContentStateChangedInternal(Element* aElement,
                                    EventStates aStateMask,
                                    nsChangeHint* aOutChangeHint,
                                    nsRestyleHint* aOutRestyleHint);
--- a/layout/base/ServoRestyleManager.h
+++ b/layout/base/ServoRestyleManager.h
@@ -35,18 +35,16 @@ namespace mozilla {
  * Restyle manager for a Servo-backed style system.
  */
 class ServoRestyleManager : public RestyleManager
 {
   friend class ServoStyleSet;
 public:
   typedef RestyleManager base_type;
 
-  NS_INLINE_DECL_REFCOUNTING(ServoRestyleManager)
-
   explicit ServoRestyleManager(nsPresContext* aPresContext);
 
   void PostRestyleEvent(dom::Element* aElement,
                         nsRestyleHint aRestyleHint,
                         nsChangeHint aMinChangeHint);
   void PostRestyleEventForLazyConstruction();
   void RebuildAllStyleData(nsChangeHint aExtraHint,
                            nsRestyleHint aRestyleHint);
@@ -96,17 +94,20 @@ public:
 
   /**
    * Clears HasDirtyDescendants from all elements in the subtree rooted at
    * aElement.
    */
   static void ClearDirtyDescendantsFromSubtree(Element* aElement);
 
 protected:
-  ~ServoRestyleManager() { MOZ_ASSERT(!mReentrantChanges); }
+  ~ServoRestyleManager() override
+  {
+    MOZ_ASSERT(!mReentrantChanges);
+  }
 
 private:
   /**
    * Traverses a tree of content that Servo has just restyled, recreating style
    * contexts for their frames with the new style data.
    */
   void RecreateStyleContexts(Element* aElement,
                              nsStyleContext* aParentContext,