Bug 1462497 - Part 4: Only use the MayHaveAnimation variants when computing useOpacity in case the more accurate version changes results between paints. r=hiro, a=RyanVM
☠☠ backed out by 0f95c023462e ☠ ☠
authorMatt Woodrow <mwoodrow@mozilla.com>
Wed, 23 May 2018 11:03:54 +1200
changeset 473431 f89eb218615420225501ca0c1e32c05aae3445f0
parent 473430 e8836b424826088cd4f502103d07cec300a85a28
child 473432 5277d1553fd2dd78e315ae2a3e278c436308756c
push id1728
push userjlund@mozilla.com
push dateMon, 18 Jun 2018 21:12:27 +0000
treeherdermozilla-release@c296fde26f5f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewershiro, RyanVM
bugs1462497
milestone61.0
Bug 1462497 - Part 4: Only use the MayHaveAnimation variants when computing useOpacity in case the more accurate version changes results between paints. r=hiro, a=RyanVM I don't think this part is necessary, but putting the patch up in case we decide we want to take it. MozReview-Commit-ID: G0JTNddvZma
layout/base/nsLayoutUtils.cpp
layout/base/nsLayoutUtils.h
layout/painting/ActiveLayerTracker.cpp
layout/svg/nsSVGUtils.cpp
--- a/layout/base/nsLayoutUtils.cpp
+++ b/layout/base/nsLayoutUtils.cpp
@@ -253,35 +253,36 @@ MayHaveAnimationOfProperty(EffectSet* ef
   if (aProperty == eCSSProperty_opacity &&
       !effects->MayHaveOpacityAnimation()) {
     return false;
   }
 
   return true;
 }
 
