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

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

Issue 2130753003: Support viewport units for SVG Length animations (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 months 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
1 // Copyright 2015 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "core/animation/SVGLengthInterpolationType.h" 5 #include "core/animation/SVGLengthInterpolationType.h"
6 6
7 #include "core/animation/InterpolationEnvironment.h" 7 #include "core/animation/InterpolationEnvironment.h"
8 #include "core/animation/StringKeyframe.h" 8 #include "core/animation/StringKeyframe.h"
9 #include "core/css/CSSHelper.h" 9 #include "core/css/CSSHelper.h"
10 #include "core/svg/SVGElement.h" 10 #include "core/svg/SVGElement.h"
11 #include "core/svg/SVGLength.h" 11 #include "core/svg/SVGLength.h"
12 #include "core/svg/SVGLengthContext.h" 12 #include "core/svg/SVGLengthContext.h"
13 #include <memory> 13 #include <memory>
14 14
15 namespace blink { 15 namespace blink {
16 16
17 namespace { 17 namespace {
18 18
19 enum LengthInterpolatedUnit { 19 enum LengthInterpolatedUnit {
20 LengthInterpolatedNumber, 20 LengthInterpolatedNumber,
21 LengthInterpolatedPercentage, 21 LengthInterpolatedPercentage,
22 LengthInterpolatedEMS, 22 LengthInterpolatedEMS,
23 LengthInterpolatedEXS, 23 LengthInterpolatedEXS,
24 LengthInterpolatedREMS, 24 LengthInterpolatedREMS,
25 LengthInterpolatedCHS, 25 LengthInterpolatedCHS,
26 LengthInterpolatedViewportWidth,
27 LengthInterpolatedViewportHeight,
28 LengthInterpolatedViewportMin,
29 LengthInterpolatedViewportMax,
26 }; 30 };
27 31
28 static const CSSPrimitiveValue::UnitType unitTypes[] = { 32 static const CSSPrimitiveValue::UnitType unitTypes[] = {
29 CSSPrimitiveValue::UnitType::UserUnits, 33 CSSPrimitiveValue::UnitType::UserUnits,
30 CSSPrimitiveValue::UnitType::Percentage, 34 CSSPrimitiveValue::UnitType::Percentage,
31 CSSPrimitiveValue::UnitType::Ems, 35 CSSPrimitiveValue::UnitType::Ems,
32 CSSPrimitiveValue::UnitType::Exs, 36 CSSPrimitiveValue::UnitType::Exs,
33 CSSPrimitiveValue::UnitType::Rems, 37 CSSPrimitiveValue::UnitType::Rems,
34 CSSPrimitiveValue::UnitType::Chs 38 CSSPrimitiveValue::UnitType::Chs,
39 CSSPrimitiveValue::UnitType::ViewportWidth,
40 CSSPrimitiveValue::UnitType::ViewportHeight,
41 CSSPrimitiveValue::UnitType::ViewportMin,
42 CSSPrimitiveValue::UnitType::ViewportMax
alancutter (OOO until 2018) 2016/07/11 06:28:35 Nit: Let's add a trailing comma here to be consist
Shanmuga Pandi 2016/07/12 06:44:03 Done.
35 }; 43 };
36 44
37 const size_t numLengthInterpolatedUnits = WTF_ARRAY_LENGTH(unitTypes); 45 const size_t numLengthInterpolatedUnits = WTF_ARRAY_LENGTH(unitTypes);
38 46
39 LengthInterpolatedUnit convertToInterpolatedUnit(CSSPrimitiveValue::UnitType uni tType, double& value) 47 LengthInterpolatedUnit convertToInterpolatedUnit(CSSPrimitiveValue::UnitType uni tType, double& value)
40 { 48 {
41 switch (unitType) { 49 switch (unitType) {
42 case CSSPrimitiveValue::UnitType::Unknown: 50 case CSSPrimitiveValue::UnitType::Unknown:
43 default: 51 default:
44 NOTREACHED(); 52 NOTREACHED();
(...skipping 19 matching lines...) Expand all
64 case CSSPrimitiveValue::UnitType::Points: 72 case CSSPrimitiveValue::UnitType::Points:
65 value *= cssPixelsPerPoint; 73 value *= cssPixelsPerPoint;
66 return LengthInterpolatedNumber; 74 return LengthInterpolatedNumber;
67 case CSSPrimitiveValue::UnitType::Picas: 75 case CSSPrimitiveValue::UnitType::Picas:
68 value *= cssPixelsPerPica; 76 value *= cssPixelsPerPica;
69 return LengthInterpolatedNumber; 77 return LengthInterpolatedNumber;
70 case CSSPrimitiveValue::UnitType::Rems: 78 case CSSPrimitiveValue::UnitType::Rems:
71 return LengthInterpolatedREMS; 79 return LengthInterpolatedREMS;
72 case CSSPrimitiveValue::UnitType::Chs: 80 case CSSPrimitiveValue::UnitType::Chs:
73 return LengthInterpolatedCHS; 81 return LengthInterpolatedCHS;
82 case CSSPrimitiveValue::UnitType::ViewportWidth:
83 return LengthInterpolatedViewportWidth;
84 case CSSPrimitiveValue::UnitType::ViewportHeight:
85 return LengthInterpolatedViewportHeight;
86 case CSSPrimitiveValue::UnitType::ViewportMin:
87 return LengthInterpolatedViewportMin;
88 case CSSPrimitiveValue::UnitType::ViewportMax:
89 return LengthInterpolatedViewportMax;
74 } 90 }
75 } 91 }
76 92
77 } // namespace 93 } // namespace
78 94
79 std::unique_ptr<InterpolableValue> SVGLengthInterpolationType::neutralInterpolab leValue() 95 std::unique_ptr<InterpolableValue> SVGLengthInterpolationType::neutralInterpolab leValue()
80 { 96 {
81 std::unique_ptr<InterpolableList> listOfValues = InterpolableList::create(nu mLengthInterpolatedUnits); 97 std::unique_ptr<InterpolableList> listOfValues = InterpolableList::create(nu mLengthInterpolatedUnits);
82 for (size_t i = 0; i < numLengthInterpolatedUnits; ++i) 98 for (size_t i = 0; i < numLengthInterpolatedUnits; ++i)
83 listOfValues->set(i, InterpolableNumber::create(0)); 99 listOfValues->set(i, InterpolableNumber::create(0));
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 } 177 }
162 178
163 void SVGLengthInterpolationType::apply(const InterpolableValue& interpolableValu e, const NonInterpolableValue* nonInterpolableValue, InterpolationEnvironment& e nvironment) const 179 void SVGLengthInterpolationType::apply(const InterpolableValue& interpolableValu e, const NonInterpolableValue* nonInterpolableValue, InterpolationEnvironment& e nvironment) const
164 { 180 {
165 SVGElement& element = environment.svgElement(); 181 SVGElement& element = environment.svgElement();
166 SVGLengthContext lengthContext(&element); 182 SVGLengthContext lengthContext(&element);
167 element.setWebAnimatedAttribute(attribute(), resolveInterpolableSVGLength(in terpolableValue, lengthContext, m_unitMode, m_negativeValuesForbidden)); 183 element.setWebAnimatedAttribute(attribute(), resolveInterpolableSVGLength(in terpolableValue, lengthContext, m_unitMode, m_negativeValuesForbidden));
168 } 184 }
169 185
170 } // namespace blink 186 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698