Bug 1315874 - Drop animation styles if we re-use an existing style context in DoGetStyleContextNoFlush for non-animation style; r=heycam draft
authorBrian Birtles <birtles@gmail.com>
Mon, 03 Apr 2017 16:49:10 +0900
changeset 555973 6f9f8231654952ceadf49c2887b8868c2c18934b
parent 555972 470c597591e49a16b3aca17679f111e4fd5bc951
child 555974 392e53f521689422e92643d22189a55f0b491f2e
push id52387
push userbbirtles@mozilla.com
push dateWed, 05 Apr 2017 06:09:34 +0000
reviewersheycam
bugs1315874
milestone55.0a1
Bug 1315874 - Drop animation styles if we re-use an existing style context in DoGetStyleContextNoFlush for non-animation style; r=heycam MozReview-Commit-ID: GrB8A8bVLiX
layout/style/nsComputedDOMStyle.cpp
--- a/layout/style/nsComputedDOMStyle.cpp
+++ b/layout/style/nsComputedDOMStyle.cpp
@@ -601,16 +601,32 @@ nsComputedDOMStyle::DoGetStyleContextNoF
       !aElement->IsHTMLElement(nsGkAtoms::area)) {
     nsIFrame* frame = nsLayoutUtils::GetStyleFrame(aElement);
     if (frame) {
       nsStyleContext* result = frame->StyleContext();
       // Don't use the style context if it was influenced by
       // pseudo-elements, since then it's not the primary style
       // for this element.
       if (!result->HasPseudoElementData()) {
+        // The existing style context may have animation styles so check if we
+        // need to remove them.
+        if (aAnimationFlag == eWithoutAnimation) {
+          nsPresContext* presContext = presShell->GetPresContext();
+          MOZ_ASSERT(presContext, "Should have a prescontext if we have a frame");
+          MOZ_ASSERT(presContext->StyleSet()->IsGecko(),
+                     "stylo: Need ResolveStyleByRemovingAnimation for stylo");
+          if (presContext && presContext->StyleSet()->IsGecko()) {
+            nsStyleSet* styleSet = presContext->StyleSet()->AsGecko();
+            return styleSet->ResolveStyleByRemovingAnimation(
+                     aElement, result, eRestyle_AllHintsWithAnimations);
+          } else {
+            return nullptr;
+          }
+        }
+
         // this function returns an addrefed style context
         RefPtr<nsStyleContext> ret = result;
         return ret.forget();
       }
     }
   }
 
   // No frame has been created, or we have a pseudo, or we're looking