Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (c) 2013, Opera Software ASA. All rights reserved. | 2 * Copyright (c) 2013, Opera Software ASA. 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 19 matching lines...) Expand all Loading... | |
| 30 | 30 |
| 31 #ifndef BorderImageLength_h | 31 #ifndef BorderImageLength_h |
| 32 #define BorderImageLength_h | 32 #define BorderImageLength_h |
| 33 | 33 |
| 34 #include "platform/Length.h" | 34 #include "platform/Length.h" |
| 35 | 35 |
| 36 namespace WebCore { | 36 namespace WebCore { |
| 37 | 37 |
| 38 class PLATFORM_EXPORT BorderImageLength { | 38 class PLATFORM_EXPORT BorderImageLength { |
| 39 public: | 39 public: |
| 40 // Default is 'auto' | |
|
Julien - ping for review
2013/11/04 18:30:25
Default _Length_ is 'auto' if that changed, this w
| |
| 40 BorderImageLength() | 41 BorderImageLength() |
| 42 : m_number(0) | |
| 43 , m_type(LengthType) | |
| 41 { | 44 { |
| 42 } | 45 } |
| 43 | 46 |
| 44 BorderImageLength(double number) | 47 BorderImageLength(double number) |
| 45 : m_length(number, Relative) | 48 : m_length(Undefined) |
| 49 , m_number(number) | |
| 50 , m_type(NumberType) | |
| 46 { | 51 { |
| 47 } | 52 } |
| 48 | 53 |
| 49 BorderImageLength(const Length& length) | 54 BorderImageLength(const Length& length) |
| 50 : m_length(length) | 55 : m_length(length) |
| 56 , m_number(0) | |
| 57 , m_type(LengthType) | |
| 51 { | 58 { |
| 52 } | 59 } |
| 53 | 60 |
| 54 bool isNumber() const { return m_length.isRelative(); } | 61 bool isNumber() const { return m_type == NumberType; } |
| 55 bool isLength() const { return !isNumber(); } | 62 bool isLength() const { return m_type == LengthType; } |
| 56 | 63 |
| 57 const Length& length() const { ASSERT(isLength()); return m_length; } | 64 const Length& length() const { ASSERT(isLength()); return m_length; } |
| 58 Length& length() { ASSERT(isLength()); return m_length; } | 65 Length& length() { ASSERT(isLength()); return m_length; } |
| 59 | 66 |
| 60 double number() const { ASSERT(isNumber()); return m_length.value(); } | 67 double number() const { ASSERT(isNumber()); return m_number; } |
| 61 | 68 |
| 62 bool operator==(const BorderImageLength& o) const | 69 bool operator==(const BorderImageLength& o) const |
| 63 { | 70 { |
| 64 return m_length == o.m_length; | 71 return m_length == o.m_length && m_number == o.m_number && m_type == o.m _type; |
|
Julien - ping for review
2013/11/04 18:30:25
Nit: Let's put m_type first. And |o| -> |other| ^_
| |
| 65 } | 72 } |
| 66 | 73 |
| 67 bool isZero() const | 74 bool isZero() const |
| 68 { | 75 { |
| 69 return m_length.isZero(); | 76 return (isLength() && m_length.isZero()) || (isNumber() && m_number); |
| 70 } | 77 } |
| 71 | 78 |
| 72 private: | 79 private: |
| 80 // Ideally we would put the 2 following fields in a union, but Length has a constructor, | |
| 81 // a destructor and a copy assignment which isn't allowed. | |
| 73 Length m_length; | 82 Length m_length; |
| 83 double m_number; | |
| 84 enum { | |
| 85 LengthType, | |
| 86 NumberType | |
| 87 } m_type; | |
| 74 }; | 88 }; |
| 75 | 89 |
| 76 } // namespace WebCore | 90 } // namespace WebCore |
| 77 | 91 |
| 78 #endif // BorderImageLength_h | 92 #endif // BorderImageLength_h |
| OLD | NEW |