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 class GridSpan; | |
| 13 class RenderBox; | |
| 14 class RenderStyle; | |
| 15 | |
| 16 enum GridPositionSide { | |
| 17 ColumnStartSide, | |
| 18 ColumnEndSide, | |
| 19 RowStartSide, | |
| 20 RowEndSide | |
| 21 }; | |
| 22 | |
| 23 enum GridTrackSizingDirection { | |
| 24 ForColumns, | |
| 25 ForRows | |
| 26 }; | |
| 27 | |
|
Julien - ping for review
2014/03/21 23:49:27
Maybe worth adding a class comment that this is an
| |
| 28 class GridResolvedPosition { | |
| 29 public: | |
| 30 static size_t adjustGridPositionForAfterEndSide(size_t resolvedPosition) | |
| 31 { | |
| 32 return resolvedPosition ? resolvedPosition - 1 : 0; | |
| 33 } | |
| 34 | |
| 35 static size_t adjustGridPositionForSide(size_t resolvedPosition, GridPositio nSide side) | |
| 36 { | |
| 37 // An item finishing on the N-th line belongs to the N-1-th cell. | |
| 38 if (side == ColumnEndSide || side == RowEndSide) | |
| 39 return adjustGridPositionForAfterEndSide(resolvedPosition); | |
| 40 | |
| 41 return resolvedPosition; | |
| 42 } | |
| 43 | |
| 44 static GridSpan resolveGridPositionsFromAutoPlacementPosition(const RenderBo x*, GridTrackSizingDirection, const GridResolvedPosition&); | |
| 45 static PassOwnPtr<GridSpan> resolveGridPositionsFromStyle(const RenderStyle& , const RenderBox*, GridTrackSizingDirection); | |
| 46 static GridResolvedPosition resolveNamedGridLinePositionFromStyle(const Rend erStyle&, const GridPosition&, GridPositionSide); | |
| 47 static GridResolvedPosition resolveGridPositionFromStyle(const RenderStyle&, const GridPosition&, GridPositionSide); | |
| 48 static PassOwnPtr<GridSpan> resolveGridPositionAgainstOppositePosition(const RenderStyle&, const GridResolvedPosition& resolvedOppositePosition, const GridP osition&, GridPositionSide); | |
| 49 static PassOwnPtr<GridSpan> resolveNamedGridLinePositionAgainstOppositePosit ion(const RenderStyle&, const GridResolvedPosition& resolvedOppositePosition, co nst GridPosition&, GridPositionSide); | |
| 50 | |
| 51 GridResolvedPosition(size_t position) | |
| 52 : m_integerPosition(position) | |
| 53 { | |
| 54 } | |
| 55 | |
| 56 GridResolvedPosition(const GridPosition& position, GridPositionSide side) | |
| 57 { | |
| 58 size_t integerPosition; | |
|
Julien - ping for review
2014/03/21 23:49:27
No need to define this variable here. Better just
| |
| 59 | |
| 60 ASSERT(position.integerPosition()); | |
| 61 integerPosition = position.integerPosition() - 1; | |
| 62 | |
| 63 m_integerPosition = adjustGridPositionForSide(integerPosition, side); | |
| 64 } | |
| 65 | |
| 66 GridResolvedPosition next() const | |
| 67 { | |
| 68 return GridResolvedPosition(m_integerPosition + 1); | |
| 69 } | |
| 70 | |
| 71 GridResolvedPosition& operator++() | |
| 72 { | |
| 73 m_integerPosition++; | |
| 74 return *this; | |
| 75 } | |
| 76 | |
| 77 GridResolvedPosition& operator=(const GridResolvedPosition& other) | |
| 78 { | |
| 79 m_integerPosition = other.m_integerPosition; | |
| 80 return *this; | |
| 81 } | |
| 82 | |
| 83 bool operator==(const GridResolvedPosition& other) const | |
| 84 { | |
| 85 return m_integerPosition == other.m_integerPosition; | |
| 86 } | |
| 87 | |
| 88 bool operator<(const GridResolvedPosition& other) const | |
| 89 { | |
| 90 return m_integerPosition < other.m_integerPosition; | |
| 91 } | |
| 92 | |
| 93 bool operator<=(const GridResolvedPosition& other) const | |
| 94 { | |
| 95 return m_integerPosition <= other.m_integerPosition; | |
| 96 } | |
| 97 | |
| 98 bool operator<(size_t otherIntegerPosition) const | |
| 99 { | |
| 100 return m_integerPosition < otherIntegerPosition; | |
| 101 } | |
| 102 | |
| 103 bool operator<=(size_t otherIntegerPosition) const | |
| 104 { | |
| 105 return m_integerPosition <= otherIntegerPosition; | |
| 106 } | |
| 107 | |
| 108 operator size_t() const | |
| 109 { | |
| 110 return m_integerPosition; | |
| 111 } | |
| 112 | |
| 113 static size_t explicitGridColumnCount(const RenderStyle&); | |
| 114 static size_t explicitGridRowCount(const RenderStyle&); | |
| 115 | |
| 116 private: | |
| 117 | |
| 118 static size_t explicitGridSizeForSide(const RenderStyle&, GridPositionSide); | |
| 119 | |
| 120 size_t m_integerPosition; | |
| 121 }; | |
| 122 | |
| 123 } // namespace WebCore | |
| 124 | |
| 125 #endif // GridResolvedPosition_h | |
| OLD | NEW |