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

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

Issue 1644883002: Add additive animation support for CSS property translate (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@_propertyInterpolationTypesMapping
Patch Set: Created 4 years, 10 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/CSSLengthInterpolationType.h" 5 #include "core/animation/CSSLengthInterpolationType.h"
6 6
7 #include "core/animation/LengthPropertyFunctions.h" 7 #include "core/animation/LengthPropertyFunctions.h"
8 #include "core/animation/css/CSSAnimatableValueFactory.h" 8 #include "core/animation/css/CSSAnimatableValueFactory.h"
9 #include "core/css/CSSCalculationValue.h" 9 #include "core/css/CSSCalculationValue.h"
10 #include "core/css/resolver/StyleBuilder.h" 10 #include "core/css/resolver/StyleBuilder.h"
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 } 220 }
221 221
222 // TODO(alancutter): Move this to Length.h. 222 // TODO(alancutter): Move this to Length.h.
223 static double clampToRange(double x, ValueRange range) 223 static double clampToRange(double x, ValueRange range)
224 { 224 {
225 return (range == ValueRangeNonNegative && x < 0) ? 0 : x; 225 return (range == ValueRangeNonNegative && x < 0) ? 0 : x;
226 } 226 }
227 227
228 static Length createLength(double pixels, double percentage, bool hasPercentage, ValueRange range) 228 static Length createLength(double pixels, double percentage, bool hasPercentage, ValueRange range)
229 { 229 {
230 ASSERT(hasPercentage || percentage == 0); 230 if (percentage != 0)
231 if (pixels && hasPercentage) 231 hasPercentage = true;
232 if (pixels != 0 && hasPercentage)
232 return Length(CalculationValue::create(PixelsAndPercent(pixels, percenta ge), range)); 233 return Length(CalculationValue::create(PixelsAndPercent(pixels, percenta ge), range));
233 if (hasPercentage) 234 if (hasPercentage)
234 return Length(clampToRange(percentage, range), Percent); 235 return Length(clampToRange(percentage, range), Percent);
235 return Length(CSSPrimitiveValue::clampToCSSLengthRange(clampToRange(pixels, range)), Fixed); 236 return Length(CSSPrimitiveValue::clampToCSSLengthRange(clampToRange(pixels, range)), Fixed);
236 } 237 }
237 238
238 static Length resolveInterpolablePixelsOrPercentageLength(const InterpolableList & values, bool hasPercentage, ValueRange range, double zoom) 239 static Length resolveInterpolablePixelsOrPercentageLength(const InterpolableList & values, bool hasPercentage, ValueRange range, double zoom)
239 { 240 {
240 ASSERT(isPixelsOrPercentOnly(values)); 241 ASSERT(isPixelsOrPercentOnly(values));
241 double pixels = toInterpolableNumber(values.get(CSSPrimitiveValue::UnitTypeP ixels))->value() * zoom; 242 double pixels = toInterpolableNumber(values.get(CSSPrimitiveValue::UnitTypeP ixels))->value() * zoom;
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
319 RefPtr<AnimatableValue> after = CSSAnimatableValueFactory::create(cs sProperty(), *state.style()); 320 RefPtr<AnimatableValue> after = CSSAnimatableValueFactory::create(cs sProperty(), *state.style());
320 ASSERT(before->equals(*after)); 321 ASSERT(before->equals(*after));
321 #endif 322 #endif
322 return; 323 return;
323 } 324 }
324 } 325 }
325 StyleBuilder::applyProperty(cssProperty(), state, createCSSValue(values, has Percentage, m_valueRange).get()); 326 StyleBuilder::applyProperty(cssProperty(), state, createCSSValue(values, has Percentage, m_valueRange).get());
326 } 327 }
327 328
328 } // namespace blink 329 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698