Commit 1092a8c0 authored by Fredrik Söderquist's avatar Fredrik Söderquist Committed by Commit Bot

Simplify animation function for the SVG*Optional* types

Since there are just basically "pair" types, we can call the underlying
type Add/CalculateAnimatedValue for each component.

Bug: 1017723
Change-Id: I8b14246b5a760cec18f9758b360e7c5c4df7b7fc
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1879897
Commit-Queue: Fredrik Söderquist <fs@opera.com>
Reviewed-by: default avatarStephen Chenney <schenney@chromium.org>
Cr-Commit-Position: refs/heads/master@{#709633}
parent 6a25fb53
...@@ -30,7 +30,6 @@ ...@@ -30,7 +30,6 @@
#include "third_party/blink/renderer/core/svg/svg_integer_optional_integer.h" #include "third_party/blink/renderer/core/svg/svg_integer_optional_integer.h"
#include "third_party/blink/renderer/core/svg/svg_animation_element.h"
#include "third_party/blink/renderer/core/svg/svg_parser_utilities.h" #include "third_party/blink/renderer/core/svg/svg_parser_utilities.h"
#include "third_party/blink/renderer/platform/heap/heap.h" #include "third_party/blink/renderer/platform/heap/heap.h"
...@@ -88,16 +87,13 @@ void SVGIntegerOptionalInteger::SetInitial(unsigned value) { ...@@ -88,16 +87,13 @@ void SVGIntegerOptionalInteger::SetInitial(unsigned value) {
second_integer_->SetInitial(value); second_integer_->SetInitial(value);
} }
void SVGIntegerOptionalInteger::Add(SVGPropertyBase* other, SVGElement*) { void SVGIntegerOptionalInteger::Add(SVGPropertyBase* other,
SVGIntegerOptionalInteger* other_integer_optional_integer = SVGElement* context_element) {
ToSVGIntegerOptionalInteger(other); auto* other_integer_optional_integer = ToSVGIntegerOptionalInteger(other);
first_integer_->Add(other_integer_optional_integer->FirstInteger(),
first_integer_->SetValue( context_element);
first_integer_->Value() + second_integer_->Add(other_integer_optional_integer->SecondInteger(),
other_integer_optional_integer->first_integer_->Value()); context_element);
second_integer_->SetValue(
second_integer_->Value() +
other_integer_optional_integer->second_integer_->Value());
} }
void SVGIntegerOptionalInteger::CalculateAnimatedValue( void SVGIntegerOptionalInteger::CalculateAnimatedValue(
...@@ -107,24 +103,20 @@ void SVGIntegerOptionalInteger::CalculateAnimatedValue( ...@@ -107,24 +103,20 @@ void SVGIntegerOptionalInteger::CalculateAnimatedValue(
SVGPropertyBase* from, SVGPropertyBase* from,
SVGPropertyBase* to, SVGPropertyBase* to,
SVGPropertyBase* to_at_end_of_duration, SVGPropertyBase* to_at_end_of_duration,
SVGElement*) { SVGElement* context_element) {
SVGIntegerOptionalInteger* from_integer = ToSVGIntegerOptionalInteger(from); auto* from_integer = ToSVGIntegerOptionalInteger(from);
SVGIntegerOptionalInteger* to_integer = ToSVGIntegerOptionalInteger(to); auto* to_integer = ToSVGIntegerOptionalInteger(to);
SVGIntegerOptionalInteger* to_at_end_of_duration_integer = auto* to_at_end_of_duration_integer =
ToSVGIntegerOptionalInteger(to_at_end_of_duration); ToSVGIntegerOptionalInteger(to_at_end_of_duration);
float x = first_integer_->Value(); first_integer_->CalculateAnimatedValue(
float y = second_integer_->Value(); animation_element, percentage, repeat_count, from_integer->FirstInteger(),
animation_element.AnimateAdditiveNumber( to_integer->FirstInteger(), to_at_end_of_duration_integer->FirstInteger(),
percentage, repeat_count, from_integer->FirstInteger()->Value(), context_element);
to_integer->FirstInteger()->Value(), second_integer_->CalculateAnimatedValue(
to_at_end_of_duration_integer->FirstInteger()->Value(), x); animation_element, percentage, repeat_count,
animation_element.AnimateAdditiveNumber( from_integer->SecondInteger(), to_integer->SecondInteger(),
percentage, repeat_count, from_integer->SecondInteger()->Value(), to_at_end_of_duration_integer->SecondInteger(), context_element);
to_integer->SecondInteger()->Value(),
to_at_end_of_duration_integer->SecondInteger()->Value(), y);
first_integer_->SetValue(clampTo<int>(roundf(x)));
second_integer_->SetValue(clampTo<int>(roundf(y)));
} }
float SVGIntegerOptionalInteger::CalculateDistance(SVGPropertyBase* other, float SVGIntegerOptionalInteger::CalculateDistance(SVGPropertyBase* other,
......
...@@ -30,7 +30,6 @@ ...@@ -30,7 +30,6 @@
#include "third_party/blink/renderer/core/svg/svg_number_optional_number.h" #include "third_party/blink/renderer/core/svg/svg_number_optional_number.h"
#include "third_party/blink/renderer/core/svg/svg_animation_element.h"
#include "third_party/blink/renderer/core/svg/svg_parser_utilities.h" #include "third_party/blink/renderer/core/svg/svg_parser_utilities.h"
#include "third_party/blink/renderer/platform/heap/heap.h" #include "third_party/blink/renderer/platform/heap/heap.h"
...@@ -90,15 +89,13 @@ void SVGNumberOptionalNumber::SetInitial(unsigned value) { ...@@ -90,15 +89,13 @@ void SVGNumberOptionalNumber::SetInitial(unsigned value) {
second_number_->SetInitial(value); second_number_->SetInitial(value);
} }
void SVGNumberOptionalNumber::Add(SVGPropertyBase* other, SVGElement*) { void SVGNumberOptionalNumber::Add(SVGPropertyBase* other,
SVGNumberOptionalNumber* other_number_optional_number = SVGElement* context_element) {
ToSVGNumberOptionalNumber(other); auto* other_number_optional_number = ToSVGNumberOptionalNumber(other);
first_number_->Add(other_number_optional_number->FirstNumber(),
first_number_->SetValue(first_number_->Value() + context_element);
other_number_optional_number->first_number_->Value()); second_number_->Add(other_number_optional_number->SecondNumber(),
second_number_->SetValue( context_element);
second_number_->Value() +
other_number_optional_number->second_number_->Value());
} }
void SVGNumberOptionalNumber::CalculateAnimatedValue( void SVGNumberOptionalNumber::CalculateAnimatedValue(
...@@ -108,24 +105,20 @@ void SVGNumberOptionalNumber::CalculateAnimatedValue( ...@@ -108,24 +105,20 @@ void SVGNumberOptionalNumber::CalculateAnimatedValue(
SVGPropertyBase* from, SVGPropertyBase* from,
SVGPropertyBase* to, SVGPropertyBase* to,
SVGPropertyBase* to_at_end_of_duration, SVGPropertyBase* to_at_end_of_duration,
SVGElement*) { SVGElement* context_element) {
SVGNumberOptionalNumber* from_number = ToSVGNumberOptionalNumber(from); auto* from_number = ToSVGNumberOptionalNumber(from);
SVGNumberOptionalNumber* to_number = ToSVGNumberOptionalNumber(to); auto* to_number = ToSVGNumberOptionalNumber(to);
SVGNumberOptionalNumber* to_at_end_of_duration_number = auto* to_at_end_of_duration_number =
ToSVGNumberOptionalNumber(to_at_end_of_duration); ToSVGNumberOptionalNumber(to_at_end_of_duration);
float x = first_number_->Value(); first_number_->CalculateAnimatedValue(
float y = second_number_->Value(); animation_element, percentage, repeat_count, from_number->FirstNumber(),
animation_element.AnimateAdditiveNumber( to_number->FirstNumber(), to_at_end_of_duration_number->FirstNumber(),
percentage, repeat_count, from_number->FirstNumber()->Value(), context_element);
to_number->FirstNumber()->Value(), second_number_->CalculateAnimatedValue(
to_at_end_of_duration_number->FirstNumber()->Value(), x); animation_element, percentage, repeat_count, from_number->SecondNumber(),
animation_element.AnimateAdditiveNumber( to_number->SecondNumber(), to_at_end_of_duration_number->SecondNumber(),
percentage, repeat_count, from_number->SecondNumber()->Value(), context_element);
to_number->SecondNumber()->Value(),
to_at_end_of_duration_number->SecondNumber()->Value(), y);
first_number_->SetValue(x);
second_number_->SetValue(y);
} }
float SVGNumberOptionalNumber::CalculateDistance(SVGPropertyBase* other, float SVGNumberOptionalNumber::CalculateDistance(SVGPropertyBase* other,
......
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