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 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 | 119 |
120 bool operator==(const Length& o) const { | 120 bool operator==(const Length& o) const { |
121 return (type_ == o.type_) && (quirk_ == o.quirk_) && | 121 return (type_ == o.type_) && (quirk_ == o.quirk_) && |
122 (IsMaxSizeNone() || (GetFloatValue() == o.GetFloatValue()) || | 122 (IsMaxSizeNone() || (GetFloatValue() == o.GetFloatValue()) || |
123 IsCalculatedEqual(o)); | 123 IsCalculatedEqual(o)); |
124 } | 124 } |
125 bool operator!=(const Length& o) const { return !(*this == o); } | 125 bool operator!=(const Length& o) const { return !(*this == o); } |
126 | 126 |
127 const Length& operator*=(float v) { | 127 const Length& operator*=(float v) { |
128 if (IsCalculated()) { | 128 if (IsCalculated()) { |
129 ASSERT_NOT_REACHED(); | 129 NOTREACHED(); |
130 return *this; | 130 return *this; |
131 } | 131 } |
132 | 132 |
133 if (is_float_) | 133 if (is_float_) |
134 float_value_ = static_cast<float>(float_value_ * v); | 134 float_value_ = static_cast<float>(float_value_ * v); |
135 else | 135 else |
136 int_value_ = static_cast<int>(int_value_ * v); | 136 int_value_ = static_cast<int>(int_value_ * 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 | 141 // FIXME: Make this private (if possible) or at least rename it |
142 // (http://crbug.com/432707). | 142 // (http://crbug.com/432707). |
143 inline float Value() const { | 143 inline float Value() const { |
144 ASSERT(!IsCalculated()); | 144 ASSERT(!IsCalculated()); |
145 return GetFloatValue(); | 145 return GetFloatValue(); |
146 } | 146 } |
147 | 147 |
148 int IntValue() const { | 148 int IntValue() const { |
149 if (IsCalculated()) { | 149 if (IsCalculated()) { |
150 ASSERT_NOT_REACHED(); | 150 NOTREACHED(); |
151 return 0; | 151 return 0; |
152 } | 152 } |
153 return GetIntValue(); | 153 return GetIntValue(); |
154 } | 154 } |
155 | 155 |
156 float Pixels() const { | 156 float Pixels() const { |
157 ASSERT(GetType() == kFixed); | 157 ASSERT(GetType() == kFixed); |
158 return GetFloatValue(); | 158 return GetFloatValue(); |
159 } | 159 } |
160 | 160 |
(...skipping 12 matching lines...) Expand all Loading... |
173 void SetQuirk(bool quirk) { quirk_ = quirk; } | 173 void SetQuirk(bool quirk) { quirk_ = quirk; } |
174 | 174 |
175 void SetValue(LengthType t, int value) { | 175 void SetValue(LengthType t, int value) { |
176 type_ = t; | 176 type_ = t; |
177 int_value_ = value; | 177 int_value_ = value; |
178 is_float_ = false; | 178 is_float_ = false; |
179 } | 179 } |
180 | 180 |
181 void SetValue(int value) { | 181 void SetValue(int value) { |
182 if (IsCalculated()) { | 182 if (IsCalculated()) { |
183 ASSERT_NOT_REACHED(); | 183 NOTREACHED(); |
184 return; | 184 return; |
185 } | 185 } |
186 SetValue(kFixed, value); | 186 SetValue(kFixed, value); |
187 } | 187 } |
188 | 188 |
189 void SetValue(LengthType t, float value) { | 189 void SetValue(LengthType t, float value) { |
190 type_ = t; | 190 type_ = t; |
191 float_value_ = value; | 191 float_value_ = value; |
192 is_float_ = true; | 192 is_float_ = true; |
193 } | 193 } |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
309 float float_value_; | 309 float float_value_; |
310 }; | 310 }; |
311 bool quirk_; | 311 bool quirk_; |
312 unsigned char type_; | 312 unsigned char type_; |
313 bool is_float_; | 313 bool is_float_; |
314 }; | 314 }; |
315 | 315 |
316 } // namespace blink | 316 } // namespace blink |
317 | 317 |
318 #endif // Length_h | 318 #endif // Length_h |
OLD | NEW |