OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
89 if (value->isLength()) | 89 if (value->isLength()) |
90 return BorderImageLength(toAnimatableLength(value)->length(state.style() ->effectiveZoom(), ValueRangeNonNegative)); | 90 return BorderImageLength(toAnimatableLength(value)->length(state.style() ->effectiveZoom(), ValueRangeNonNegative)); |
91 if (value->isDouble()) | 91 if (value->isDouble()) |
92 return BorderImageLength(clampTo<double>(toAnimatableDouble(value)->toDo uble(), 0)); | 92 return BorderImageLength(clampTo<double>(toAnimatableDouble(value)->toDo uble(), 0)); |
93 ASSERT(toAnimatableUnknown(value)->toCSSValueID() == CSSValueAuto); | 93 ASSERT(toAnimatableUnknown(value)->toCSSValueID() == CSSValueAuto); |
94 return Length(Auto); | 94 return Length(Auto); |
95 } | 95 } |
96 | 96 |
97 template<typename T> T animatableValueClampTo(const AnimatableValue* value, T mi n = defaultMinimumForClamp<T>(), T max = defaultMaximumForClamp<T>()) | 97 template<typename T> T animatableValueClampTo(const AnimatableValue* value, T mi n = defaultMinimumForClamp<T>(), T max = defaultMaximumForClamp<T>()) |
98 { | 98 { |
99 static_assert(std::is_integral<T>::value, "should use integral type T when r ounding values"); | |
100 return clampTo<T>(roundForImpreciseConversion<T>(toAnimatableDouble(value)-> toDouble()), min, max); | 99 return clampTo<T>(roundForImpreciseConversion<T>(toAnimatableDouble(value)-> toDouble()), min, max); |
101 } | 100 } |
102 | 101 |
103 template<typename T> T animatableLineWidthClamp(const AnimatableValue* value) | 102 template<typename T> T animatableLineWidthClamp(const AnimatableValue* value, T min = defaultMinimumForClamp<T>(), T max = defaultMaximumForClamp<T>()) |
alancutter (OOO until 2018)
2016/01/20 06:06:23
No need for min/max parameters. Line widths are al
| |
104 { | 103 { |
105 double doubleValue = toAnimatableDouble(value)->toDouble(); | 104 double doubleValue = toAnimatableDouble(value)->toDouble(); |
106 // This matches StyleBuilderConverter::convertLineWidth(). | 105 // This matches StyleBuilderConverter::convertLineWidth(). |
107 return (doubleValue > 0 && doubleValue < 1) ? 1 : animatableValueClampTo<T>( value); | 106 return (doubleValue > 0 && doubleValue < 1) ? 1 : animatableValueClampTo<T>( value, min, max); |
108 } | 107 } |
109 | 108 |
110 LengthBox animatableValueToLengthBox(const AnimatableValue* value, const StyleRe solverState& state, ValueRange range = ValueRangeAll) | 109 LengthBox animatableValueToLengthBox(const AnimatableValue* value, const StyleRe solverState& state, ValueRange range = ValueRangeAll) |
111 { | 110 { |
112 const AnimatableLengthBox* animatableLengthBox = toAnimatableLengthBox(value ); | 111 const AnimatableLengthBox* animatableLengthBox = toAnimatableLengthBox(value ); |
113 return LengthBox( | 112 return LengthBox( |
114 animatableValueToLength(animatableLengthBox->top(), state, range), | 113 animatableValueToLength(animatableLengthBox->top(), state, range), |
115 animatableValueToLength(animatableLengthBox->right(), state, range), | 114 animatableValueToLength(animatableLengthBox->right(), state, range), |
116 animatableValueToLength(animatableLengthBox->bottom(), state, range), | 115 animatableValueToLength(animatableLengthBox->bottom(), state, range), |
117 animatableValueToLength(animatableLengthBox->left(), state, range)); | 116 animatableValueToLength(animatableLengthBox->left(), state, range)); |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
316 style->setBorderBottomColor(toAnimatableColor(value)->color()); | 315 style->setBorderBottomColor(toAnimatableColor(value)->color()); |
317 style->setVisitedLinkBorderBottomColor(toAnimatableColor(value)->visited LinkColor()); | 316 style->setVisitedLinkBorderBottomColor(toAnimatableColor(value)->visited LinkColor()); |
318 return; | 317 return; |
319 case CSSPropertyBorderBottomLeftRadius: | 318 case CSSPropertyBorderBottomLeftRadius: |
320 style->setBorderBottomLeftRadius(animatableValueToLengthSize(value, stat e, ValueRangeNonNegative)); | 319 style->setBorderBottomLeftRadius(animatableValueToLengthSize(value, stat e, ValueRangeNonNegative)); |
321 return; | 320 return; |
322 case CSSPropertyBorderBottomRightRadius: | 321 case CSSPropertyBorderBottomRightRadius: |
323 style->setBorderBottomRightRadius(animatableValueToLengthSize(value, sta te, ValueRangeNonNegative)); | 322 style->setBorderBottomRightRadius(animatableValueToLengthSize(value, sta te, ValueRangeNonNegative)); |
324 return; | 323 return; |
325 case CSSPropertyBorderBottomWidth: | 324 case CSSPropertyBorderBottomWidth: |
326 style->setBorderBottomWidth(animatableLineWidthClamp<unsigned>(value)); | 325 style->setBorderBottomWidth(animatableLineWidthClamp<float>(value, 0)); |
327 return; | 326 return; |
328 case CSSPropertyBorderImageOutset: | 327 case CSSPropertyBorderImageOutset: |
329 style->setBorderImageOutset(animatableValueToBorderImageLengthBox(value, state)); | 328 style->setBorderImageOutset(animatableValueToBorderImageLengthBox(value, state)); |
330 return; | 329 return; |
331 case CSSPropertyBorderImageSlice: | 330 case CSSPropertyBorderImageSlice: |
332 style->setBorderImageSlices(animatableValueToLengthBox(toAnimatableLengt hBoxAndBool(value)->box(), state, ValueRangeNonNegative)); | 331 style->setBorderImageSlices(animatableValueToLengthBox(toAnimatableLengt hBoxAndBool(value)->box(), state, ValueRangeNonNegative)); |
333 style->setBorderImageSlicesFill(toAnimatableLengthBoxAndBool(value)->fla g()); | 332 style->setBorderImageSlicesFill(toAnimatableLengthBoxAndBool(value)->fla g()); |
334 return; | 333 return; |
335 case CSSPropertyBorderImageSource: | 334 case CSSPropertyBorderImageSource: |
336 style->setBorderImageSource(state.styleImage(property, *toAnimatableImag e(value)->toCSSValue())); | 335 style->setBorderImageSource(state.styleImage(property, *toAnimatableImag e(value)->toCSSValue())); |
337 return; | 336 return; |
338 case CSSPropertyBorderImageWidth: | 337 case CSSPropertyBorderImageWidth: |
339 style->setBorderImageWidth(animatableValueToBorderImageLengthBox(value, state)); | 338 style->setBorderImageWidth(animatableValueToBorderImageLengthBox(value, state)); |
340 return; | 339 return; |
341 case CSSPropertyBorderLeftColor: | 340 case CSSPropertyBorderLeftColor: |
342 style->setBorderLeftColor(toAnimatableColor(value)->color()); | 341 style->setBorderLeftColor(toAnimatableColor(value)->color()); |
343 style->setVisitedLinkBorderLeftColor(toAnimatableColor(value)->visitedLi nkColor()); | 342 style->setVisitedLinkBorderLeftColor(toAnimatableColor(value)->visitedLi nkColor()); |
344 return; | 343 return; |
345 case CSSPropertyBorderLeftWidth: | 344 case CSSPropertyBorderLeftWidth: |
346 style->setBorderLeftWidth(animatableLineWidthClamp<unsigned>(value)); | 345 style->setBorderLeftWidth(animatableLineWidthClamp<float>(value, 0)); |
347 return; | 346 return; |
348 case CSSPropertyBorderRightColor: | 347 case CSSPropertyBorderRightColor: |
349 style->setBorderRightColor(toAnimatableColor(value)->color()); | 348 style->setBorderRightColor(toAnimatableColor(value)->color()); |
350 style->setVisitedLinkBorderRightColor(toAnimatableColor(value)->visitedL inkColor()); | 349 style->setVisitedLinkBorderRightColor(toAnimatableColor(value)->visitedL inkColor()); |
351 return; | 350 return; |
352 case CSSPropertyBorderRightWidth: | 351 case CSSPropertyBorderRightWidth: |
353 style->setBorderRightWidth(animatableLineWidthClamp<unsigned>(value)); | 352 style->setBorderRightWidth(animatableLineWidthClamp<float>(value, 0)); |
354 return; | 353 return; |
355 case CSSPropertyBorderTopColor: | 354 case CSSPropertyBorderTopColor: |
356 style->setBorderTopColor(toAnimatableColor(value)->color()); | 355 style->setBorderTopColor(toAnimatableColor(value)->color()); |
357 style->setVisitedLinkBorderTopColor(toAnimatableColor(value)->visitedLin kColor()); | 356 style->setVisitedLinkBorderTopColor(toAnimatableColor(value)->visitedLin kColor()); |
358 return; | 357 return; |
359 case CSSPropertyBorderTopLeftRadius: | 358 case CSSPropertyBorderTopLeftRadius: |
360 style->setBorderTopLeftRadius(animatableValueToLengthSize(value, state, ValueRangeNonNegative)); | 359 style->setBorderTopLeftRadius(animatableValueToLengthSize(value, state, ValueRangeNonNegative)); |
361 return; | 360 return; |
362 case CSSPropertyBorderTopRightRadius: | 361 case CSSPropertyBorderTopRightRadius: |
363 style->setBorderTopRightRadius(animatableValueToLengthSize(value, state, ValueRangeNonNegative)); | 362 style->setBorderTopRightRadius(animatableValueToLengthSize(value, state, ValueRangeNonNegative)); |
364 return; | 363 return; |
365 case CSSPropertyBorderTopWidth: | 364 case CSSPropertyBorderTopWidth: |
366 style->setBorderTopWidth(animatableLineWidthClamp<unsigned>(value)); | 365 style->setBorderTopWidth(animatableLineWidthClamp<float>(value, 0)); |
367 return; | 366 return; |
368 case CSSPropertyBottom: | 367 case CSSPropertyBottom: |
369 style->setBottom(animatableValueToLength(value, state)); | 368 style->setBottom(animatableValueToLength(value, state)); |
370 return; | 369 return; |
371 case CSSPropertyBoxShadow: | 370 case CSSPropertyBoxShadow: |
372 style->setBoxShadow(toAnimatableShadow(value)->shadowList()); | 371 style->setBoxShadow(toAnimatableShadow(value)->shadowList()); |
373 return; | 372 return; |
374 case CSSPropertyClip: | 373 case CSSPropertyClip: |
375 style->setClip(animatableValueToLengthBox(value, state)); | 374 style->setClip(animatableValueToLengthBox(value, state)); |
376 return; | 375 return; |
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
705 case CSSPropertyRy: | 704 case CSSPropertyRy: |
706 style->setRy(animatableValueToLength(value, state, ValueRangeNonNegative )); | 705 style->setRy(animatableValueToLength(value, state, ValueRangeNonNegative )); |
707 return; | 706 return; |
708 | 707 |
709 default: | 708 default: |
710 ASSERT_NOT_REACHED(); | 709 ASSERT_NOT_REACHED(); |
711 } | 710 } |
712 } | 711 } |
713 | 712 |
714 } // namespace blink | 713 } // namespace blink |
OLD | NEW |