From 26b701c0cc5ddb566ab63b628a34ae097c3b46ae Mon Sep 17 00:00:00 2001 From: Brian Birtles Date: Wed, 6 Jan 2016 11:04:05 +0900 Subject: [PATCH] Bug 1228229 part 11 - Avoid calling nsRuleNode::ComputePropertiesOverridingAnimation when there are no compositor-animatable properties; r=dbaron This restores the code removed in part 3 but adjusts it to iterate over an effect set instead of an AnimationCollection. It also adds an early return for the case where no compositor-animatable properties are found. --- dom/animation/EffectCompositor.cpp | 29 +++++++++++++++++++++++++---- dom/animation/EffectCompositor.h | 7 ++++--- 2 files changed, 29 insertions(+), 7 deletions(-) diff --git a/dom/animation/EffectCompositor.cpp b/dom/animation/EffectCompositor.cpp index 9b1baa27c61..1b8940910cd 100644 --- a/dom/animation/EffectCompositor.cpp +++ b/dom/animation/EffectCompositor.cpp @@ -16,6 +16,7 @@ #include "nsAnimationManager.h" #include "nsComputedDOMStyle.h" // nsComputedDOMStyle::GetPresShellForContent #include "nsCSSPropertySet.h" +#include "nsCSSProps.h" #include "nsIPresShell.h" #include "nsLayoutUtils.h" #include "nsRuleNode.h" // For nsRuleNode::ComputePropertiesOverridingAnimation @@ -225,14 +226,34 @@ EffectCompositor::GetAnimationElementAndPseudoForFrame(const nsIFrame* aFrame) /* static */ void EffectCompositor::GetOverriddenProperties(nsStyleContext* aStyleContext, + EffectSet& aEffectSet, nsCSSPropertySet& aPropertiesOverridden) { nsAutoTArray propertiesToTrack; - for (const LayerAnimationInfo::Record& record : - LayerAnimationInfo::sRecords) { - propertiesToTrack.AppendElement(record.mProperty); + { + nsCSSPropertySet propertiesToTrackAsSet; + for (KeyframeEffectReadOnly* effect : aEffectSet) { + for (const AnimationProperty& property : effect->Properties()) { + if (nsCSSProps::PropHasFlags(property.mProperty, + CSS_PROPERTY_CAN_ANIMATE_ON_COMPOSITOR) && + !propertiesToTrackAsSet.HasProperty(property.mProperty)) { + propertiesToTrackAsSet.AddProperty(property.mProperty); + propertiesToTrack.AppendElement(property.mProperty); + } + } + // Skip iterating over the rest of the effects if we've already + // found all the compositor-animatable properties. + if (propertiesToTrack.Length() == LayerAnimationInfo::kRecords) { + break; + } + } } + + if (propertiesToTrack.IsEmpty()) { + return; + } + nsRuleNode::ComputePropertiesOverridingAnimation(propertiesToTrack, aStyleContext, aPropertiesOverridden); @@ -265,7 +286,7 @@ EffectCompositor::UpdateCascadeResults(EffectSet& aEffectSet, // cascade applies. nsCSSPropertySet overriddenProperties; if (aStyleContext) { - GetOverriddenProperties(aStyleContext, overriddenProperties); + GetOverriddenProperties(aStyleContext, aEffectSet, overriddenProperties); } bool changed = false; diff --git a/dom/animation/EffectCompositor.h b/dom/animation/EffectCompositor.h index 013139c65c1..ed6c8954632 100644 --- a/dom/animation/EffectCompositor.h +++ b/dom/animation/EffectCompositor.h @@ -73,11 +73,12 @@ public: GetAnimationElementAndPseudoForFrame(const nsIFrame* aFrame); private: - // Get the properties that we are able to animate on the compositor that - // are specified at a higher level in the cascade than the animations - // level in |aStyleContext|. + // Get the properties in |aEffectSet| that we are able to animate on the + // compositor but which are also specified at a higher level in the cascade + // than the animations level in |aStyleContext|. static void GetOverriddenProperties(nsStyleContext* aStyleContext, + EffectSet& aEffectSet, nsCSSPropertySet& aPropertiesOverridden); static void