summaryrefslogtreecommitdiff
path: root/chromium/third_party/blink/renderer/core/animation/svg_integer_interpolation_type.cc
blob: 0859bd5efeb8de4dd867ad40e02574c38d0b3faf (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
// 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_integer_interpolation_type.h"

#include "third_party/blink/renderer/core/animation/interpolation_environment.h"
#include "third_party/blink/renderer/core/svg/svg_integer.h"

namespace blink {

InterpolationValue SVGIntegerInterpolationType::MaybeConvertNeutral(
    const InterpolationValue&,
    ConversionCheckers&) const {
  return InterpolationValue(InterpolableNumber::Create(0));
}

InterpolationValue SVGIntegerInterpolationType::MaybeConvertSVGValue(
    const SVGPropertyBase& svg_value) const {
  if (svg_value.GetType() != kAnimatedInteger)
    return nullptr;
  return InterpolationValue(
      InterpolableNumber::Create(ToSVGInteger(svg_value).Value()));
}

SVGPropertyBase* SVGIntegerInterpolationType::AppliedSVGValue(
    const InterpolableValue& interpolable_value,
    const NonInterpolableValue*) const {
  double value = ToInterpolableNumber(interpolable_value).Value();
  return SVGInteger::Create(round(value));
}

}  // namespace blink