Bug 1373725 - Trigger a rule tree gc at the end of DoProcessPendingRestyles. r=emilio

MozReview-Commit-ID: W2lkQohudA
This commit is contained in:
Bobby Holley 2017-06-16 10:20:25 -07:00
parent a123d7939a
commit 690fa8991e
4 changed files with 21 additions and 0 deletions

View File

@ -680,6 +680,10 @@ ServoRestyleManager::DoProcessPendingRestyles(TraversalRestyleBehavior
mRestyleForCSSRuleChanges = false;
mInStyleRefresh = false;
// Now that everything has settled, see if we have enough free rule nodes in
// the tree to warrant sweeping them.
styleSet->MaybeGCRuleTree();
// Note: We are in the scope of |animationsWithDestroyedFrame|, so
// |mAnimationsWithDestroyedFrame| is still valid.
MOZ_ASSERT(mAnimationsWithDestroyedFrame);

View File

@ -518,6 +518,10 @@ SERVO_BINDING_FUNC(Servo_TraverseSubtree,
// Assert that the tree has no pending or unconsumed restyles.
SERVO_BINDING_FUNC(Servo_AssertTreeIsClean, void, RawGeckoElementBorrowed root)
// Checks whether the rule tree has crossed its threshold for unused rule nodes,
// and if so, frees them.
SERVO_BINDING_FUNC(Servo_MaybeGCRuleTree, void, RawServoStyleSetBorrowed set)
// Returns computed values for the given element without any animations rules.
SERVO_BINDING_FUNC(Servo_StyleSet_GetBaseComputedValuesForElement,
ServoComputedValuesStrong,

View File

@ -1290,6 +1290,13 @@ ServoStyleSet::UpdateStylist()
mStylistState = StylistState::NotDirty;
}
void
ServoStyleSet::MaybeGCRuleTree()
{
MOZ_ASSERT(NS_IsMainThread());
Servo_MaybeGCRuleTree(mRawSet.get());
}
void
ServoStyleSet::PrependSheetOfType(SheetType aType,
ServoStyleSheet* aSheet)

View File

@ -341,6 +341,12 @@ public:
}
}
/**
* Checks whether the rule tree has crossed its threshold for unused nodes,
* and if so, frees them.
*/
void MaybeGCRuleTree();
#ifdef DEBUG
void AssertTreeIsClean();
#else