summaryrefslogtreecommitdiffstats
path: root/chromium/third_party/blink/renderer/core/animation/svg_interpolation_type.cc
blob: 885cae5dad58bfd57a207ba171dffe0633e6517a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "third_party/blink/renderer/core/animation/svg_interpolation_type.h"

#include "third_party/blink/renderer/core/animation/string_keyframe.h"
#include "third_party/blink/renderer/core/animation/svg_interpolation_environment.h"
#include "third_party/blink/renderer/core/svg/properties/svg_property.h"
#include "third_party/blink/renderer/core/svg/svg_element.h"

namespace blink {

InterpolationValue SVGInterpolationType::MaybeConvertSingle(
    const PropertySpecificKeyframe& keyframe,
    const InterpolationEnvironment& environment,
    const InterpolationValue& underlying,
    ConversionCheckers& conversion_checkers) const {
  if (keyframe.IsNeutral())
    return MaybeConvertNeutral(underlying, conversion_checkers);

  auto* svg_value =
      To<SVGInterpolationEnvironment>(environment)
          .SvgBaseValue()
          .CloneForAnimation(To<SVGPropertySpecificKeyframe>(keyframe).Value());
  return MaybeConvertSVGValue(*svg_value);
}

InterpolationValue SVGInterpolationType::MaybeConvertUnderlyingValue(
    const InterpolationEnvironment& environment) const {
  return MaybeConvertSVGValue(
      To<SVGInterpolationEnvironment>(environment).SvgBaseValue());
}

void SVGInterpolationType::Apply(
    const InterpolableValue& interpolable_value,
    const NonInterpolableValue* non_interpolable_value,
    InterpolationEnvironment& environment) const {
  To<SVGInterpolationEnvironment>(environment)
      .SvgElement()
      .SetWebAnimatedAttribute(
          Attribute(),
          AppliedSVGValue(interpolable_value, non_interpolable_value));
}

}  // namespace blink