| 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 | 35 |
| 36 namespace WebCore { | 36 namespace WebCore { |
| 37 | 37 |
| 38 enum GridPositionType { | 38 enum GridPositionType { |
| 39 AutoPosition, | 39 AutoPosition, |
| 40 ExplicitPosition, // [ <integer> || <string> ] | 40 ExplicitPosition, // [ <integer> || <string> ] |
| 41 SpanPosition, // span && [ <integer> || <string> ] | 41 SpanPosition, // span && [ <integer> || <string> ] |
| 42 NamedGridAreaPosition // <ident> | 42 NamedGridAreaPosition // <ident> |
| 43 }; | 43 }; |
| 44 | 44 |
| 45 enum GridPositionSide { | |
| 46 ColumnStartSide, | |
| 47 ColumnEndSide, | |
| 48 RowStartSide, | |
| 49 RowEndSide | |
| 50 }; | |
| 51 | |
| 52 class GridPosition { | 45 class GridPosition { |
| 53 public: | 46 public: |
| 54 GridPosition() | 47 GridPosition() |
| 55 : m_type(AutoPosition) | 48 : m_type(AutoPosition) |
| 56 , m_integerPosition(0) | 49 , m_integerPosition(0) |
| 57 { | 50 { |
| 58 } | 51 } |
| 59 | 52 |
| 60 static size_t adjustGridPositionForAfterEndSide(size_t resolvedPosition) | |
| 61 { | |
| 62 return resolvedPosition ? resolvedPosition - 1 : 0; | |
| 63 } | |
| 64 | |
| 65 static size_t adjustGridPositionForSide(size_t resolvedPosition, GridPositio
nSide side) | |
| 66 { | |
| 67 // An item finishing on the N-th line belongs to the N-1-th cell. | |
| 68 if (side == ColumnEndSide || side == RowEndSide) | |
| 69 return adjustGridPositionForAfterEndSide(resolvedPosition); | |
| 70 | |
| 71 return resolvedPosition; | |
| 72 } | |
| 73 | |
| 74 bool isPositive() const { return integerPosition() > 0; } | 53 bool isPositive() const { return integerPosition() > 0; } |
| 75 | 54 |
| 76 GridPositionType type() const { return m_type; } | 55 GridPositionType type() const { return m_type; } |
| 77 bool isAuto() const { return m_type == AutoPosition; } | 56 bool isAuto() const { return m_type == AutoPosition; } |
| 78 bool isSpan() const { return m_type == SpanPosition; } | 57 bool isSpan() const { return m_type == SpanPosition; } |
| 79 bool isNamedGridArea() const { return m_type == NamedGridAreaPosition; } | 58 bool isNamedGridArea() const { return m_type == NamedGridAreaPosition; } |
| 80 | 59 |
| 81 void setExplicitPosition(int position, const String& namedGridLine) | 60 void setExplicitPosition(int position, const String& namedGridLine) |
| 82 { | 61 { |
| 83 m_type = ExplicitPosition; | 62 m_type = ExplicitPosition; |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 } | 109 } |
| 131 private: | 110 private: |
| 132 GridPositionType m_type; | 111 GridPositionType m_type; |
| 133 int m_integerPosition; | 112 int m_integerPosition; |
| 134 String m_namedGridLine; | 113 String m_namedGridLine; |
| 135 }; | 114 }; |
| 136 | 115 |
| 137 } // namespace WebCore | 116 } // namespace WebCore |
| 138 | 117 |
| 139 #endif // GridPosition_h | 118 #endif // GridPosition_h |
| OLD | NEW |