Bug 1389440 - Replace pseudo style with the one having animations before generating elements corresponding to content propery. r?emilio
This needs for content property animations.
MozReview-Commit-ID: C7ViMQTczJx
--- a/layout/base/nsCSSFrameConstructor.cpp
+++ b/layout/base/nsCSSFrameConstructor.cpp
@@ -1930,23 +1930,30 @@ nsCSSFrameConstructor::CreateGeneratedCo
return;
}
// Servo has already eagerly computed the style for the container, so we can
// just stick the style on the element and avoid an additional traversal.
//
// We don't do this for pseudos that may trigger animations or transitions,
// since those need to be kicked off by the traversal machinery.
- bool hasServoAnimations = false;
auto* servoStyle = pseudoStyleContext->GetAsServo();
if (servoStyle) {
- hasServoAnimations =
+ bool hasServoAnimations =
Servo_ComputedValues_SpecifiesAnimationsOrTransitions(servoStyle);
if (!hasServoAnimations) {
Servo_SetExplicitStyle(container, servoStyle);
+ } else {
+ // If animations are involved, we avoid the SetExplicitStyle optimization
+ // above. We need to grab style with animations from the pseudo element
+ // and replace old one.
+ mPresShell->StyleSet()->AsServo()->StyleNewSubtree(container);
+ pseudoStyleContext =
+ styleSet->AsServo()->ResolveServoStyle(container,
+ ServoTraversalFlags::Empty);
}
} else {
mozilla::GeckoRestyleManager* geckoRM = RestyleManager()->AsGecko();
GeckoRestyleManager::ReframingStyleContexts* rsc =
geckoRM->GetReframingStyleContexts();
if (rsc) {
RefPtr<GeckoStyleContext> newContext =
@@ -1976,25 +1983,17 @@ nsCSSFrameConstructor::CreateGeneratedCo
if (content->IsElement()) {
createdChildElement = true;
}
}
}
// We may need to do a synchronous servo traversal in various uncommon cases.
if (servoStyle) {
- if (hasServoAnimations) {
- // If animations are involved, we avoid the SetExplicitStyle optimization
- // above. We need to grab style with animations from the pseudo element
- // and replace old one.
- mPresShell->StyleSet()->AsServo()->StyleNewSubtree(container);
- pseudoStyleContext =
- styleSet->AsServo()->ResolveServoStyle(container,
- ServoTraversalFlags::Empty);
- } else if (createdChildElement) {
+ if (createdChildElement) {
// If we created any children elements, Servo needs to traverse them, but
// the root is already set up.
mPresShell->StyleSet()->AsServo()->StyleNewChildren(container);
}
}
AddFrameConstructionItemsInternal(aState, container, aParentFrame, elemName,
kNameSpaceID_None, true,