Commit 53640169 authored by George Steel's avatar George Steel Committed by Commit Bot

Move CountAnimatedProperty call to KeyframeEffect.

Animated properties are now counted in the KeyframeEffect constructor
and in SetKeyframes instead of in ProcessKeyframesRule. This makes
WebAnimations trigger the use counters as well as CSS
animations/transitions.

Bug: 992430
Change-Id: I7f0d453d7cde1333863a1127c3dcc68931814c13
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2354946
Commit-Queue: George Steel <gtsteel@chromium.org>
Reviewed-by: default avatarKevin Ellis <kevers@chromium.org>
Cr-Commit-Position: refs/heads/master@{#799158}
parent 99900ffc
...@@ -102,7 +102,6 @@ StringKeyframeVector ProcessKeyframesRule( ...@@ -102,7 +102,6 @@ StringKeyframeVector ProcessKeyframesRule(
const ComputedStyle* parent_style, const ComputedStyle* parent_style,
TimingFunction* default_timing_function) { TimingFunction* default_timing_function) {
StringKeyframeVector keyframes; StringKeyframeVector keyframes;
PropertySet specified_properties_for_use_counter;
const HeapVector<Member<StyleRuleKeyframe>>& style_keyframes = const HeapVector<Member<StyleRuleKeyframe>>& style_keyframes =
keyframes_rule->Keyframes(); keyframes_rule->Keyframes();
...@@ -118,7 +117,6 @@ StringKeyframeVector ProcessKeyframesRule( ...@@ -118,7 +117,6 @@ StringKeyframeVector ProcessKeyframesRule(
// TODO(crbug.com/980160): Remove access to static Variable instance. // TODO(crbug.com/980160): Remove access to static Variable instance.
const CSSProperty& property = const CSSProperty& property =
CSSProperty::Get(properties.PropertyAt(j).Id()); CSSProperty::Get(properties.PropertyAt(j).Id());
specified_properties_for_use_counter.insert(&property);
if (property.PropertyID() == CSSPropertyID::kAnimationTimingFunction) { if (property.PropertyID() == CSSPropertyID::kAnimationTimingFunction) {
const CSSValue& value = properties.PropertyAt(j).Value(); const CSSValue& value = properties.PropertyAt(j).Value();
scoped_refptr<TimingFunction> timing_function; scoped_refptr<TimingFunction> timing_function;
...@@ -145,11 +143,6 @@ StringKeyframeVector ProcessKeyframesRule( ...@@ -145,11 +143,6 @@ StringKeyframeVector ProcessKeyframesRule(
} }
} }
for (const CSSProperty* property : specified_properties_for_use_counter) {
DCHECK(isValidCSSPropertyID(property->PropertyID()));
document.CountAnimatedProperty(property->PropertyID());
}
std::stable_sort(keyframes.begin(), keyframes.end(), std::stable_sort(keyframes.begin(), keyframes.end(),
[](const Member<Keyframe>& a, const Member<Keyframe>& b) { [](const Member<Keyframe>& a, const Member<Keyframe>& b) {
return a->CheckedOffset() < b->CheckedOffset(); return a->CheckedOffset() < b->CheckedOffset();
...@@ -1025,9 +1018,6 @@ void CSSAnimations::MaybeApplyPendingUpdate(Element* element) { ...@@ -1025,9 +1018,6 @@ void CSSAnimations::MaybeApplyPendingUpdate(Element* element) {
animation->Update(kTimingUpdateOnDemand); animation->Update(kTimingUpdateOnDemand);
running_transition->animation = animation; running_transition->animation = animation;
transitions_.Set(property, running_transition); transitions_.Set(property, running_transition);
DCHECK(isValidCSSPropertyID(property.GetCSSProperty().PropertyID()));
element->GetDocument().CountAnimatedProperty(
property.GetCSSProperty().PropertyID());
} }
ClearPendingUpdate(); ClearPendingUpdate();
} }
......
...@@ -173,6 +173,8 @@ KeyframeEffect::KeyframeEffect(Element* target, ...@@ -173,6 +173,8 @@ KeyframeEffect::KeyframeEffect(Element* target,
DCHECK(!target_element_->IsPseudoElement()); DCHECK(!target_element_->IsPseudoElement());
target_pseudo_ = target->tagName(); target_pseudo_ = target->tagName();
} }
CountAnimatedProperties();
} }
KeyframeEffect::~KeyframeEffect() = default; KeyframeEffect::~KeyframeEffect() = default;
...@@ -293,6 +295,7 @@ void KeyframeEffect::SetKeyframes(StringKeyframeVector keyframes) { ...@@ -293,6 +295,7 @@ void KeyframeEffect::SetKeyframes(StringKeyframeVector keyframes) {
// potentially affect the effect owner. // potentially affect the effect owner.
ClearEffects(); ClearEffects();
InvalidateAndNotifyOwner(); InvalidateAndNotifyOwner();
CountAnimatedProperties();
} }
bool KeyframeEffect::Affects(const PropertyHandle& property) const { bool KeyframeEffect::Affects(const PropertyHandle& property) const {
...@@ -686,4 +689,16 @@ ActiveInterpolationsMap KeyframeEffect::InterpolationsForCommitStyles() { ...@@ -686,4 +689,16 @@ ActiveInterpolationsMap KeyframeEffect::InterpolationsForCommitStyles() {
return results; return results;
} }
void KeyframeEffect::CountAnimatedProperties() const {
if (target_element_) {
Document& document = target_element_->GetDocument();
for (const auto& property : model_->Properties()) {
if (property.IsCSSProperty()) {
DCHECK(isValidCSSPropertyID(property.GetCSSProperty().PropertyID()));
document.CountAnimatedProperty(property.GetCSSProperty().PropertyID());
}
}
}
}
} // namespace blink } // namespace blink
...@@ -153,6 +153,7 @@ class CORE_EXPORT KeyframeEffect final : public AnimationEffect { ...@@ -153,6 +153,7 @@ class CORE_EXPORT KeyframeEffect final : public AnimationEffect {
void AttachTarget(Animation*); void AttachTarget(Animation*);
void DetachTarget(Animation*); void DetachTarget(Animation*);
void RefreshTarget(); void RefreshTarget();
void CountAnimatedProperties() const;
AnimationTimeDelta CalculateTimeToEffectChange( AnimationTimeDelta CalculateTimeToEffectChange(
bool forwards, bool forwards,
base::Optional<double> inherited_time, base::Optional<double> inherited_time,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment