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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 } | 81 } |
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: | |
92 case CSSPropertyWebkitColumnCount: | |
93 case CSSPropertyWidows: | |
94 return clampTo<double>(round(value), 1); | |
95 | |
96 case CSSPropertyStrokeMiterlimit: | 91 case CSSPropertyStrokeMiterlimit: |
97 return clampTo<double>(value, 1); | 92 return clampTo<float>(value, 1); |
98 | 93 |
99 case CSSPropertyFloodOpacity: | 94 case CSSPropertyFloodOpacity: |
100 case CSSPropertyStopOpacity: | 95 case CSSPropertyStopOpacity: |
101 case CSSPropertyStrokeOpacity: | 96 case CSSPropertyStrokeOpacity: |
102 case CSSPropertyShapeImageThreshold: | 97 case CSSPropertyShapeImageThreshold: |
103 return clampTo<double>(value, 0, 1); | 98 return clampTo<float>(value, 0, 1); |
104 | 99 |
105 case CSSPropertyFillOpacity: | 100 case CSSPropertyFillOpacity: |
106 case CSSPropertyOpacity: | 101 case CSSPropertyOpacity: |
107 return clampTo<double>(value, 0, nextafterf(1, 0)); | 102 return clampTo<float>(value, 0, nextafterf(1, 0)); |
108 | 103 |
109 case CSSPropertyFlexGrow: | 104 case CSSPropertyFlexGrow: |
110 case CSSPropertyFlexShrink: | 105 case CSSPropertyFlexShrink: |
111 case CSSPropertyFontSizeAdjust: | 106 case CSSPropertyFontSizeAdjust: |
112 case CSSPropertyLineHeight: | 107 case CSSPropertyLineHeight: |
113 return clampTo<double>(value, 0); | 108 return clampTo<float>(value, 0); |
| 109 |
| 110 case CSSPropertyOrphans: |
| 111 case CSSPropertyWidows: |
| 112 return clampTo<short>(round(value), 1); |
| 113 |
| 114 case CSSPropertyWebkitColumnCount: |
| 115 return clampTo<unsigned short>(round(value), 1); |
114 | 116 |
115 case CSSPropertyWebkitColumnRuleWidth: | 117 case CSSPropertyWebkitColumnRuleWidth: |
| 118 return clampTo<unsigned short>(round(value)); |
| 119 |
116 case CSSPropertyZIndex: | 120 case CSSPropertyZIndex: |
117 return round(value); | 121 return clampTo<int>(round(value)); |
118 | 122 |
119 default: | 123 default: |
120 ASSERT_NOT_REACHED(); | 124 ASSERT_NOT_REACHED(); |
121 return value; | 125 return value; |
122 } | 126 } |
123 } | 127 } |
124 | 128 |
125 bool NumberPropertyFunctions::setNumber(CSSPropertyID property, ComputedStyle& s
tyle, double value) | 129 bool NumberPropertyFunctions::setNumber(CSSPropertyID property, ComputedStyle& s
tyle, double value) |
126 { | 130 { |
127 ASSERT(value == clampNumber(property, value)); | 131 ASSERT(value == clampNumber(property, value)); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 return true; | 171 return true; |
168 case CSSPropertyZIndex: | 172 case CSSPropertyZIndex: |
169 style.setZIndex(value); | 173 style.setZIndex(value); |
170 return true; | 174 return true; |
171 default: | 175 default: |
172 return false; | 176 return false; |
173 } | 177 } |
174 } | 178 } |
175 | 179 |
176 } // namespace blink | 180 } // namespace blink |
OLD | NEW |