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

Side by Side Diff: Source/core/animation/LengthStyleInterpolation.cpp

Issue 1170913002: Clamp animated lengths to CSS length range to match CSSPrimitiveValue (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « LayoutTests/animations/css-length-range-crash.html ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "config.h" 5 #include "config.h"
6 #include "core/animation/LengthStyleInterpolation.h" 6 #include "core/animation/LengthStyleInterpolation.h"
7 7
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 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
262 ValueRange range = (interpolationRange == RangeNonNegative) ? ValueRangeNonN egative : ValueRangeAll; 262 ValueRange range = (interpolationRange == RangeNonNegative) ? ValueRangeNonN egative : ValueRangeAll;
263 PixelsAndPercent pixelsAndPercent(0, 0); 263 PixelsAndPercent pixelsAndPercent(0, 0);
264 if (hasPixels) 264 if (hasPixels)
265 pixelsAndPercent.pixels = toInterpolableNumber(values.get(CSSPrimitiveVa lue::UnitTypePixels))->value() * zoom; 265 pixelsAndPercent.pixels = toInterpolableNumber(values.get(CSSPrimitiveVa lue::UnitTypePixels))->value() * zoom;
266 if (hasPercent) 266 if (hasPercent)
267 pixelsAndPercent.percent = toInterpolableNumber(values.get(CSSPrimitiveV alue::UnitTypePercentage))->value(); 267 pixelsAndPercent.percent = toInterpolableNumber(values.get(CSSPrimitiveV alue::UnitTypePercentage))->value();
268 268
269 if (hasPixels && hasPercent) 269 if (hasPixels && hasPercent)
270 return Length(CalculationValue::create(pixelsAndPercent, range)); 270 return Length(CalculationValue::create(pixelsAndPercent, range));
271 if (hasPixels) 271 if (hasPixels)
272 return Length(clampToRange(pixelsAndPercent.pixels, range), Fixed); 272 return Length(CSSPrimitiveValue::clampToCSSLengthRange(clampToRange(pixe lsAndPercent.pixels, range)), Fixed);
273 if (hasPercent) 273 if (hasPercent)
274 return Length(clampToRange(pixelsAndPercent.percent, range), Percent); 274 return Length(clampToRange(pixelsAndPercent.percent, range), Percent);
275 ASSERT_NOT_REACHED(); 275 ASSERT_NOT_REACHED();
276 return Length(0, Fixed); 276 return Length(0, Fixed);
277 } 277 }
278 278
279 } 279 }
280 280
281 PassRefPtrWillBeRawPtr<CSSPrimitiveValue> LengthStyleInterpolation::fromInterpol ableValue(const InterpolableValue& value, InterpolationRange range) 281 PassRefPtrWillBeRawPtr<CSSPrimitiveValue> LengthStyleInterpolation::fromInterpol ableValue(const InterpolableValue& value, InterpolationRange range)
282 { 282 {
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
326 StyleBuilder::applyProperty(m_id, state, fromInterpolableValue(*m_cached Value, m_range).get()); 326 StyleBuilder::applyProperty(m_id, state, fromInterpolableValue(*m_cached Value, m_range).get());
327 } 327 }
328 } 328 }
329 329
330 DEFINE_TRACE(LengthStyleInterpolation) 330 DEFINE_TRACE(LengthStyleInterpolation)
331 { 331 {
332 StyleInterpolation::trace(visitor); 332 StyleInterpolation::trace(visitor);
333 } 333 }
334 334
335 } 335 }
OLDNEW
« no previous file with comments | « LayoutTests/animations/css-length-range-crash.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698