Chromium Code Reviews| 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 "config.h" | 5 #include "config.h" |
| 6 #include "core/animation/NumberPropertyFunctions.h" | 6 #include "core/animation/NumberPropertyFunctions.h" |
| 7 | 7 |
| 8 #include "core/style/ComputedStyle.h" | 8 #include "core/style/ComputedStyle.h" |
| 9 | 9 |
| 10 namespace blink { | 10 namespace blink { |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 82 | 82 |
| 83 default: | 83 default: |
| 84 return false; | 84 return false; |
| 85 } | 85 } |
| 86 } | 86 } |
| 87 | 87 |
| 88 double NumberPropertyFunctions::clampNumber(CSSPropertyID property, double value ) | 88 double NumberPropertyFunctions::clampNumber(CSSPropertyID property, double value ) |
| 89 { | 89 { |
| 90 switch (property) { | 90 switch (property) { |
| 91 case CSSPropertyOrphans: | 91 case CSSPropertyOrphans: |
| 92 case CSSPropertyWidows: | |
| 93 return clampTo<short>(round(value), 1); | |
| 94 | |
| 92 case CSSPropertyWebkitColumnCount: | 95 case CSSPropertyWebkitColumnCount: |
| 93 case CSSPropertyWidows: | 96 return clampTo<unsigned short>(round(value), 1); |
| 94 return clampTo<double>(round(value), 1); | |
| 95 | 97 |
| 96 case CSSPropertyStrokeMiterlimit: | 98 case CSSPropertyStrokeMiterlimit: |
| 97 return clampTo<double>(value, 1); | 99 return clampTo<float>(value, 1); |
| 98 | 100 |
| 99 case CSSPropertyFloodOpacity: | 101 case CSSPropertyFloodOpacity: |
| 100 case CSSPropertyStopOpacity: | 102 case CSSPropertyStopOpacity: |
| 101 case CSSPropertyStrokeOpacity: | 103 case CSSPropertyStrokeOpacity: |
| 102 case CSSPropertyShapeImageThreshold: | 104 case CSSPropertyShapeImageThreshold: |
| 103 return clampTo<double>(value, 0, 1); | 105 return clampTo<float>(value, 0, 1); |
| 104 | 106 |
| 105 case CSSPropertyFillOpacity: | 107 case CSSPropertyFillOpacity: |
| 106 case CSSPropertyOpacity: | 108 case CSSPropertyOpacity: |
| 107 return clampTo<double>(value, 0, nextafterf(1, 0)); | 109 return clampTo<float>(value, 0, nextafterf(1, 0)); |
| 108 | 110 |
| 109 case CSSPropertyFlexGrow: | 111 case CSSPropertyFlexGrow: |
| 110 case CSSPropertyFlexShrink: | 112 case CSSPropertyFlexShrink: |
| 111 case CSSPropertyFontSizeAdjust: | 113 case CSSPropertyFontSizeAdjust: |
| 112 case CSSPropertyLineHeight: | 114 case CSSPropertyLineHeight: |
| 113 return clampTo<double>(value, 0); | 115 return clampTo<float>(value, 0); |
| 114 | 116 |
| 115 case CSSPropertyWebkitColumnRuleWidth: | 117 case CSSPropertyWebkitColumnRuleWidth: |
|
Eric Willigers
2015/11/18 00:18:54
AnimatedStyleBuilder::applyProperty and ComputedSt
alancutter (OOO until 2018)
2015/11/18 00:33:28
Updated, also fixed AnimatedStyleBuilder calls to
| |
| 116 case CSSPropertyZIndex: | 118 case CSSPropertyZIndex: |
| 117 return round(value); | 119 return clampTo<int>(round(value)); |
| 118 | 120 |
| 119 default: | 121 default: |
| 120 ASSERT_NOT_REACHED(); | 122 ASSERT_NOT_REACHED(); |
| 121 return value; | 123 return value; |
| 122 } | 124 } |
| 123 } | 125 } |
| 124 | 126 |
| 125 bool NumberPropertyFunctions::setNumber(CSSPropertyID property, ComputedStyle& s tyle, double value) | 127 bool NumberPropertyFunctions::setNumber(CSSPropertyID property, ComputedStyle& s tyle, double value) |
| 126 { | 128 { |
| 127 ASSERT(value == clampNumber(property, value)); | 129 ASSERT(value == clampNumber(property, value)); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 167 return true; | 169 return true; |
| 168 case CSSPropertyZIndex: | 170 case CSSPropertyZIndex: |
| 169 style.setZIndex(value); | 171 style.setZIndex(value); |
| 170 return true; | 172 return true; |
| 171 default: | 173 default: |
| 172 return false; | 174 return false; |
| 173 } | 175 } |
| 174 } | 176 } |
| 175 | 177 |
| 176 } // namespace blink | 178 } // namespace blink |
| OLD | NEW |