// 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_optional_integer_interpolation_type.h" #include #include #include "third_party/blink/renderer/core/animation/interpolation_environment.h" #include "third_party/blink/renderer/core/svg/svg_integer_optional_integer.h" #include "third_party/blink/renderer/platform/heap/heap.h" namespace blink { InterpolationValue SVGIntegerOptionalIntegerInterpolationType::MaybeConvertNeutral( const InterpolationValue&, ConversionCheckers&) const { auto result = std::make_unique(2); result->Set(0, std::make_unique(0)); result->Set(1, std::make_unique(0)); return InterpolationValue(std::move(result)); } InterpolationValue SVGIntegerOptionalIntegerInterpolationType::MaybeConvertSVGValue( const SVGPropertyBase& svg_value) const { if (svg_value.GetType() != kAnimatedIntegerOptionalInteger) return nullptr; const auto& integer_optional_integer = To(svg_value); auto result = std::make_unique(2); result->Set(0, std::make_unique( integer_optional_integer.FirstInteger()->Value())); result->Set(1, std::make_unique( integer_optional_integer.SecondInteger()->Value())); return InterpolationValue(std::move(result)); } static SVGInteger* ToPositiveInteger(const InterpolableValue* number) { return MakeGarbageCollected( clampTo(round(To(number)->Value()), 1)); } SVGPropertyBase* SVGIntegerOptionalIntegerInterpolationType::AppliedSVGValue( const InterpolableValue& interpolable_value, const NonInterpolableValue*) const { const auto& list = To(interpolable_value); return MakeGarbageCollected( ToPositiveInteger(list.Get(0)), ToPositiveInteger(list.Get(1))); } } // namespace blink