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

Sink is-to-animation check out of SVGAnimationElement::IsAccumulated

'to' animation is sufficiently special that we may as well treat
separately altogether. Sink that part of the check out and clean up code
using IsAccumulated().

Bug: 1017723, 231517
Change-Id: I27c63a423fa3ac24896bd4cf8f15f5aa101c4499
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1886813
Commit-Queue: Fredrik Söderquist <fs@opera.com>
Reviewed-by: default avatarStephen Chenney <schenney@chromium.org>
Cr-Commit-Position: refs/heads/master@{#710701}
parent 9fc93d85
......@@ -209,8 +209,11 @@ void SVGAnimateMotionElement::CalculateAnimatedValue(float percentage,
if (GetAnimationMode() != kPathAnimation) {
FloatPoint to_point_at_end_of_duration = to_point_;
if (IsAccumulated() && repeat_count && has_to_point_at_end_of_duration_)
to_point_at_end_of_duration = to_point_at_end_of_duration_;
if (GetAnimationMode() != kToAnimation) {
if (repeat_count && IsAccumulated() && has_to_point_at_end_of_duration_) {
to_point_at_end_of_duration = to_point_at_end_of_duration_;
}
}
float animated_x = 0;
AnimateAdditiveNumber(percentage, repeat_count, from_point_.X(),
......@@ -234,7 +237,7 @@ void SVGAnimateMotionElement::CalculateAnimatedValue(float percentage,
animation_path_.PointAndNormalAtLength(position_on_path, position, angle);
// Handle accumulate="sum".
if (IsAccumulated() && repeat_count) {
if (repeat_count && IsAccumulated()) {
FloatPoint position_at_end_of_duration =
animation_path_.PointAtLength(animation_path_.length());
position.Move(position_at_end_of_duration.X() * repeat_count,
......
......@@ -331,7 +331,7 @@ bool SVGAnimationElement::IsAdditive() const {
bool SVGAnimationElement::IsAccumulated() const {
DEFINE_STATIC_LOCAL(const AtomicString, sum, ("sum"));
const AtomicString& value = FastGetAttribute(svg_names::kAccumulateAttr);
return value == sum && GetAnimationMode() != kToAnimation;
return value == sum;
}
void SVGAnimationElement::CalculateKeyTimesForCalcModePaced() {
......@@ -630,7 +630,8 @@ void SVGAnimationElement::UpdateAnimation(float percent,
if (CheckAnimationParameters()) {
animation_valid_ = AnimationValidity::kValid;
if (IsAdditive() || IsAccumulated()) {
if (IsAdditive() ||
(IsAccumulated() && GetAnimationMode() != kToAnimation)) {
UseCounter::Count(&GetDocument(),
WebFeature::kSVGSMILAdditiveAnimation);
}
......@@ -675,8 +676,9 @@ void SVGAnimationElement::UpdateAnimation(float percent,
}
bool SVGAnimationElement::OverwritesUnderlyingAnimationValue() const {
return !IsAdditive() && !IsAccumulated() &&
GetAnimationMode() != kToAnimation &&
if (IsAdditive() || IsAccumulated())
return false;
return GetAnimationMode() != kToAnimation &&
GetAnimationMode() != kByAnimation &&
GetAnimationMode() != kNoAnimation;
}
......
......@@ -87,14 +87,13 @@ class CORE_EXPORT SVGAnimationElement : public SVGSMILElement {
number = percentage < 0.5 ? from_number : to_number;
else
number = (to_number - from_number) * percentage + from_number;
if (IsAccumulated() && repeat_count)
number += to_at_end_of_duration_number * repeat_count;
if (IsAdditive() && GetAnimationMode() != kToAnimation)
animated_number += number;
else
animated_number = number;
if (GetAnimationMode() != kToAnimation) {
if (repeat_count && IsAccumulated())
number += to_at_end_of_duration_number * repeat_count;
if (IsAdditive())
number += animated_number;
}
animated_number = number;
}
protected:
......
......@@ -167,17 +167,19 @@ void SVGPath::CalculateAnimatedValue(
std::unique_ptr<SVGPathByteStream> new_stream =
BlendPathByteStreams(*from_stream, to_stream, percentage);
// Handle additive='sum'.
if (animation_element.IsAdditive() && !is_to_animation) {
new_stream =
ConditionallyAddPathByteStreams(std::move(new_stream), ByteStream());
}
if (!is_to_animation) {
// Handle additive='sum'.
if (animation_element.IsAdditive()) {
new_stream =
ConditionallyAddPathByteStreams(std::move(new_stream), ByteStream());
}
// Handle accumulate='sum'.
if (animation_element.IsAccumulated() && repeat_count) {
new_stream = ConditionallyAddPathByteStreams(
std::move(new_stream),
ToSVGPath(to_at_end_of_duration_value)->ByteStream(), repeat_count);
// Handle accumulate='sum'.
if (repeat_count && animation_element.IsAccumulated()) {
new_stream = ConditionallyAddPathByteStreams(
std::move(new_stream),
ToSVGPath(to_at_end_of_duration_value)->ByteStream(), repeat_count);
}
}
path_value_ = MakeGarbageCollected<CSSPathValue>(std::move(new_stream));
}
......
......@@ -483,17 +483,20 @@ void SVGTransformList::CalculateAnimatedValue(
effective_from = MakeGarbageCollected<SVGTransform>(
to_transform->TransformType(), SVGTransform::kConstructZeroTransform);
// Never resize the animatedTransformList to the toList size, instead either
// clear the list or append to it.
bool is_to_animation = animation_element.GetAnimationMode() == kToAnimation;
if (!IsEmpty() && (!animation_element.IsAdditive() || is_to_animation))
Clear();
SVGTransform* current_transform =
SVGTransformDistance(effective_from, to_transform)
.ScaledDistance(percentage)
.AddToSVGTransform(effective_from);
if (animation_element.IsAccumulated() && repeat_count) {
if (animation_element.GetAnimationMode() == kToAnimation) {
Initialize(current_transform);
return;
}
// Never resize the animatedTransformList to the toList size, instead either
// clear the list or append to it.
if (!IsEmpty() && !animation_element.IsAdditive())
Clear();
if (repeat_count && animation_element.IsAccumulated()) {
SVGTransform* effective_to_at_end =
!to_at_end_of_duration_list->IsEmpty()
? to_at_end_of_duration_list->at(0)
......
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