OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 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 24 matching lines...) Expand all Loading... |
35 #include "wtf/Allocator.h" | 35 #include "wtf/Allocator.h" |
36 | 36 |
37 namespace blink { | 37 namespace blink { |
38 | 38 |
39 enum GridTrackSizeType { | 39 enum GridTrackSizeType { |
40 LengthTrackSizing, | 40 LengthTrackSizing, |
41 MinMaxTrackSizing, | 41 MinMaxTrackSizing, |
42 FitContentTrackSizing | 42 FitContentTrackSizing |
43 }; | 43 }; |
44 | 44 |
45 // This class represents a <track-size> from the spec. Althought there are 3 dif
ferent types of | 45 // This class represents a <track-size> from the spec. Althought there are 3 |
46 // <track-size> there is always an equivalent minmax() representation that could
represent any of | 46 // different types of <track-size> there is always an equivalent minmax() |
47 // them. The only special case is fit-content(argument) which is similar to minm
ax(auto, | 47 // representation that could represent any of them. The only special case is |
48 // max-content) except that the track size is clamped at argument if it is great
er than the auto | 48 // fit-content(argument) which is similar to minmax(auto, max-content) except |
49 // minimum. At the GridTrackSize level we don't need to worry about clamping so
we treat that case | 49 // that the track size is clamped at argument if it is greater than the auto |
50 // exactly as auto. | 50 // minimum. At the GridTrackSize level we don't need to worry about clamping so |
| 51 // we treat that case exactly as auto. |
51 // | 52 // |
52 // We're using a separate attribute to store fit-content argument even though we
could directly use | 53 // We're using a separate attribute to store fit-content argument even though we |
53 // m_maxTrackBreadth. The reason why we don't do it is because the maxTrackBread
h() call is a hot | 54 // could directly use m_maxTrackBreadth. The reason why we don't do it is |
54 // spot, so adding a conditional statement there (to distinguish between fit-con
tent and any other | 55 // because the maxTrackBreadh() call is a hot spot, so adding a conditional |
55 // case) was causing a severe performance drop. | 56 // statement there (to distinguish between fit-content and any other case) was |
| 57 // causing a severe performance drop. |
56 class GridTrackSize { | 58 class GridTrackSize { |
57 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); | 59 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); |
58 | 60 |
59 public: | 61 public: |
60 GridTrackSize(const GridLength& length, | 62 GridTrackSize(const GridLength& length, |
61 GridTrackSizeType trackSizeType = LengthTrackSizing) | 63 GridTrackSizeType trackSizeType = LengthTrackSizing) |
62 : m_type(trackSizeType), | 64 : m_type(trackSizeType), |
63 m_minTrackBreadth(trackSizeType == FitContentTrackSizing ? Length(Auto) | 65 m_minTrackBreadth(trackSizeType == FitContentTrackSizing ? Length(Auto) |
64 : length), | 66 : length), |
65 m_maxTrackBreadth(trackSizeType == FitContentTrackSizing ? Length(Auto) | 67 m_maxTrackBreadth(trackSizeType == FitContentTrackSizing ? Length(Auto) |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 bool m_maxTrackBreadthIsAuto : 1; | 167 bool m_maxTrackBreadthIsAuto : 1; |
166 bool m_minTrackBreadthIsMaxContent : 1; | 168 bool m_minTrackBreadthIsMaxContent : 1; |
167 bool m_minTrackBreadthIsMinContent : 1; | 169 bool m_minTrackBreadthIsMinContent : 1; |
168 bool m_maxTrackBreadthIsMaxContent : 1; | 170 bool m_maxTrackBreadthIsMaxContent : 1; |
169 bool m_maxTrackBreadthIsMinContent : 1; | 171 bool m_maxTrackBreadthIsMinContent : 1; |
170 }; | 172 }; |
171 | 173 |
172 } // namespace blink | 174 } // namespace blink |
173 | 175 |
174 #endif // GridTrackSize_h | 176 #endif // GridTrackSize_h |
OLD | NEW |