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

Side by Side Diff: third_party/WebKit/Source/core/animation/CSSScaleInterpolationType.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 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/CSSScaleInterpolationType.h" 5 #include "core/animation/CSSScaleInterpolationType.h"
6 6
7 #include "core/css/CSSPrimitiveValue.h" 7 #include "core/css/CSSPrimitiveValue.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 "wtf/PtrUtil.h" 10 #include "wtf/PtrUtil.h"
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 if (array[i] != other.array[i]) 48 if (array[i] != other.array[i])
49 return false; 49 return false;
50 } 50 }
51 return isNone == other.isNone; 51 return isNone == other.isNone;
52 } 52 }
53 53
54 double array[3]; 54 double array[3];
55 bool isNone; 55 bool isNone;
56 }; 56 };
57 57
58 std::unique_ptr<InterpolableValue> createIdentityInterpolableValue() { 58 std::unique_ptr<InterpolableValue> createScaleIdentity() {
59 std::unique_ptr<InterpolableList> list = InterpolableList::create(3); 59 std::unique_ptr<InterpolableList> list = InterpolableList::create(3);
60 for (size_t i = 0; i < 3; i++) 60 for (size_t i = 0; i < 3; i++)
61 list->set(i, InterpolableNumber::create(1)); 61 list->set(i, InterpolableNumber::create(1));
62 return std::move(list); 62 return std::move(list);
63 } 63 }
64 64
65 class InheritedScaleChecker : public InterpolationType::ConversionChecker { 65 class InheritedScaleChecker : public InterpolationType::ConversionChecker {
66 public: 66 public:
67 static std::unique_ptr<InheritedScaleChecker> create(const Scale& scale) { 67 static std::unique_ptr<InheritedScaleChecker> create(const Scale& scale) {
68 return WTF::wrapUnique(new InheritedScaleChecker(scale)); 68 return WTF::wrapUnique(new InheritedScaleChecker(scale));
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 toCSSScaleNonInterpolableValue(*value.nonInterpolableValue).setIsAdditive(); 186 toCSSScaleNonInterpolableValue(*value.nonInterpolableValue).setIsAdditive();
187 } 187 }
188 188
189 PairwiseInterpolationValue CSSScaleInterpolationType::maybeMergeSingles( 189 PairwiseInterpolationValue CSSScaleInterpolationType::maybeMergeSingles(
190 InterpolationValue&& start, 190 InterpolationValue&& start,
191 InterpolationValue&& end) const { 191 InterpolationValue&& end) const {
192 size_t startListLength = 192 size_t startListLength =
193 toInterpolableList(*start.interpolableValue).length(); 193 toInterpolableList(*start.interpolableValue).length();
194 size_t endListLength = toInterpolableList(*end.interpolableValue).length(); 194 size_t endListLength = toInterpolableList(*end.interpolableValue).length();
195 if (startListLength < endListLength) 195 if (startListLength < endListLength)
196 start.interpolableValue = createIdentityInterpolableValue(); 196 start.interpolableValue = createScaleIdentity();
197 else if (endListLength < startListLength) 197 else if (endListLength < startListLength)
198 end.interpolableValue = createIdentityInterpolableValue(); 198 end.interpolableValue = createScaleIdentity();
199 199
200 return PairwiseInterpolationValue( 200 return PairwiseInterpolationValue(
201 std::move(start.interpolableValue), std::move(end.interpolableValue), 201 std::move(start.interpolableValue), std::move(end.interpolableValue),
202 CSSScaleNonInterpolableValue::merge( 202 CSSScaleNonInterpolableValue::merge(
203 toCSSScaleNonInterpolableValue(*start.nonInterpolableValue), 203 toCSSScaleNonInterpolableValue(*start.nonInterpolableValue),
204 toCSSScaleNonInterpolableValue(*end.nonInterpolableValue))); 204 toCSSScaleNonInterpolableValue(*end.nonInterpolableValue)));
205 } 205 }
206 206
207 InterpolationValue 207 InterpolationValue
208 CSSScaleInterpolationType::maybeConvertStandardPropertyUnderlyingValue( 208 CSSScaleInterpolationType::maybeConvertStandardPropertyUnderlyingValue(
209 const ComputedStyle& style) const { 209 const ComputedStyle& style) const {
210 return Scale(style.scale()).createInterpolationValue(); 210 return Scale(style.scale()).createInterpolationValue();
211 } 211 }
212 212
213 void CSSScaleInterpolationType::composite( 213 void CSSScaleInterpolationType::composite(
214 UnderlyingValueOwner& underlyingValueOwner, 214 UnderlyingValueOwner& underlyingValueOwner,
215 double underlyingFraction, 215 double underlyingFraction,
216 const InterpolationValue& value, 216 const InterpolationValue& value,
217 double interpolationFraction) const { 217 double interpolationFraction) const {
218 if (toInterpolableList(*underlyingValueOwner.mutableValue().interpolableValue) 218 if (toInterpolableList(*underlyingValueOwner.mutableValue().interpolableValue)
219 .length() == 0) { 219 .length() == 0) {
220 underlyingValueOwner.mutableValue().interpolableValue = 220 underlyingValueOwner.mutableValue().interpolableValue =
221 createIdentityInterpolableValue(); 221 createScaleIdentity();
222 } 222 }
223 223
224 const CSSScaleNonInterpolableValue& metadata = 224 const CSSScaleNonInterpolableValue& metadata =
225 toCSSScaleNonInterpolableValue(*value.nonInterpolableValue); 225 toCSSScaleNonInterpolableValue(*value.nonInterpolableValue);
226 DCHECK(metadata.isStartAdditive() || metadata.isEndAdditive()); 226 DCHECK(metadata.isStartAdditive() || metadata.isEndAdditive());
227 227
228 InterpolableList& underlyingList = toInterpolableList( 228 InterpolableList& underlyingList = toInterpolableList(
229 *underlyingValueOwner.mutableValue().interpolableValue); 229 *underlyingValueOwner.mutableValue().interpolableValue);
230 for (size_t i = 0; i < 3; i++) { 230 for (size_t i = 0; i < 3; i++) {
231 InterpolableNumber& underlying = 231 InterpolableNumber& underlying =
(...skipping 15 matching lines...) Expand all
247 if (scale.isNone) { 247 if (scale.isNone) {
248 state.style()->setScale(nullptr); 248 state.style()->setScale(nullptr);
249 return; 249 return;
250 } 250 }
251 state.style()->setScale(ScaleTransformOperation::create( 251 state.style()->setScale(ScaleTransformOperation::create(
252 scale.array[0], scale.array[1], scale.array[2], 252 scale.array[0], scale.array[1], scale.array[2],
253 TransformOperation::Scale3D)); 253 TransformOperation::Scale3D));
254 } 254 }
255 255
256 } // namespace blink 256 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698