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/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 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 } | 239 } |
240 | 240 |
241 // TODO(alancutter): Move this to Length.h. | 241 // TODO(alancutter): Move this to Length.h. |
242 static double clampToRange(double x, ValueRange range) | 242 static double clampToRange(double x, ValueRange range) |
243 { | 243 { |
244 return (range == ValueRangeNonNegative && x < 0) ? 0 : x; | 244 return (range == ValueRangeNonNegative && x < 0) ? 0 : x; |
245 } | 245 } |
246 | 246 |
247 static Length createLength(double pixels, double percentage, bool hasPercentage,
ValueRange range) | 247 static Length createLength(double pixels, double percentage, bool hasPercentage,
ValueRange range) |
248 { | 248 { |
249 ASSERT(hasPercentage || percentage == 0); | 249 if (percentage != 0) |
250 if (pixels && hasPercentage) | 250 hasPercentage = true; |
| 251 if (pixels != 0 && hasPercentage) |
251 return Length(CalculationValue::create(PixelsAndPercent(pixels, percenta
ge), range)); | 252 return Length(CalculationValue::create(PixelsAndPercent(pixels, percenta
ge), range)); |
252 if (hasPercentage) | 253 if (hasPercentage) |
253 return Length(clampToRange(percentage, range), Percent); | 254 return Length(clampToRange(percentage, range), Percent); |
254 return Length(CSSPrimitiveValue::clampToCSSLengthRange(clampToRange(pixels,
range)), Fixed); | 255 return Length(CSSPrimitiveValue::clampToCSSLengthRange(clampToRange(pixels,
range)), Fixed); |
255 } | 256 } |
256 | 257 |
257 static Length resolveInterpolablePixelsOrPercentageLength(const InterpolableList
& values, bool hasPercentage, ValueRange range, double zoom) | 258 static Length resolveInterpolablePixelsOrPercentageLength(const InterpolableList
& values, bool hasPercentage, ValueRange range, double zoom) |
258 { | 259 { |
259 ASSERT(isPixelsOrPercentOnly(values)); | 260 ASSERT(isPixelsOrPercentOnly(values)); |
260 double pixels = toInterpolableNumber(values.get(CSSPrimitiveValue::UnitTypeP
ixels))->value() * zoom; | 261 double pixels = toInterpolableNumber(values.get(CSSPrimitiveValue::UnitTypeP
ixels))->value() * zoom; |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
338 RefPtr<AnimatableValue> after = CSSAnimatableValueFactory::create(cs
sProperty(), *state.style()); | 339 RefPtr<AnimatableValue> after = CSSAnimatableValueFactory::create(cs
sProperty(), *state.style()); |
339 ASSERT(before->equals(*after)); | 340 ASSERT(before->equals(*after)); |
340 #endif | 341 #endif |
341 return; | 342 return; |
342 } | 343 } |
343 } | 344 } |
344 StyleBuilder::applyProperty(cssProperty(), state, createCSSValue(values, has
Percentage, m_valueRange).get()); | 345 StyleBuilder::applyProperty(cssProperty(), state, createCSSValue(values, has
Percentage, m_valueRange).get()); |
345 } | 346 } |
346 | 347 |
347 } // namespace blink | 348 } // namespace blink |
OLD | NEW |