Chromium Code Reviews| OLD | NEW |
|---|---|
| 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" |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 96 { | 96 { |
| 97 std::unique_ptr<InterpolableList> listOfValues = InterpolableList::create(nu mLengthInterpolatedUnits); | 97 std::unique_ptr<InterpolableList> listOfValues = InterpolableList::create(nu mLengthInterpolatedUnits); |
| 98 for (size_t i = 0; i < numLengthInterpolatedUnits; ++i) | 98 for (size_t i = 0; i < numLengthInterpolatedUnits; ++i) |
| 99 listOfValues->set(i, InterpolableNumber::create(0)); | 99 listOfValues->set(i, InterpolableNumber::create(0)); |
| 100 | 100 |
| 101 return std::move(listOfValues); | 101 return std::move(listOfValues); |
| 102 } | 102 } |
| 103 | 103 |
| 104 InterpolationValue SVGLengthInterpolationType::convertSVGLength(const SVGLength& length) | 104 InterpolationValue SVGLengthInterpolationType::convertSVGLength(const SVGLength& length) |
| 105 { | 105 { |
| 106 double value = length.valueInSpecifiedUnits(); | 106 const CSSPrimitiveValue* primitiveValue = length.asCSSPrimitiveValue(); |
| 107 LengthInterpolatedUnit unitType = convertToInterpolatedUnit(length.typeWithC alcResolved(), value); | 107 |
| 108 CSSLengthArray lengthArray; | |
| 109 primitiveValue->accumulateLengthArray(lengthArray); | |
| 108 | 110 |
| 109 double values[numLengthInterpolatedUnits] = { }; | 111 double values[numLengthInterpolatedUnits] = { }; |
| 110 values[unitType] = value; | 112 |
| 113 for (size_t i = 0; i < CSSPrimitiveValue::LengthUnitTypeCount; i++) { | |
| 114 double value = lengthArray.values[i]; | |
| 115 LengthInterpolatedUnit unitType = convertToInterpolatedUnit(SVGLength::t oUnitType(i), value); | |
|
fs
2016/07/16 21:13:02
Couldn't we take this opportunity to transition to
Shanmuga Pandi
2016/07/18 13:35:32
That's good thought.. :)
Done!!
fs
2016/07/18 13:56:48
Looks great, thanks!
| |
| 116 values[unitType] = value; | |
| 117 } | |
| 111 | 118 |
| 112 std::unique_ptr<InterpolableList> listOfValues = InterpolableList::create(nu mLengthInterpolatedUnits); | 119 std::unique_ptr<InterpolableList> listOfValues = InterpolableList::create(nu mLengthInterpolatedUnits); |
| 113 for (size_t i = 0; i < numLengthInterpolatedUnits; ++i) | 120 for (size_t i = 0; i < numLengthInterpolatedUnits; ++i) |
| 114 listOfValues->set(i, InterpolableNumber::create(values[i])); | 121 listOfValues->set(i, InterpolableNumber::create(values[i])); |
| 115 | 122 |
| 116 return InterpolationValue(std::move(listOfValues)); | 123 return InterpolationValue(std::move(listOfValues)); |
| 117 } | 124 } |
| 118 | 125 |
| 119 SVGLength* SVGLengthInterpolationType::resolveInterpolableSVGLength(const Interp olableValue& interpolableValue, const SVGLengthContext& lengthContext, SVGLength Mode unitMode, bool negativeValuesForbidden) | 126 SVGLength* SVGLengthInterpolationType::resolveInterpolableSVGLength(const Interp olableValue& interpolableValue, const SVGLengthContext& lengthContext, SVGLength Mode unitMode, bool negativeValuesForbidden) |
| 120 { | 127 { |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 177 } | 184 } |
| 178 | 185 |
| 179 void SVGLengthInterpolationType::apply(const InterpolableValue& interpolableValu e, const NonInterpolableValue* nonInterpolableValue, InterpolationEnvironment& e nvironment) const | 186 void SVGLengthInterpolationType::apply(const InterpolableValue& interpolableValu e, const NonInterpolableValue* nonInterpolableValue, InterpolationEnvironment& e nvironment) const |
| 180 { | 187 { |
| 181 SVGElement& element = environment.svgElement(); | 188 SVGElement& element = environment.svgElement(); |
| 182 SVGLengthContext lengthContext(&element); | 189 SVGLengthContext lengthContext(&element); |
| 183 element.setWebAnimatedAttribute(attribute(), resolveInterpolableSVGLength(in terpolableValue, lengthContext, m_unitMode, m_negativeValuesForbidden)); | 190 element.setWebAnimatedAttribute(attribute(), resolveInterpolableSVGLength(in terpolableValue, lengthContext, m_unitMode, m_negativeValuesForbidden)); |
| 184 } | 191 } |
| 185 | 192 |
| 186 } // namespace blink | 193 } // namespace blink |
| OLD | NEW |