Bug 1351535 - Part 4: Add a TraversalRestyleBehavior argument to traversal functions. r=bholley

This argument will be used to control whether we are restyling in preparation
for reframing a subtree, which can avoid generating any change hints, as we
aren't preserving the frames that they would otherwise apply to.

MozReview-Commit-ID: DkLVCUnNGt

--HG--
extra : rebase_source : cb3537cea26cb9805b2ec1556cf5ca6eb9d38ab8
This commit is contained in:
Cameron McCormack 2017-04-08 22:57:08 +08:00
Родитель f8a5e03987
Коммит 9ce0d4d3d2
4 изменённых файлов: 29 добавлений и 8 удалений

Просмотреть файл

@ -324,7 +324,8 @@ SERVO_BINDING_FUNC(Servo_ResolveStyleLazily, ServoComputedValuesStrong,
// directly
SERVO_BINDING_FUNC(Servo_TraverseSubtree, bool,
RawGeckoElementBorrowed root, RawServoStyleSetBorrowed set,
mozilla::TraversalRootBehavior root_behavior)
mozilla::TraversalRootBehavior root_behavior,
mozilla::TraversalRestyleBehavior restyle_behavior)
// Assert that the tree has no pending or unconsumed restyles.
SERVO_BINDING_FUNC(Servo_AssertTreeIsClean, void, RawGeckoElementBorrowed root)

Просмотреть файл

@ -225,7 +225,9 @@ ServoStyleSet::PreTraverse()
bool
ServoStyleSet::PrepareAndTraverseSubtree(RawGeckoElementBorrowed aRoot,
mozilla::TraversalRootBehavior aRootBehavior)
TraversalRootBehavior aRootBehavior,
TraversalRestyleBehavior
aRestyleBehavior)
{
// Get the Document's root element to ensure that the cache is valid before
// calling into the (potentially-parallel) Servo traversal, where a cache hit
@ -237,13 +239,14 @@ ServoStyleSet::PrepareAndTraverseSubtree(RawGeckoElementBorrowed aRoot,
bool isInitial = !aRoot->HasServoData();
bool postTraversalRequired =
Servo_TraverseSubtree(aRoot, mRawSet.get(), aRootBehavior);
Servo_TraverseSubtree(aRoot, mRawSet.get(), aRootBehavior, aRestyleBehavior);
MOZ_ASSERT_IF(isInitial, !postTraversalRequired);
// If there are still animation restyles needed, trigger a second traversal to
// update CSS animations' styles.
if (mPresContext->EffectCompositor()->PreTraverse()) {
if (Servo_TraverseSubtree(aRoot, mRawSet.get(), aRootBehavior)) {
if (Servo_TraverseSubtree(aRoot, mRawSet.get(),
aRootBehavior, aRestyleBehavior)) {
if (isInitial) {
// We're doing initial styling, and the additional animation
// traversal changed the styles that were set by the first traversal.
@ -708,7 +711,9 @@ ServoStyleSet::StyleDocument()
bool postTraversalRequired = false;
DocumentStyleRootIterator iter(mPresContext->Document());
while (Element* root = iter.GetNextStyleRoot()) {
if (PrepareAndTraverseSubtree(root, TraversalRootBehavior::Normal)) {
if (PrepareAndTraverseSubtree(root,
TraversalRootBehavior::Normal,
TraversalRestyleBehavior::Normal)) {
postTraversalRequired = true;
}
}
@ -723,7 +728,9 @@ ServoStyleSet::StyleNewSubtree(Element* aRoot)
PreTraverse();
DebugOnly<bool> postTraversalRequired =
PrepareAndTraverseSubtree(aRoot, TraversalRootBehavior::Normal);
PrepareAndTraverseSubtree(aRoot,
TraversalRootBehavior::Normal,
TraversalRestyleBehavior::Normal);
MOZ_ASSERT(!postTraversalRequired);
}
@ -732,7 +739,9 @@ ServoStyleSet::StyleNewChildren(Element* aParent)
{
PreTraverse();
PrepareAndTraverseSubtree(aParent, TraversalRootBehavior::UnstyledChildrenOnly);
PrepareAndTraverseSubtree(aParent,
TraversalRootBehavior::UnstyledChildrenOnly,
TraversalRestyleBehavior::Normal);
// We can't assert that Servo_TraverseSubtree returns false, since aParent
// or some of its other children might have pending restyles.
}

Просмотреть файл

@ -302,7 +302,8 @@ private:
* a subtree. Returns whether a post-traversal is required.
*/
bool PrepareAndTraverseSubtree(RawGeckoElementBorrowed aRoot,
mozilla::TraversalRootBehavior aRootBehavior);
TraversalRootBehavior aRootBehavior,
TraversalRestyleBehavior aRestyleBehavior);
/**
* Clear our cached mNonInheritingStyleContexts. We do this when we want to

Просмотреть файл

@ -53,6 +53,16 @@ enum class TraversalRootBehavior {
UnstyledChildrenOnly,
};
// Indicates whether the Servo style system should perform normal processing or
// whether it should traverse in a mode that doesn't generate any change hints,
// which is what's required when handling frame reconstruction. The change
// hints in this case are unneeded, since the old frames have already been
// destroyed.
enum class TraversalRestyleBehavior {
Normal,
ForReconstruct,
};
// Represents which tasks are performed in a SequentialTask of UpdateAnimations.
enum class UpdateAnimationsTasks : uint8_t {
CSSAnimations = 1 << 0,