-static bool
-MayHaveAnimationOfProperty(const nsIFrame* aFrame, nsCSSPropertyID aProperty)
+bool
+nsLayoutUtils::MayHaveAnimationOfProperty(const nsIFrame* aFrame,
+                                          nsCSSPropertyID aProperty)
 {
   switch (aProperty) {
     case eCSSProperty_transform:
       return aFrame->MayHaveTransformAnimation();
     case eCSSProperty_opacity:
       return aFrame->MayHaveOpacityAnimation();
     default:
       MOZ_ASSERT_UNREACHABLE("unexpected property");
       return false;
   }
 }
 
 bool
 nsLayoutUtils::HasAnimationOfProperty(EffectSet* aEffectSet,
                                       nsCSSPropertyID aProperty)
 {
-  if (!aEffectSet || !MayHaveAnimationOfProperty(aEffectSet, aProperty)) {
+  if (!aEffectSet || !::MayHaveAnimationOfProperty(aEffectSet, aProperty)) {
     return false;
   }
 
   return HasMatchingAnimations(aEffectSet,
     [&aProperty](KeyframeEffectReadOnly& aEffect)
     {
       return (aEffect.IsInEffect() || aEffect.IsCurrent()) &&
              aEffect.HasAnimationOfProperty(aProperty);
@@ -307,30 +308,41 @@ nsLayoutUtils::HasAnimationOfProperty(co
 
 }
 
 bool
 nsLayoutUtils::HasEffectiveAnimation(const nsIFrame* aFrame,
                                      nsCSSPropertyID aProperty)
 {
   EffectSet* effects = EffectSet::GetEffectSet(aFrame);
-  if (!effects || !MayHaveAnimationOfProperty(effects, aProperty)) {
+  if (!effects || !::MayHaveAnimationOfProperty(effects, aProperty)) {
     return false;
   }
 
 
   return HasMatchingAnimations(effects,
     [&aProperty](KeyframeEffectReadOnly& aEffect)
     {
       return (aEffect.IsInEffect() || aEffect.IsCurrent()) &&
              aEffect.HasEffectiveAnimationOfProperty(aProperty);
     }
   );
 }
 
+bool
+nsLayoutUtils::MayHaveEffectiveAnimation(const nsIFrame* aFrame,
+                                         nsCSSPropertyID aProperty)
+{
+  EffectSet* effects = EffectSet::GetEffectSet(aFrame);
+  if (!effects || !::MayHaveAnimationOfProperty(effects, aProperty)) {
+    return false;
+  }
+  return true;
+}
+
 static float
 GetSuitableScale(float aMaxScale, float aMinScale,
                  nscoord aVisibleDimension, nscoord aDisplayDimension)
 {
   float displayVisibleRatio = float(aDisplayDimension) /
                               float(aVisibleDimension);
   // We want to rasterize based on the largest scale used during the
   // transform animation, unless that would make us rasterize something
--- a/layout/base/nsLayoutUtils.h
+++ b/layout/base/nsLayoutUtils.h
@@ -2327,30 +2327,34 @@ public:
   static bool HasCurrentTransitions(const nsIFrame* aFrame);
 
   /**
    * Returns true if |aFrame| has an animation of |aProperty| regardless of
    * whether the property is overridden by !important rule.
    */
   static bool HasAnimationOfProperty(const nsIFrame* aFrame,
                                      nsCSSPropertyID aProperty);
+  static bool MayHaveAnimationOfProperty(const nsIFrame* aFrame,
+                                         nsCSSPropertyID aProperty);
 
   /**
    * Returns true if |aEffectSet| has an animation of |aProperty| regardless of
    * whether the property is overridden by !important rule.
    */
   static bool HasAnimationOfProperty(mozilla::EffectSet* aEffectSet,
                                      nsCSSPropertyID aProperty);
 
   /**
    * Returns true if |aFrame| has an animation of |aProperty| which is
    * not overridden by !important rules.
    */
   static bool HasEffectiveAnimation(const nsIFrame* aFrame,
                                     nsCSSPropertyID aProperty);
+  static bool MayHaveEffectiveAnimation(const nsIFrame* aFrame,
+                                        nsCSSPropertyID aProperty);
 
   /**
    * Checks if off-main-thread animations are enabled.
    */
   static bool AreAsyncAnimationsEnabled();
 
   /**
    * Checks if we should warn about animations that can't be async
--- a/layout/painting/ActiveLayerTracker.cpp
+++ b/layout/painting/ActiveLayerTracker.cpp
@@ -431,17 +431,21 @@ ActiveLayerTracker::IsStyleAnimated(nsDi
     }
     if (CheckScrollInducedActivity(layerActivity, activityIndex, aBuilder)) {
       return true;
     }
   }
   if (aProperty == eCSSProperty_transform && aFrame->Combines3DTransformWithAncestors()) {
     return IsStyleAnimated(aBuilder, aFrame->GetParent(), aProperty);
   }
-  return nsLayoutUtils::HasEffectiveAnimation(aFrame, aProperty);
+  if (aBuilder) {
+    return nsLayoutUtils::HasEffectiveAnimation(aFrame, aProperty);
+  } else {
+    return nsLayoutUtils::MayHaveEffectiveAnimation(aFrame, aProperty);
+  }
 }
 
 /* static */ bool
 ActiveLayerTracker::IsOffsetStyleAnimated(nsIFrame* aFrame)
 {
   LayerActivity* layerActivity = GetLayerActivity(aFrame);
   if (layerActivity) {
     if (layerActivity->mRestyleCounts[LayerActivity::ACTIVITY_LEFT] >= 2 ||
--- a/layout/svg/nsSVGUtils.cpp
+++ b/layout/svg/nsSVGUtils.cpp
@@ -1290,17 +1290,17 @@ nsSVGUtils::CanOptimizeOpacity(nsIFrame 
   if (type == LayoutFrameType::SVGImage) {
     return true;
   }
   const nsStyleSVG *style = aFrame->StyleSVG();
   if (style->HasMarker()) {
     return false;
   }
 
-  if (nsLayoutUtils::HasAnimationOfProperty(aFrame, eCSSProperty_opacity)) {
+  if (nsLayoutUtils::MayHaveAnimationOfProperty(aFrame, eCSSProperty_opacity)) {
     return false;
   }
 
   if (!style->HasFill() || !HasStroke(aFrame)) {
     return true;
   }
   return false;
 }