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 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 return *this; | 117 return *this; |
118 } | 118 } |
119 | 119 |
120 inline int rawValue() const { return m_value; } | 120 inline int rawValue() const { return m_value; } |
121 inline void setRawValue(int value) { m_value = value; } | 121 inline void setRawValue(int value) { m_value = value; } |
122 void setRawValue(long long value) | 122 void setRawValue(long long value) |
123 { | 123 { |
124 REPORT_OVERFLOW(value > std::numeric_limits<int>::min() && value < std::
numeric_limits<int>::max()); | 124 REPORT_OVERFLOW(value > std::numeric_limits<int>::min() && value < std::
numeric_limits<int>::max()); |
125 m_value = static_cast<int>(value); | 125 m_value = static_cast<int>(value); |
126 } | 126 } |
| 127 static LayoutUnit fromRawValue(int value) |
| 128 { |
| 129 LayoutUnit v; |
| 130 v.setRawValue(value); |
| 131 return v; |
| 132 } |
127 | 133 |
128 LayoutUnit abs() const | 134 LayoutUnit abs() const |
129 { | 135 { |
130 LayoutUnit returnValue; | 136 LayoutUnit returnValue; |
131 returnValue.setRawValue(::abs(m_value)); | 137 returnValue.setRawValue(::abs(m_value)); |
132 return returnValue; | 138 return returnValue; |
133 } | 139 } |
134 int ceil() const | 140 int ceil() const |
135 { | 141 { |
136 if (UNLIKELY(m_value >= INT_MAX - kFixedPointDenominator + 1)) | 142 if (UNLIKELY(m_value >= INT_MAX - kFixedPointDenominator + 1)) |
(...skipping 670 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
807 } | 813 } |
808 | 814 |
809 inline std::ostream& operator<<(std::ostream& stream, const LayoutUnit& value) | 815 inline std::ostream& operator<<(std::ostream& stream, const LayoutUnit& value) |
810 { | 816 { |
811 return stream << value.toDouble(); | 817 return stream << value.toDouble(); |
812 } | 818 } |
813 | 819 |
814 } // namespace blink | 820 } // namespace blink |
815 | 821 |
816 #endif // LayoutUnit_h | 822 #endif // LayoutUnit_h |
OLD | NEW |