| 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 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 213 } | 213 } |
| 214 static bool isInBounds(unsigned value) | 214 static bool isInBounds(unsigned value) |
| 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 inline void setValue(int value) |
| 224 { | 224 { |
| 225 m_value = saturatedSet(value, kLayoutUnitFractionalBits); | 225 if (value > intMaxForLayoutUnit) |
| 226 m_value = std::numeric_limits<int>::max(); |
| 227 else if (value < intMinForLayoutUnit) |
| 228 m_value = std::numeric_limits<int>::min(); |
| 229 else |
| 230 m_value = value * kFixedPointDenominator; |
| 226 } | 231 } |
| 227 | |
| 228 inline void setValue(unsigned value) | 232 inline void setValue(unsigned value) |
| 229 { | 233 { |
| 230 m_value = saturatedSet(value, kLayoutUnitFractionalBits); | 234 if (value >= static_cast<unsigned>(intMaxForLayoutUnit)) |
| 235 m_value = std::numeric_limits<int>::max(); |
| 236 else |
| 237 m_value = value * kFixedPointDenominator; |
| 231 } | 238 } |
| 232 | 239 |
| 233 int m_value; | 240 int m_value; |
| 234 }; | 241 }; |
| 235 | 242 |
| 236 inline bool operator<=(const LayoutUnit& a, const LayoutUnit& b) | 243 inline bool operator<=(const LayoutUnit& a, const LayoutUnit& b) |
| 237 { | 244 { |
| 238 return a.rawValue() <= b.rawValue(); | 245 return a.rawValue() <= b.rawValue(); |
| 239 } | 246 } |
| 240 | 247 |
| (...skipping 547 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 788 if (value >= max) | 795 if (value >= max) |
| 789 return max; | 796 return max; |
| 790 if (value <= min) | 797 if (value <= min) |
| 791 return min; | 798 return min; |
| 792 return value; | 799 return value; |
| 793 } | 800 } |
| 794 | 801 |
| 795 } // namespace WebCore | 802 } // namespace WebCore |
| 796 | 803 |
| 797 #endif // LayoutUnit_h | 804 #endif // LayoutUnit_h |
| OLD | NEW |