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 @@
#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/platform/heap/heap.h"
......@@ -88,16 +87,13 @@ void SVGIntegerOptionalInteger::SetInitial(unsigned value) {
second_integer_->SetInitial(value);
}
void SVGIntegerOptionalInteger::Add(SVGPropertyBase* other, SVGElement*) {
SVGIntegerOptionalInteger* other_integer_optional_integer =
ToSVGIntegerOptionalInteger(other);
first_integer_->SetValue(
first_integer_->Value() +
other_integer_optional_integer->first_integer_->Value());
second_integer_->SetValue(
second_integer_->Value() +
other_integer_optional_integer->second_integer_->Value());
void SVGIntegerOptionalInteger::Add(SVGPropertyBase* other,
SVGElement* context_element) {
auto* other_integer_optional_integer = ToSVGIntegerOptionalInteger(other);
first_integer_->Add(other_integer_optional_integer->FirstInteger(),
context_element);
second_integer_->Add(other_integer_optional_integer->SecondInteger(),
context_element);
}
void SVGIntegerOptionalInteger::CalculateAnimatedValue(
......@@ -107,24 +103,20 @@ void SVGIntegerOptionalInteger::CalculateAnimatedValue(
SVGPropertyBase* from,
SVGPropertyBase* to,
SVGPropertyBase* to_at_end_of_duration,
SVGElement*) {
SVGIntegerOptionalInteger* from_integer = ToSVGIntegerOptionalInteger(from);
SVGIntegerOptionalInteger* to_integer = ToSVGIntegerOptionalInteger(to);
SVGIntegerOptionalInteger* to_at_end_of_duration_integer =
SVGElement* context_element) {
auto* from_integer = ToSVGIntegerOptionalInteger(from);
auto* to_integer = ToSVGIntegerOptionalInteger(to);
auto* to_at_end_of_duration_integer =
ToSVGIntegerOptionalInteger(to_at_end_of_duration);
float x = first_integer_->Value();
float y = second_integer_->Value();
animation_element.AnimateAdditiveNumber(
percentage, repeat_count, from_integer->FirstInteger()->Value(),
to_integer->FirstInteger()->Value(),
to_at_end_of_duration_integer->FirstInteger()->Value(), x);
animation_element.AnimateAdditiveNumber(
percentage, repeat_count, from_integer->SecondInteger()->Value(),
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)));
first_integer_->CalculateAnimatedValue(
animation_element, percentage, repeat_count, from_integer->FirstInteger(),
to_integer->FirstInteger(), to_at_end_of_duration_integer->FirstInteger(),
context_element);
second_integer_->CalculateAnimatedValue(
animation_element, percentage, repeat_count,
from_integer->SecondInteger(), to_integer->SecondInteger(),
to_at_end_of_duration_integer->SecondInteger(), context_element);
}
float SVGIntegerOptionalInteger::CalculateDistance(SVGPropertyBase* other,
......
......@@ -30,7 +30,6 @@
#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/platform/heap/heap.h"
......@@ -90,15 +89,13 @@ void SVGNumberOptionalNumber::SetInitial(unsigned value) {
second_number_->SetInitial(value);
}
void SVGNumberOptionalNumber::Add(SVGPropertyBase* other, SVGElement*) {
SVGNumberOptionalNumber* other_number_optional_number =
ToSVGNumberOptionalNumber(other);
first_number_->SetValue(first_number_->Value() +
other_number_optional_number->first_number_->Value());
second_number_->SetValue(
second_number_->Value() +
other_number_optional_number->second_number_->Value());
void SVGNumberOptionalNumber::Add(SVGPropertyBase* other,
SVGElement* context_element) {
auto* other_number_optional_number = ToSVGNumberOptionalNumber(other);
first_number_->Add(other_number_optional_number->FirstNumber(),
context_element);
second_number_->Add(other_number_optional_number->SecondNumber(),
context_element);
}
void SVGNumberOptionalNumber::CalculateAnimatedValue(
......@@ -108,24 +105,20 @@ void SVGNumberOptionalNumber::CalculateAnimatedValue(
SVGPropertyBase* from,
SVGPropertyBase* to,
SVGPropertyBase* to_at_end_of_duration,
SVGElement*) {
SVGNumberOptionalNumber* from_number = ToSVGNumberOptionalNumber(from);
SVGNumberOptionalNumber* to_number = ToSVGNumberOptionalNumber(to);
SVGNumberOptionalNumber* to_at_end_of_duration_number =
SVGElement* context_element) {
auto* from_number = ToSVGNumberOptionalNumber(from);
auto* to_number = ToSVGNumberOptionalNumber(to);
auto* to_at_end_of_duration_number =
ToSVGNumberOptionalNumber(to_at_end_of_duration);
float x = first_number_->Value();
float y = second_number_->Value();
animation_element.AnimateAdditiveNumber(
percentage, repeat_count, from_number->FirstNumber()->Value(),
to_number->FirstNumber()->Value(),
to_at_end_of_duration_number->FirstNumber()->Value(), x);
animation_element.AnimateAdditiveNumber(
percentage, repeat_count, from_number->SecondNumber()->Value(),
to_number->SecondNumber()->Value(),
to_at_end_of_duration_number->SecondNumber()->Value(), y);
first_number_->SetValue(x);
second_number_->SetValue(y);
first_number_->CalculateAnimatedValue(
animation_element, percentage, repeat_count, from_number->FirstNumber(),
to_number->FirstNumber(), to_at_end_of_duration_number->FirstNumber(),
context_element);
second_number_->CalculateAnimatedValue(
animation_element, percentage, repeat_count, from_number->SecondNumber(),
to_number->SecondNumber(), to_at_end_of_duration_number->SecondNumber(),
context_element);
}
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