OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 2012, Google Inc. All rights reserved. | 2 * Copyright (c) 2012, 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 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
215 { | 215 { |
216 return value <= static_cast<unsigned>(std::numeric_limits<int>::max()) / kFixedPointDenominator; | 216 return value <= static_cast<unsigned>(std::numeric_limits<int>::max()) / kFixedPointDenominator; |
217 } | 217 } |
218 static bool isInBounds(double value) | 218 static bool isInBounds(double value) |
219 { | 219 { |
220 return ::fabs(value) <= std::numeric_limits<int>::max() / kFixedPointDen ominator; | 220 return ::fabs(value) <= std::numeric_limits<int>::max() / kFixedPointDen ominator; |
221 } | 221 } |
222 | 222 |
223 ALWAYS_INLINE void setValue(int value) | 223 ALWAYS_INLINE void setValue(int value) |
224 { | 224 { |
225 m_value = saturatedSet(value, kLayoutUnitFractionalBits); | 225 // The inner function needs to be implemented as a template to |
226 // maintain a common interface for both C++ and ARM versions. The first | |
227 // parameter specifies how many bits we saturate to (for ARM). | |
228 m_value = saturatedSetSigned< | |
229 32 - kLayoutUnitFractionalBits, | |
eseidel
2014/07/22 15:40:21
nit: We don't wrap to 80c in blink. I'd probably
| |
230 kLayoutUnitFractionalBits>(value); | |
226 } | 231 } |
227 | 232 |
228 inline void setValue(unsigned value) | 233 ALWAYS_INLINE void setValue(unsigned value) |
229 { | 234 { |
230 m_value = saturatedSet(value, kLayoutUnitFractionalBits); | 235 // The inner function needs to be implemented as a template to |
236 // maintain a common interface for both C++ and ARM versions. The first | |
237 // parameter specifies how many bits we saturate to (for ARM). This is | |
238 // one bit less than the signed version due to the ARM instructions for | |
239 // unsigned saturation. | |
240 m_value = saturatedSetUnsigned< | |
241 31 - kLayoutUnitFractionalBits, | |
242 kLayoutUnitFractionalBits>(value); | |
231 } | 243 } |
232 | 244 |
233 int m_value; | 245 int m_value; |
234 }; | 246 }; |
235 | 247 |
236 inline bool operator<=(const LayoutUnit& a, const LayoutUnit& b) | 248 inline bool operator<=(const LayoutUnit& a, const LayoutUnit& b) |
237 { | 249 { |
238 return a.rawValue() <= b.rawValue(); | 250 return a.rawValue() <= b.rawValue(); |
239 } | 251 } |
240 | 252 |
(...skipping 547 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
788 if (value >= max) | 800 if (value >= max) |
789 return max; | 801 return max; |
790 if (value <= min) | 802 if (value <= min) |
791 return min; | 803 return min; |
792 return value; | 804 return value; |
793 } | 805 } |
794 | 806 |
795 } // namespace WebCore | 807 } // namespace WebCore |
796 | 808 |
797 #endif // LayoutUnit_h | 809 #endif // LayoutUnit_h |
OLD | NEW |