Bug 1389440 - Replace pseudo style with the one having animations before generating elements corresponding to content propery. r?emilio draft
authorHiroyuki Ikezoe <hikezoe@mozilla.com>
Fri, 11 Aug 2017 19:49:56 +0900
changeset 644845 113ca20bf3979460f806dc49c5603b230df7ac4a
parent 643612 a4a448ba7f187069fce916ee234a06cbb0d06f80
child 644846 49920d68292d4b7270acb0e7748497d3006384c2
push id73557
push userhikezoe@mozilla.com
push dateFri, 11 Aug 2017 10:51:32 +0000
reviewersemilio
bugs1389440
milestone57.0a1
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
layout/base/nsCSSFrameConstructor.cpp
--- 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,