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

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

Issue 2283783002: Move static methods out of CSSLengthInterpolationType to LengthInterpolationFunctions (Closed)
Patch Set: Fix compile Created 4 years, 3 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/CSSLengthListInterpolationType.h" 5 #include "core/animation/CSSLengthListInterpolationType.h"
6 6
7 #include "core/animation/CSSLengthInterpolationType.h" 7 #include "core/animation/LengthInterpolationFunctions.h"
8 #include "core/animation/LengthListPropertyFunctions.h" 8 #include "core/animation/LengthListPropertyFunctions.h"
9 #include "core/animation/ListInterpolationFunctions.h" 9 #include "core/animation/ListInterpolationFunctions.h"
10 #include "core/animation/UnderlyingLengthChecker.h" 10 #include "core/animation/UnderlyingLengthChecker.h"
11 #include "core/css/CSSPrimitiveValue.h" 11 #include "core/css/CSSPrimitiveValue.h"
12 #include "core/css/CSSValueList.h" 12 #include "core/css/CSSValueList.h"
13 #include "core/css/resolver/StyleResolverState.h" 13 #include "core/css/resolver/StyleResolverState.h"
14 #include "wtf/PtrUtil.h" 14 #include "wtf/PtrUtil.h"
15 #include <memory> 15 #include <memory>
16 16
17 namespace blink { 17 namespace blink {
18 18
19 CSSLengthListInterpolationType::CSSLengthListInterpolationType(CSSPropertyID pro perty) 19 CSSLengthListInterpolationType::CSSLengthListInterpolationType(CSSPropertyID pro perty)
20 : CSSInterpolationType(property) 20 : CSSInterpolationType(property)
21 , m_valueRange(LengthListPropertyFunctions::getValueRange(property)) 21 , m_valueRange(LengthListPropertyFunctions::getValueRange(property))
22 { 22 {
23 } 23 }
24 24
25 InterpolationValue CSSLengthListInterpolationType::maybeConvertNeutral(const Int erpolationValue& underlying, ConversionCheckers& conversionCheckers) const 25 InterpolationValue CSSLengthListInterpolationType::maybeConvertNeutral(const Int erpolationValue& underlying, ConversionCheckers& conversionCheckers) const
26 { 26 {
27 size_t underlyingLength = UnderlyingLengthChecker::getUnderlyingLength(under lying); 27 size_t underlyingLength = UnderlyingLengthChecker::getUnderlyingLength(under lying);
28 conversionCheckers.append(UnderlyingLengthChecker::create(underlyingLength)) ; 28 conversionCheckers.append(UnderlyingLengthChecker::create(underlyingLength)) ;
29 29
30 if (underlyingLength == 0) 30 if (underlyingLength == 0)
31 return nullptr; 31 return nullptr;
32 32
33 return ListInterpolationFunctions::createList(underlyingLength, [](size_t) { 33 return ListInterpolationFunctions::createList(underlyingLength, [](size_t) {
34 return InterpolationValue(CSSLengthInterpolationType::createNeutralInter polableValue()); 34 return InterpolationValue(LengthInterpolationFunctions::createNeutralInt erpolableValue());
35 }); 35 });
36 } 36 }
37 37
38 static InterpolationValue maybeConvertLengthList(const Vector<Length>& lengthLis t, float zoom) 38 static InterpolationValue maybeConvertLengthList(const Vector<Length>& lengthLis t, float zoom)
39 { 39 {
40 if (lengthList.isEmpty()) 40 if (lengthList.isEmpty())
41 return nullptr; 41 return nullptr;
42 42
43 return ListInterpolationFunctions::createList(lengthList.size(), [&lengthLis t, zoom](size_t index) { 43 return ListInterpolationFunctions::createList(lengthList.size(), [&lengthLis t, zoom](size_t index) {
44 return CSSLengthInterpolationType::maybeConvertLength(lengthList[index], zoom); 44 return LengthInterpolationFunctions::maybeConvertLength(lengthList[index ], zoom);
45 }); 45 });
46 } 46 }
47 47
48 InterpolationValue CSSLengthListInterpolationType::maybeConvertInitial(const Sty leResolverState&, ConversionCheckers& conversionCheckers) const 48 InterpolationValue CSSLengthListInterpolationType::maybeConvertInitial(const Sty leResolverState&, ConversionCheckers& conversionCheckers) const
49 { 49 {
50 Vector<Length> initialLengthList; 50 Vector<Length> initialLengthList;
51 if (!LengthListPropertyFunctions::getInitialLengthList(cssProperty(), initia lLengthList)) 51 if (!LengthListPropertyFunctions::getInitialLengthList(cssProperty(), initia lLengthList))
52 return nullptr; 52 return nullptr;
53 return maybeConvertLengthList(initialLengthList, 1); 53 return maybeConvertLengthList(initialLengthList, 1);
54 } 54 }
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 return maybeConvertLengthList(inheritedLengthList, state.parentStyle()->effe ctiveZoom()); 89 return maybeConvertLengthList(inheritedLengthList, state.parentStyle()->effe ctiveZoom());
90 } 90 }
91 91
92 InterpolationValue CSSLengthListInterpolationType::maybeConvertValue(const CSSVa lue& value, const StyleResolverState&, ConversionCheckers&) const 92 InterpolationValue CSSLengthListInterpolationType::maybeConvertValue(const CSSVa lue& value, const StyleResolverState&, ConversionCheckers&) const
93 { 93 {
94 if (!value.isBaseValueList()) 94 if (!value.isBaseValueList())
95 return nullptr; 95 return nullptr;
96 96
97 const CSSValueList& list = toCSSValueList(value); 97 const CSSValueList& list = toCSSValueList(value);
98 return ListInterpolationFunctions::createList(list.length(), [&list](size_t index) { 98 return ListInterpolationFunctions::createList(list.length(), [&list](size_t index) {
99 return CSSLengthInterpolationType::maybeConvertCSSValue(list.item(index) ); 99 return LengthInterpolationFunctions::maybeConvertCSSValue(list.item(inde x));
100 }); 100 });
101 } 101 }
102 102
103 PairwiseInterpolationValue CSSLengthListInterpolationType::maybeMergeSingles(Int erpolationValue&& start, InterpolationValue&& end) const 103 PairwiseInterpolationValue CSSLengthListInterpolationType::maybeMergeSingles(Int erpolationValue&& start, InterpolationValue&& end) const
104 { 104 {
105 return ListInterpolationFunctions::maybeMergeSingles(std::move(start), std:: move(end), CSSLengthInterpolationType::staticMergeSingleConversions); 105 return ListInterpolationFunctions::maybeMergeSingles(std::move(start), std:: move(end), LengthInterpolationFunctions::mergeSingles);
106 } 106 }
107 107
108 InterpolationValue CSSLengthListInterpolationType::maybeConvertUnderlyingValue(c onst InterpolationEnvironment& environment) const 108 InterpolationValue CSSLengthListInterpolationType::maybeConvertUnderlyingValue(c onst InterpolationEnvironment& environment) const
109 { 109 {
110 Vector<Length> underlyingLengthList; 110 Vector<Length> underlyingLengthList;
111 if (!LengthListPropertyFunctions::getLengthList(cssProperty(), *environment. state().style(), underlyingLengthList)) 111 if (!LengthListPropertyFunctions::getLengthList(cssProperty(), *environment. state().style(), underlyingLengthList))
112 return nullptr; 112 return nullptr;
113 return maybeConvertLengthList(underlyingLengthList, environment.state().styl e()->effectiveZoom()); 113 return maybeConvertLengthList(underlyingLengthList, environment.state().styl e()->effectiveZoom());
114 } 114 }
115 115
116 void CSSLengthListInterpolationType::composite(UnderlyingValueOwner& underlyingV alueOwner, double underlyingFraction, const InterpolationValue& value, double in terpolationFraction) const 116 void CSSLengthListInterpolationType::composite(UnderlyingValueOwner& underlyingV alueOwner, double underlyingFraction, const InterpolationValue& value, double in terpolationFraction) const
117 { 117 {
118 ListInterpolationFunctions::composite(underlyingValueOwner, underlyingFracti on, *this, value, 118 ListInterpolationFunctions::composite(underlyingValueOwner, underlyingFracti on, *this, value,
119 CSSLengthInterpolationType::nonInterpolableValuesAreCompatible, 119 LengthInterpolationFunctions::nonInterpolableValuesAreCompatible,
120 CSSLengthInterpolationType::composite); 120 LengthInterpolationFunctions::composite);
121 } 121 }
122 122
123 void CSSLengthListInterpolationType::apply(const InterpolableValue& interpolable Value, const NonInterpolableValue* nonInterpolableValue, InterpolationEnvironmen t& environment) const 123 void CSSLengthListInterpolationType::apply(const InterpolableValue& interpolable Value, const NonInterpolableValue* nonInterpolableValue, InterpolationEnvironmen t& environment) const
124 { 124 {
125 const InterpolableList& interpolableList = toInterpolableList(interpolableVa lue); 125 const InterpolableList& interpolableList = toInterpolableList(interpolableVa lue);
126 const size_t length = interpolableList.length(); 126 const size_t length = interpolableList.length();
127 DCHECK_GT(length, 0U); 127 DCHECK_GT(length, 0U);
128 const NonInterpolableList& nonInterpolableList = toNonInterpolableList(*nonI nterpolableValue); 128 const NonInterpolableList& nonInterpolableList = toNonInterpolableList(*nonI nterpolableValue);
129 DCHECK_EQ(nonInterpolableList.length(), length); 129 DCHECK_EQ(nonInterpolableList.length(), length);
130 Vector<Length> result(length); 130 Vector<Length> result(length);
131 for (size_t i = 0; i < length; i++) { 131 for (size_t i = 0; i < length; i++) {
132 result[i] = CSSLengthInterpolationType::createLength( 132 result[i] = LengthInterpolationFunctions::createLength(
133 *interpolableList.get(i), 133 *interpolableList.get(i),
134 nonInterpolableList.get(i), 134 nonInterpolableList.get(i),
135 environment.state().cssToLengthConversionData(), 135 environment.state().cssToLengthConversionData(),
136 m_valueRange); 136 m_valueRange);
137 } 137 }
138 LengthListPropertyFunctions::setLengthList(cssProperty(), *environment.state ().style(), std::move(result)); 138 LengthListPropertyFunctions::setLengthList(cssProperty(), *environment.state ().style(), std::move(result));
139 } 139 }
140 140
141 } // namespace blink 141 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698