Bug 1297899 - Part 5: Move refcounting from concrete restyle manager classes up to RestyleManager. r?bholley
MozReview-Commit-ID: 2KNfNCQzIIE
--- 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,