| 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 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 return BorderImageLength(toAnimatableLength(value)->getLength( | 96 return BorderImageLength(toAnimatableLength(value)->getLength( |
| 97 state.style()->effectiveZoom(), ValueRangeNonNegative)); | 97 state.style()->effectiveZoom(), ValueRangeNonNegative)); |
| 98 if (value->isDouble()) | 98 if (value->isDouble()) |
| 99 return BorderImageLength( | 99 return BorderImageLength( |
| 100 clampTo<double>(toAnimatableDouble(value)->toDouble(), 0)); | 100 clampTo<double>(toAnimatableDouble(value)->toDouble(), 0)); |
| 101 ASSERT(toAnimatableUnknown(value)->toCSSValueID() == CSSValueAuto); | 101 ASSERT(toAnimatableUnknown(value)->toCSSValueID() == CSSValueAuto); |
| 102 return Length(Auto); | 102 return Length(Auto); |
| 103 } | 103 } |
| 104 | 104 |
| 105 template <typename T> | 105 template <typename T> |
| 106 T animatableValueClampTo(const AnimatableValue* value, | 106 T roundedClampTo(double value) { |
| 107 T min = defaultMinimumForClamp<T>(), | |
| 108 T max = defaultMaximumForClamp<T>()) { | |
| 109 static_assert(std::is_integral<T>::value, | 107 static_assert(std::is_integral<T>::value, |
| 110 "should use integral type T when rounding values"); | 108 "should use integral type T when rounding values"); |
| 111 return clampTo<T>( | 109 return clampTo<T>(roundForImpreciseConversion<T>(value)); |
| 112 roundForImpreciseConversion<T>(toAnimatableDouble(value)->toDouble()), | |
| 113 min, max); | |
| 114 } | 110 } |
| 115 | 111 |
| 116 template <typename T> | 112 template <typename T> |
| 113 T animatableValueClampTo(const AnimatableValue* value) { |
| 114 return roundedClampTo<T>(toAnimatableDouble(value)->toDouble()); |
| 115 } |
| 116 |
| 117 template <typename T> |
| 117 T animatableLineWidthClamp(const AnimatableValue* value) { | 118 T animatableLineWidthClamp(const AnimatableValue* value) { |
| 118 double doubleValue = toAnimatableDouble(value)->toDouble(); | 119 double doubleValue = toAnimatableDouble(value)->toDouble(); |
| 119 // This matches StyleBuilderConverter::convertLineWidth(). | 120 // This matches StyleBuilderConverter::convertLineWidth(). |
| 120 return (doubleValue > 0 && doubleValue < 1) | 121 return (doubleValue > 0 && doubleValue < 1) |
| 121 ? 1 | 122 ? 1 |
| 122 : animatableValueClampTo<T>(value); | 123 : animatableValueClampTo<T>(value); |
| 123 } | 124 } |
| 124 | 125 |
| 125 LengthBox animatableValueToLengthBox(const AnimatableValue* value, | 126 LengthBox animatableValueToLengthBox(const AnimatableValue* value, |
| 126 const StyleResolverState& state, | 127 const StyleResolverState& state, |
| (...skipping 705 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 832 style->setRy( | 833 style->setRy( |
| 833 animatableValueToLength(value, state, ValueRangeNonNegative)); | 834 animatableValueToLength(value, state, ValueRangeNonNegative)); |
| 834 return; | 835 return; |
| 835 | 836 |
| 836 default: | 837 default: |
| 837 ASSERT_NOT_REACHED(); | 838 ASSERT_NOT_REACHED(); |
| 838 } | 839 } |
| 839 } | 840 } |
| 840 | 841 |
| 841 } // namespace blink | 842 } // namespace blink |
| OLD | NEW |