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

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

Issue 2794013002: Fewer reused duplicate symbol names in animation. (Closed)
Patch Set: Addressed review comments. Created 3 years, 8 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/CSSTranslateInterpolationType.h" 5 #include "core/animation/CSSTranslateInterpolationType.h"
6 6
7 #include "core/animation/LengthInterpolationFunctions.h" 7 #include "core/animation/LengthInterpolationFunctions.h"
8 #include "core/css/CSSValueList.h" 8 #include "core/css/CSSValueList.h"
9 #include "core/css/resolver/StyleResolverState.h" 9 #include "core/css/resolver/StyleResolverState.h"
10 #include "platform/transforms/TranslateTransformOperation.h" 10 #include "platform/transforms/TranslateTransformOperation.h"
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 RefPtr<TransformOperation> m_inheritedTranslate; 52 RefPtr<TransformOperation> m_inheritedTranslate;
53 }; 53 };
54 54
55 enum TranslateComponentIndex : unsigned { 55 enum TranslateComponentIndex : unsigned {
56 TranslateX, 56 TranslateX,
57 TranslateY, 57 TranslateY,
58 TranslateZ, 58 TranslateZ,
59 TranslateComponentIndexCount, 59 TranslateComponentIndexCount,
60 }; 60 };
61 61
62 std::unique_ptr<InterpolableValue> createIdentityInterpolableValue() { 62 std::unique_ptr<InterpolableValue> createTranslateIdentity() {
63 std::unique_ptr<InterpolableList> result = 63 std::unique_ptr<InterpolableList> result =
64 InterpolableList::create(TranslateComponentIndexCount); 64 InterpolableList::create(TranslateComponentIndexCount);
65 result->set(TranslateX, 65 result->set(TranslateX,
66 LengthInterpolationFunctions::createNeutralInterpolableValue()); 66 LengthInterpolationFunctions::createNeutralInterpolableValue());
67 result->set(TranslateY, 67 result->set(TranslateY,
68 LengthInterpolationFunctions::createNeutralInterpolableValue()); 68 LengthInterpolationFunctions::createNeutralInterpolableValue());
69 result->set(TranslateZ, 69 result->set(TranslateZ,
70 LengthInterpolationFunctions::createNeutralInterpolableValue()); 70 LengthInterpolationFunctions::createNeutralInterpolableValue());
71 return std::move(result); 71 return std::move(result);
72 } 72 }
(...skipping 16 matching lines...) Expand all
89 Length(translate->z(), Fixed), zoom) 89 Length(translate->z(), Fixed), zoom)
90 .interpolableValue); 90 .interpolableValue);
91 return InterpolationValue(std::move(result)); 91 return InterpolationValue(std::move(result));
92 } 92 }
93 93
94 } // namespace 94 } // namespace
95 95
96 InterpolationValue CSSTranslateInterpolationType::maybeConvertNeutral( 96 InterpolationValue CSSTranslateInterpolationType::maybeConvertNeutral(
97 const InterpolationValue& underlying, 97 const InterpolationValue& underlying,
98 ConversionCheckers&) const { 98 ConversionCheckers&) const {
99 return InterpolationValue(createIdentityInterpolableValue()); 99 return InterpolationValue(createTranslateIdentity());
100 } 100 }
101 101
102 InterpolationValue CSSTranslateInterpolationType::maybeConvertInitial( 102 InterpolationValue CSSTranslateInterpolationType::maybeConvertInitial(
103 const StyleResolverState&, 103 const StyleResolverState&,
104 ConversionCheckers&) const { 104 ConversionCheckers&) const {
105 return createNoneValue(); 105 return createNoneValue();
106 } 106 }
107 107
108 InterpolationValue CSSTranslateInterpolationType::maybeConvertInherit( 108 InterpolationValue CSSTranslateInterpolationType::maybeConvertInherit(
109 const StyleResolverState& state, 109 const StyleResolverState& state,
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 return InterpolationValue(std::move(result)); 146 return InterpolationValue(std::move(result));
147 } 147 }
148 148
149 PairwiseInterpolationValue CSSTranslateInterpolationType::maybeMergeSingles( 149 PairwiseInterpolationValue CSSTranslateInterpolationType::maybeMergeSingles(
150 InterpolationValue&& start, 150 InterpolationValue&& start,
151 InterpolationValue&& end) const { 151 InterpolationValue&& end) const {
152 size_t startListLength = 152 size_t startListLength =
153 toInterpolableList(*start.interpolableValue).length(); 153 toInterpolableList(*start.interpolableValue).length();
154 size_t endListLength = toInterpolableList(*end.interpolableValue).length(); 154 size_t endListLength = toInterpolableList(*end.interpolableValue).length();
155 if (startListLength < endListLength) 155 if (startListLength < endListLength)
156 start.interpolableValue = createIdentityInterpolableValue(); 156 start.interpolableValue = createTranslateIdentity();
157 else if (endListLength < startListLength) 157 else if (endListLength < startListLength)
158 end.interpolableValue = createIdentityInterpolableValue(); 158 end.interpolableValue = createTranslateIdentity();
159 159
160 return PairwiseInterpolationValue(std::move(start.interpolableValue), 160 return PairwiseInterpolationValue(std::move(start.interpolableValue),
161 std::move(end.interpolableValue)); 161 std::move(end.interpolableValue));
162 } 162 }
163 163
164 InterpolationValue 164 InterpolationValue
165 CSSTranslateInterpolationType::maybeConvertStandardPropertyUnderlyingValue( 165 CSSTranslateInterpolationType::maybeConvertStandardPropertyUnderlyingValue(
166 const ComputedStyle& style) const { 166 const ComputedStyle& style) const {
167 return convertTranslateOperation(style.translate(), style.effectiveZoom()); 167 return convertTranslateOperation(style.translate(), style.effectiveZoom());
168 } 168 }
169 169
170 void CSSTranslateInterpolationType::composite( 170 void CSSTranslateInterpolationType::composite(
171 UnderlyingValueOwner& underlyingValueOwner, 171 UnderlyingValueOwner& underlyingValueOwner,
172 double underlyingFraction, 172 double underlyingFraction,
173 const InterpolationValue& value, 173 const InterpolationValue& value,
174 double interpolationFraction) const { 174 double interpolationFraction) const {
175 if (isNoneValue(value)) { 175 if (isNoneValue(value)) {
176 return; 176 return;
177 } 177 }
178 178
179 if (isNoneValue(underlyingValueOwner.mutableValue())) { 179 if (isNoneValue(underlyingValueOwner.mutableValue())) {
180 underlyingValueOwner.mutableValue().interpolableValue = 180 underlyingValueOwner.mutableValue().interpolableValue =
181 createIdentityInterpolableValue(); 181 createTranslateIdentity();
182 } 182 }
183 183
184 return CSSInterpolationType::composite( 184 return CSSInterpolationType::composite(
185 underlyingValueOwner, underlyingFraction, value, interpolationFraction); 185 underlyingValueOwner, underlyingFraction, value, interpolationFraction);
186 } 186 }
187 187
188 void CSSTranslateInterpolationType::applyStandardPropertyValue( 188 void CSSTranslateInterpolationType::applyStandardPropertyValue(
189 const InterpolableValue& interpolableValue, 189 const InterpolableValue& interpolableValue,
190 const NonInterpolableValue*, 190 const NonInterpolableValue*,
191 StyleResolverState& state) const { 191 StyleResolverState& state) const {
(...skipping 12 matching lines...) Expand all
204 *list.get(TranslateZ), nullptr, conversionData, ValueRangeAll) 204 *list.get(TranslateZ), nullptr, conversionData, ValueRangeAll)
205 .pixels(); 205 .pixels();
206 206
207 RefPtr<TranslateTransformOperation> result = 207 RefPtr<TranslateTransformOperation> result =
208 TranslateTransformOperation::create(x, y, z, 208 TranslateTransformOperation::create(x, y, z,
209 TransformOperation::Translate3D); 209 TransformOperation::Translate3D);
210 state.style()->setTranslate(std::move(result)); 210 state.style()->setTranslate(std::move(result));
211 } 211 }
212 212
213 } // namespace blink 213 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698