| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 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 18 matching lines...) Expand all Loading... |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 #ifndef GridLength_h | 31 #ifndef GridLength_h |
| 32 #define GridLength_h | 32 #define GridLength_h |
| 33 | 33 |
| 34 #include "platform/Length.h" | 34 #include "platform/Length.h" |
| 35 #include "wtf/Allocator.h" | 35 #include "wtf/Allocator.h" |
| 36 | 36 |
| 37 namespace blink { | 37 namespace blink { |
| 38 | 38 |
| 39 // This class wraps the <track-breadth> which can be either a <percentage>, <len
gth>, min-content, max-content | 39 // This class wraps the <track-breadth> which can be either a <percentage>, |
| 40 // or <flex>. This class avoids spreading the knowledge of <flex> throughout the
layout directory by adding | 40 // <length>, min-content, max-content or <flex>. This class avoids spreading the |
| 41 // an new unit to Length.h. | 41 // knowledge of <flex> throughout the layout directory by adding an new unit to |
| 42 // Length.h. |
| 42 class GridLength { | 43 class GridLength { |
| 43 DISALLOW_NEW(); | 44 DISALLOW_NEW(); |
| 44 | 45 |
| 45 public: | 46 public: |
| 46 GridLength(const Length& length) | 47 GridLength(const Length& length) |
| 47 : m_length(length), m_flex(0), m_type(LengthType) {} | 48 : m_length(length), m_flex(0), m_type(LengthType) {} |
| 48 | 49 |
| 49 explicit GridLength(double flex) : m_flex(flex), m_type(FlexType) {} | 50 explicit GridLength(double flex) : m_flex(flex), m_type(FlexType) {} |
| 50 | 51 |
| 51 bool isLength() const { return m_type == LengthType; } | 52 bool isLength() const { return m_type == LengthType; } |
| (...skipping 17 matching lines...) Expand all Loading... |
| 69 return m_length == o.m_length && m_flex == o.m_flex && m_type == o.m_type; | 70 return m_length == o.m_length && m_flex == o.m_flex && m_type == o.m_type; |
| 70 } | 71 } |
| 71 | 72 |
| 72 bool isContentSized() const { | 73 bool isContentSized() const { |
| 73 return m_type == LengthType && | 74 return m_type == LengthType && |
| 74 (m_length.isAuto() || m_length.isMinContent() || | 75 (m_length.isAuto() || m_length.isMinContent() || |
| 75 m_length.isMaxContent()); | 76 m_length.isMaxContent()); |
| 76 } | 77 } |
| 77 | 78 |
| 78 private: | 79 private: |
| 79 // Ideally we would put the 2 following fields in a union, but Length has a co
nstructor, | 80 // Ideally we would put the 2 following fields in a union, but Length has a |
| 80 // a destructor and a copy assignment which isn't allowed. | 81 // constructor, a destructor and a copy assignment which isn't allowed. |
| 81 Length m_length; | 82 Length m_length; |
| 82 double m_flex; | 83 double m_flex; |
| 83 enum GridLengthType { LengthType, FlexType }; | 84 enum GridLengthType { LengthType, FlexType }; |
| 84 GridLengthType m_type; | 85 GridLengthType m_type; |
| 85 }; | 86 }; |
| 86 | 87 |
| 87 } // namespace blink | 88 } // namespace blink |
| 88 | 89 |
| 89 #endif // GridLength_h | 90 #endif // GridLength_h |
| OLD | NEW |