| OLD | NEW |
| 1 /* | 1 /* |
| 2 Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
| 3 Copyright (C) 2006, 2008 Apple Inc. All rights reserved. | 3 Copyright (C) 2006, 2008 Apple Inc. All rights reserved. |
| 4 Copyright (C) 2011 Rik Cabanier (cabanier@adobe.com) | 4 Copyright (C) 2011 Rik Cabanier (cabanier@adobe.com) |
| 5 Copyright (C) 2011 Adobe Systems Incorporated. All rights reserved. | 5 Copyright (C) 2011 Adobe Systems Incorporated. All rights reserved. |
| 6 | 6 |
| 7 This library is free software; you can redistribute it and/or | 7 This library is free software; you can redistribute it and/or |
| 8 modify it under the terms of the GNU Library General Public | 8 modify it under the terms of the GNU Library General Public |
| 9 License as published by the Free Software Foundation; either | 9 License as published by the Free Software Foundation; either |
| 10 version 2 of the License, or (at your option) any later version. | 10 version 2 of the License, or (at your option) any later version. |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 } | 131 } |
| 132 | 132 |
| 133 if (m_isFloat) | 133 if (m_isFloat) |
| 134 m_floatValue = static_cast<float>(m_floatValue * v); | 134 m_floatValue = static_cast<float>(m_floatValue * v); |
| 135 else | 135 else |
| 136 m_intValue = static_cast<int>(m_intValue * v); | 136 m_intValue = static_cast<int>(m_intValue * v); |
| 137 | 137 |
| 138 return *this; | 138 return *this; |
| 139 } | 139 } |
| 140 | 140 |
| 141 // FIXME: Make this private (if possible) or at least rename it (http://crbug.
com/432707). | 141 // FIXME: Make this private (if possible) or at least rename it |
| 142 // (http://crbug.com/432707). |
| 142 inline float value() const { | 143 inline float value() const { |
| 143 ASSERT(!isCalculated()); | 144 ASSERT(!isCalculated()); |
| 144 return getFloatValue(); | 145 return getFloatValue(); |
| 145 } | 146 } |
| 146 | 147 |
| 147 int intValue() const { | 148 int intValue() const { |
| 148 if (isCalculated()) { | 149 if (isCalculated()) { |
| 149 ASSERT_NOT_REACHED(); | 150 ASSERT_NOT_REACHED(); |
| 150 return 0; | 151 return 0; |
| 151 } | 152 } |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 194 void setValue(LengthType t, LayoutUnit value) { | 195 void setValue(LengthType t, LayoutUnit value) { |
| 195 m_type = t; | 196 m_type = t; |
| 196 m_floatValue = value.toFloat(); | 197 m_floatValue = value.toFloat(); |
| 197 m_isFloat = true; | 198 m_isFloat = true; |
| 198 } | 199 } |
| 199 | 200 |
| 200 void setValue(float value) { *this = Length(value, Fixed); } | 201 void setValue(float value) { *this = Length(value, Fixed); } |
| 201 | 202 |
| 202 bool isMaxSizeNone() const { return type() == MaxSizeNone; } | 203 bool isMaxSizeNone() const { return type() == MaxSizeNone; } |
| 203 | 204 |
| 204 // FIXME calc: https://bugs.webkit.org/show_bug.cgi?id=80357. A calculated Len
gth | 205 // FIXME calc: https://bugs.webkit.org/show_bug.cgi?id=80357. A calculated |
| 205 // always contains a percentage, and without a maxValue passed to these functi
ons | 206 // Length always contains a percentage, and without a maxValue passed to these |
| 206 // it's impossible to determine the sign or zero-ness. We assume all calc valu
es | 207 // functions it's impossible to determine the sign or zero-ness. We assume all |
| 207 // are positive and non-zero for now. | 208 // calc values are positive and non-zero for now. |
| 208 bool isZero() const { | 209 bool isZero() const { |
| 209 ASSERT(!isMaxSizeNone()); | 210 ASSERT(!isMaxSizeNone()); |
| 210 if (isCalculated()) | 211 if (isCalculated()) |
| 211 return false; | 212 return false; |
| 212 | 213 |
| 213 return m_isFloat ? !m_floatValue : !m_intValue; | 214 return m_isFloat ? !m_floatValue : !m_intValue; |
| 214 } | 215 } |
| 215 bool isPositive() const { | 216 bool isPositive() const { |
| 216 if (isMaxSizeNone()) | 217 if (isMaxSizeNone()) |
| 217 return false; | 218 return false; |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 307 float m_floatValue; | 308 float m_floatValue; |
| 308 }; | 309 }; |
| 309 bool m_quirk; | 310 bool m_quirk; |
| 310 unsigned char m_type; | 311 unsigned char m_type; |
| 311 bool m_isFloat; | 312 bool m_isFloat; |
| 312 }; | 313 }; |
| 313 | 314 |
| 314 } // namespace blink | 315 } // namespace blink |
| 315 | 316 |
| 316 #endif // Length_h | 317 #endif // Length_h |
| OLD | NEW |