Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(504)

Side by Side Diff: third_party/WebKit/Source/core/animation/IntegerOptionalIntegerSVGInterpolation.cpp

Issue 1417483015: SVG Web Animations: Add SVGIntegerOptionalIntegerInterpolationType (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: More test work... Some failing Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "config.h"
6 #include "core/animation/IntegerOptionalIntegerSVGInterpolation.h"
7
8 #include "core/SVGNames.h"
9
10 namespace blink {
11
12 namespace {
13
14 // For order, the values must be integers greater than zero.
15 // For filterRes, negative values are an error. Zero values disable rendering of the element which referenced the filter.
16 PassRefPtrWillBeRawPtr<SVGInteger> toPositiveInteger(const InterpolableValue* nu mber, int min)
17 {
18 return SVGInteger::create(clampTo<int>(roundf(toInterpolableNumber(number)-> value()), min));
19 }
20
21 } // namespace
22
23 PassOwnPtr<InterpolableValue> IntegerOptionalIntegerSVGInterpolation::toInterpol ableValue(SVGPropertyBase* value)
24 {
25 RefPtrWillBeRawPtr<SVGIntegerOptionalInteger> integerOptionalInteger = toSVG IntegerOptionalInteger(value);
26 OwnPtr<InterpolableList> result = InterpolableList::create(2);
27 result->set(0, InterpolableNumber::create(integerOptionalInteger->firstInteg er()->value()));
28 result->set(1, InterpolableNumber::create(integerOptionalInteger->secondInte ger()->value()));
29 return result.release();
30 }
31
32 PassRefPtrWillBeRawPtr<SVGIntegerOptionalInteger> IntegerOptionalIntegerSVGInter polation::fromInterpolableValue(const InterpolableValue& value, int min)
33 {
34 const InterpolableList& list = toInterpolableList(value);
35 return SVGIntegerOptionalInteger::create(
36 toPositiveInteger(list.get(0), min),
37 toPositiveInteger(list.get(1), min));
38 }
39
40 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698