Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef GridResolvedPosition_h | |
| 6 #define GridResolvedPosition_h | |
| 7 | |
| 8 #include "core/rendering/style/GridPosition.h" | |
| 9 | |
| 10 namespace WebCore { | |
| 11 | |
| 12 enum GridPositionSide { | |
| 13 ColumnStartSide, | |
| 14 ColumnEndSide, | |
| 15 RowStartSide, | |
| 16 RowEndSide | |
| 17 }; | |
| 18 | |
| 19 class GridResolvedPosition { | |
| 20 public: | |
| 21 static size_t adjustGridPositionForAfterEndSide(size_t resolvedPosition) | |
| 22 { | |
| 23 return resolvedPosition ? resolvedPosition - 1 : 0; | |
| 24 } | |
| 25 | |
| 26 static size_t adjustGridPositionForSide(size_t resolvedPosition, GridPositio nSide side) | |
| 27 { | |
| 28 // An item finishing on the N-th line belongs to the N-1-th cell. | |
| 29 if (side == ColumnEndSide || side == RowEndSide) | |
| 30 return adjustGridPositionForAfterEndSide(resolvedPosition); | |
| 31 | |
| 32 return resolvedPosition; | |
| 33 } | |
| 34 | |
| 35 GridResolvedPosition() | |
| 36 : m_integerPosition(0) | |
| 37 { | |
| 38 } | |
|
Julien - ping for review
2014/03/06 22:38:02
IMHO we should just not have this constructor and
| |
| 39 | |
| 40 GridResolvedPosition(size_t position) | |
| 41 : m_integerPosition(position) | |
| 42 { | |
| 43 } | |
| 44 | |
| 45 GridResolvedPosition(const GridPosition& position, GridPositionSide side) | |
| 46 { | |
| 47 size_t integerPosition; | |
| 48 | |
| 49 ASSERT(position.integerPosition()); | |
| 50 integerPosition = position.integerPosition() - 1; | |
| 51 | |
| 52 m_integerPosition = adjustGridPositionForSide(integerPosition, side); | |
| 53 } | |
| 54 | |
| 55 size_t integerPosition() const | |
|
Julien - ping for review
2014/03/06 22:38:02
Do we need the explicit "integer" in the getter/se
| |
| 56 { | |
| 57 return m_integerPosition; | |
| 58 } | |
| 59 | |
| 60 void setIntegerPosition(size_t position) | |
| 61 { | |
| 62 m_integerPosition = position; | |
| 63 } | |
| 64 | |
|
Julien - ping for review
2014/03/06 22:38:02
The current API makes the code very verbose as we
| |
| 65 private: | |
| 66 size_t m_integerPosition; | |
| 67 }; | |
| 68 | |
| 69 } // namespace WebCore | |
| 70 | |
| 71 #endif // GridResolvedPosition_h | |
| OLD | NEW |