Commit 6ef82730 authored by Fredrik Söderqvist's avatar Fredrik Söderqvist Committed by Commit Bot

Skip computing SMIL underlying value if not used

If the first animation in the sandwich does not depend on the underlying
value we can avoid computing it - which for certain types can avoid
flushing style.

Bug: 981355
Change-Id: Ic15e863f03f8f7194eea9a453b980f416f1bff37
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2403263Reviewed-by: default avatarPhilip Rogers <pdr@chromium.org>
Commit-Queue: Fredrik Söderquist <fs@opera.com>
Cr-Commit-Position: refs/heads/master@{#805798}
parent ea4dca75
...@@ -93,22 +93,25 @@ bool SMILAnimationSandwich::ApplyAnimationValues() { ...@@ -93,22 +93,25 @@ bool SMILAnimationSandwich::ApplyAnimationValues() {
if (!result_element) if (!result_element)
return false; return false;
// Only reset the animated type to the base value once for
// the lowest priority animation that animates and
// contributes to a particular element/attribute pair.
result_element->ResetAnimatedType();
// Animations have to be applied lowest to highest prio. // Animations have to be applied lowest to highest prio.
// //
// Only calculate the relevant animations. If we actually set the // Only calculate the relevant animations. If we actually set the
// animation value, we don't need to calculate what is beneath it // animation value, we don't need to calculate what is beneath it
// in the sandwich. // in the sandwich.
bool needs_underlying_value = true;
auto* sandwich_start = active_.end(); auto* sandwich_start = active_.end();
while (sandwich_start != active_.begin()) { while (sandwich_start != active_.begin()) {
--sandwich_start; --sandwich_start;
if ((*sandwich_start)->OverwritesUnderlyingAnimationValue()) if ((*sandwich_start)->OverwritesUnderlyingAnimationValue()) {
needs_underlying_value = false;
break; break;
} }
}
// Only reset the animated type to the base value once for
// the lowest priority animation that animates and
// contributes to a particular element/attribute pair.
result_element->ResetAnimatedType(needs_underlying_value);
for (auto* sandwich_it = sandwich_start; sandwich_it != active_.end(); for (auto* sandwich_it = sandwich_start; sandwich_it != active_.end();
sandwich_it++) { sandwich_it++) {
......
...@@ -432,7 +432,7 @@ bool SVGAnimateElement::CalculateFromAndByValues(const String& from_string, ...@@ -432,7 +432,7 @@ bool SVGAnimateElement::CalculateFromAndByValues(const String& from_string,
return true; return true;
} }
void SVGAnimateElement::ResetAnimatedType() { void SVGAnimateElement::ResetAnimatedType(bool needs_underlying_value) {
DCHECK(targetElement()); DCHECK(targetElement());
if (IsAnimatingSVGDom()) { if (IsAnimatingSVGDom()) {
// SVG DOM animVal animation code-path. // SVG DOM animVal animation code-path.
...@@ -447,7 +447,9 @@ void SVGAnimateElement::ResetAnimatedType() { ...@@ -447,7 +447,9 @@ void SVGAnimateElement::ResetAnimatedType() {
// CSS properties animation code-path. // CSS properties animation code-path.
String base_value = String base_value =
ComputeCSSPropertyValue(targetElement(), css_property_id_); needs_underlying_value
? ComputeCSSPropertyValue(targetElement(), css_property_id_)
: g_empty_string;
animated_value_ = CreatePropertyForAnimation(base_value); animated_value_ = CreatePropertyForAnimation(base_value);
} }
......
...@@ -59,7 +59,7 @@ class CORE_EXPORT SVGAnimateElement : public SVGAnimationElement { ...@@ -59,7 +59,7 @@ class CORE_EXPORT SVGAnimateElement : public SVGAnimationElement {
bool HasValidAnimation() const override; bool HasValidAnimation() const override;
void ResetAnimatedType() final; void ResetAnimatedType(bool needs_underlying_value) final;
void ClearAnimatedType() final; void ClearAnimatedType() final;
bool CalculateToAtEndOfDurationValue( bool CalculateToAtEndOfDurationValue(
......
...@@ -153,7 +153,7 @@ static bool ParsePoint(const String& string, FloatPoint& point) { ...@@ -153,7 +153,7 @@ static bool ParsePoint(const String& string, FloatPoint& point) {
}); });
} }
void SVGAnimateMotionElement::ResetAnimatedType() { void SVGAnimateMotionElement::ResetAnimatedType(bool needs_underlying_value) {
SVGElement* target_element = targetElement(); SVGElement* target_element = targetElement();
DCHECK(target_element); DCHECK(target_element);
DCHECK(TargetCanHaveMotionTransform(*target_element)); DCHECK(TargetCanHaveMotionTransform(*target_element));
......
...@@ -42,7 +42,7 @@ class SVGAnimateMotionElement final : public SVGAnimationElement { ...@@ -42,7 +42,7 @@ class SVGAnimateMotionElement final : public SVGAnimationElement {
void ParseAttribute(const AttributeModificationParams&) override; void ParseAttribute(const AttributeModificationParams&) override;
void ResetAnimatedType() override; void ResetAnimatedType(bool needs_underlying_value) override;
void ClearAnimatedType() override; void ClearAnimatedType() override;
bool CalculateToAtEndOfDurationValue( bool CalculateToAtEndOfDurationValue(
const String& to_at_end_of_duration_string) override; const String& to_at_end_of_duration_string) override;
......
...@@ -71,7 +71,7 @@ class CORE_EXPORT SVGAnimationElement : public SVGSMILElement { ...@@ -71,7 +71,7 @@ class CORE_EXPORT SVGAnimationElement : public SVGSMILElement {
DEFINE_ATTRIBUTE_EVENT_LISTENER(end, kEndEvent) DEFINE_ATTRIBUTE_EVENT_LISTENER(end, kEndEvent)
DEFINE_ATTRIBUTE_EVENT_LISTENER(repeat, kRepeatEvent) DEFINE_ATTRIBUTE_EVENT_LISTENER(repeat, kRepeatEvent)
virtual void ResetAnimatedType() = 0; virtual void ResetAnimatedType(bool needs_underlying_value) = 0;
virtual void ClearAnimatedType() = 0; virtual void ClearAnimatedType() = 0;
virtual void ApplyResultsToTarget() = 0; virtual void ApplyResultsToTarget() = 0;
// Returns true if this animation "sets" the value of the animation. Thus all // Returns true if this animation "sets" the value of the animation. Thus all
......
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