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(
const ComputedStyle* parent_style,
TimingFunction* default_timing_function) {
StringKeyframeVector keyframes;
PropertySet specified_properties_for_use_counter;
const HeapVector<Member<StyleRuleKeyframe>>& style_keyframes =
keyframes_rule->Keyframes();
......@@ -118,7 +117,6 @@ StringKeyframeVector ProcessKeyframesRule(
// TODO(crbug.com/980160): Remove access to static Variable instance.
const CSSProperty& property =
CSSProperty::Get(properties.PropertyAt(j).Id());
specified_properties_for_use_counter.insert(&property);
if (property.PropertyID() == CSSPropertyID::kAnimationTimingFunction) {
const CSSValue& value = properties.PropertyAt(j).Value();
scoped_refptr<TimingFunction> timing_function;
......@@ -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(),
[](const Member<Keyframe>& a, const Member<Keyframe>& b) {
return a->CheckedOffset() < b->CheckedOffset();
......@@ -1025,9 +1018,6 @@ void CSSAnimations::MaybeApplyPendingUpdate(Element* element) {
animation->Update(kTimingUpdateOnDemand);
running_transition->animation = animation;
transitions_.Set(property, running_transition);
DCHECK(isValidCSSPropertyID(property.GetCSSProperty().PropertyID()));
element->GetDocument().CountAnimatedProperty(
property.GetCSSProperty().PropertyID());
}
ClearPendingUpdate();
}
......
......@@ -173,6 +173,8 @@ KeyframeEffect::KeyframeEffect(Element* target,
DCHECK(!target_element_->IsPseudoElement());
target_pseudo_ = target->tagName();
}
CountAnimatedProperties();
}
KeyframeEffect::~KeyframeEffect() = default;
......@@ -293,6 +295,7 @@ void KeyframeEffect::SetKeyframes(StringKeyframeVector keyframes) {
// potentially affect the effect owner.
ClearEffects();
InvalidateAndNotifyOwner();
CountAnimatedProperties();
}
bool KeyframeEffect::Affects(const PropertyHandle& property) const {
......@@ -686,4 +689,16 @@ ActiveInterpolationsMap KeyframeEffect::InterpolationsForCommitStyles() {
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
......@@ -153,6 +153,7 @@ class CORE_EXPORT KeyframeEffect final : public AnimationEffect {
void AttachTarget(Animation*);
void DetachTarget(Animation*);
void RefreshTarget();
void CountAnimatedProperties() const;
AnimationTimeDelta CalculateTimeToEffectChange(
bool forwards,
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