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 12 matching lines...) Expand all Loading... |
23 #ifndef Length_h | 23 #ifndef Length_h |
24 #define Length_h | 24 #define Length_h |
25 | 25 |
26 #include "AnimationUtilities.h" | 26 #include "AnimationUtilities.h" |
27 #include <wtf/Assertions.h> | 27 #include <wtf/Assertions.h> |
28 #include <wtf/FastAllocBase.h> | 28 #include <wtf/FastAllocBase.h> |
29 #include <wtf/Forward.h> | 29 #include <wtf/Forward.h> |
30 #include <wtf/HashMap.h> | 30 #include <wtf/HashMap.h> |
31 #include <wtf/MathExtras.h> | 31 #include <wtf/MathExtras.h> |
32 #include <wtf/PassOwnArrayPtr.h> | 32 #include <wtf/PassOwnArrayPtr.h> |
| 33 #include <cstring> |
33 | 34 |
34 namespace WebCore { | 35 namespace WebCore { |
35 | 36 |
36 enum LengthType { | 37 enum LengthType { |
37 Auto, Relative, Percent, Fixed, | 38 Auto, Relative, Percent, Fixed, |
38 Intrinsic, MinIntrinsic, | 39 Intrinsic, MinIntrinsic, |
39 MinContent, MaxContent, FillAvailable, FitContent, | 40 MinContent, MaxContent, FillAvailable, FitContent, |
40 Calculated, | 41 Calculated, |
41 ViewportPercentageWidth, ViewportPercentageHeight, ViewportPercentageMin, Vi
ewportPercentageMax, | 42 ViewportPercentageWidth, ViewportPercentageHeight, ViewportPercentageMin, Vi
ewportPercentageMax, |
42 Undefined | 43 Undefined |
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
276 return getFloatValue(); | 277 return getFloatValue(); |
277 } | 278 } |
278 private: | 279 private: |
279 int getIntValue() const | 280 int getIntValue() const |
280 { | 281 { |
281 ASSERT(!isUndefined()); | 282 ASSERT(!isUndefined()); |
282 return m_isFloat ? static_cast<int>(m_floatValue) : m_intValue; | 283 return m_isFloat ? static_cast<int>(m_floatValue) : m_intValue; |
283 } | 284 } |
284 void initFromLength(const Length &length) | 285 void initFromLength(const Length &length) |
285 { | 286 { |
286 m_quirk = length.m_quirk; | 287 memcpy(this, &length, sizeof(Length)); |
287 m_type = length.m_type; | 288 |
288 m_isFloat = length.m_isFloat; | |
289 | |
290 if (m_isFloat) | |
291 m_floatValue = length.m_floatValue; | |
292 else | |
293 m_intValue = length.m_intValue; | |
294 | |
295 if (isCalculated()) | 289 if (isCalculated()) |
296 incrementCalculatedRef(); | 290 incrementCalculatedRef(); |
297 } | 291 } |
298 | 292 |
299 Length blendMixedTypes(const Length& from, double progress) const; | 293 Length blendMixedTypes(const Length& from, double progress) const; |
300 | 294 |
301 int calculationHandle() const | 295 int calculationHandle() const |
302 { | 296 { |
303 ASSERT(isCalculated()); | 297 ASSERT(isCalculated()); |
304 return getIntValue(); | 298 return getIntValue(); |
305 } | 299 } |
306 void incrementCalculatedRef() const; | 300 void incrementCalculatedRef() const; |
307 void decrementCalculatedRef() const; | 301 void decrementCalculatedRef() const; |
308 | 302 |
309 union { | 303 union { |
310 int m_intValue; | 304 int m_intValue; |
311 float m_floatValue; | 305 float m_floatValue; |
312 }; | 306 }; |
313 bool m_quirk; | 307 bool m_quirk; |
314 unsigned char m_type; | 308 unsigned char m_type; |
315 bool m_isFloat; | 309 bool m_isFloat; |
316 }; | 310 }; |
317 | 311 |
318 PassOwnArrayPtr<Length> newCoordsArray(const String&, int& len); | 312 PassOwnArrayPtr<Length> newCoordsArray(const String&, int& len); |
319 PassOwnArrayPtr<Length> newLengthArray(const String&, int& len); | 313 PassOwnArrayPtr<Length> newLengthArray(const String&, int& len); |
320 | 314 |
321 } // namespace WebCore | 315 } // namespace WebCore |
322 | 316 |
323 #endif // Length_h | 317 #endif // Length_h |
OLD | NEW |