OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef GridResolvedPosition_h | 5 #ifndef GridResolvedPosition_h |
6 #define GridResolvedPosition_h | 6 #define GridResolvedPosition_h |
7 | 7 |
8 #include "core/style/GridPosition.h" | 8 #include "core/style/GridPosition.h" |
9 #include "wtf/Allocator.h" | 9 #include "wtf/Allocator.h" |
10 | 10 |
11 namespace blink { | 11 namespace blink { |
12 | 12 |
13 struct GridSpan; | 13 struct GridSpan; |
14 class LayoutBox; | 14 class LayoutBox; |
15 class ComputedStyle; | 15 class ComputedStyle; |
16 | 16 |
17 enum GridPositionSide { | |
18 ColumnStartSide, | |
19 ColumnEndSide, | |
20 RowStartSide, | |
21 RowEndSide | |
22 }; | |
23 | |
24 enum GridTrackSizingDirection { | 17 enum GridTrackSizingDirection { |
25 ForColumns, | 18 ForColumns, |
26 ForRows | 19 ForRows |
27 }; | 20 }; |
28 | 21 |
22 class GridUnresolvedSpan { | |
23 public: | |
24 GridUnresolvedSpan(GridPosition initialPosition, GridPositionSide initialPos itionSide, GridPosition finalPosition, GridPositionSide finalPositionSide) | |
25 : m_initialPosition(initialPosition) | |
26 , m_finalPosition(finalPosition) | |
27 , m_initialPositionSide(initialPositionSide) | |
28 , m_finalPositionSide(finalPositionSide) | |
29 { | |
30 } | |
31 | |
32 const GridPosition& initialPosition() const { return m_initialPosition; } | |
33 const GridPosition& finalPosition() const { return m_finalPosition; } | |
34 GridPositionSide initialPositionSide() const { return m_initialPositionSide; } | |
35 GridPositionSide finalPositionSide() const { return m_finalPositionSide; } | |
36 | |
37 bool requiresAutoPlacement() const; | |
38 GridUnresolvedSpan& adjustGridPositionsFromStyle(const ComputedStyle& gridCo ntainerStyle); | |
39 | |
40 private: | |
41 GridPosition m_initialPosition; | |
42 GridPosition m_finalPosition; | |
43 GridPositionSide m_initialPositionSide; | |
44 GridPositionSide m_finalPositionSide; | |
45 }; | |
46 | |
29 // This class represents an index into one of the dimensions of the grid array. | 47 // This class represents an index into one of the dimensions of the grid array. |
30 // Wraps a size_t integer just for the purpose of knowing what we manipulate in the grid code. | 48 // Wraps a size_t integer just for the purpose of knowing what we manipulate in the grid code. |
31 class GridResolvedPosition { | 49 class GridResolvedPosition { |
32 DISALLOW_NEW(); | 50 DISALLOW_NEW(); |
33 public: | 51 public: |
34 static GridResolvedPosition adjustGridPositionForAfterEndSide(size_t resolve dPosition) | |
35 { | |
36 return resolvedPosition ? GridResolvedPosition(resolvedPosition - 1) : G ridResolvedPosition(0); | |
37 } | |
38 | |
39 static GridResolvedPosition adjustGridPositionForSide(size_t resolvedPositio n, GridPositionSide side) | |
40 { | |
41 // An item finishing on the N-th line belongs to the N-1-th cell. | |
42 if (side == ColumnEndSide || side == RowEndSide) | |
43 return adjustGridPositionForAfterEndSide(resolvedPosition); | |
44 | |
45 return GridResolvedPosition(resolvedPosition); | |
46 } | |
47 | |
48 static bool isValidNamedLineOrArea(const String& lineName, const ComputedSty le&, GridPositionSide); | |
49 static GridPositionSide initialPositionSide(GridTrackSizingDirection); | |
50 static GridPositionSide finalPositionSide(GridTrackSizingDirection); | |
51 static void initialAndFinalPositionsFromStyle(const ComputedStyle&, const La youtBox&, GridTrackSizingDirection, GridPosition &initialPosition, GridPosition &finalPosition); | |
52 static GridSpan resolveGridPositionsFromAutoPlacementPosition(const Computed Style&, const LayoutBox&, GridTrackSizingDirection, const GridResolvedPosition&) ; | |
53 static PassOwnPtr<GridSpan> resolveGridPositionsFromStyle(const ComputedStyl e&, const LayoutBox&, GridTrackSizingDirection); | |
54 static GridResolvedPosition resolveNamedGridLinePositionFromStyle(const Comp utedStyle&, const GridPosition&, GridPositionSide); | |
55 static GridResolvedPosition resolveGridPositionFromStyle(const ComputedStyle &, const GridPosition&, GridPositionSide); | |
56 static PassOwnPtr<GridSpan> resolveGridPositionAgainstOppositePosition(const ComputedStyle&, const GridResolvedPosition& resolvedOppositePosition, const Gri dPosition&, GridPositionSide); | |
57 static PassOwnPtr<GridSpan> resolveNamedGridLinePositionAgainstOppositePosit ion(const ComputedStyle&, const GridResolvedPosition& resolvedOppositePosition, const GridPosition&, GridPositionSide); | |
58 | |
59 GridResolvedPosition(size_t position) | 52 GridResolvedPosition(size_t position) |
60 : m_integerPosition(position) | 53 : m_integerPosition(position) |
61 { | 54 { |
62 } | 55 } |
63 | 56 |
64 GridResolvedPosition(const GridPosition& position, GridPositionSide side) | 57 GridResolvedPosition(const GridPosition&, GridPositionSide); |
65 { | |
66 ASSERT(position.integerPosition()); | |
67 size_t integerPosition = position.integerPosition() - 1; | |
68 | |
69 m_integerPosition = adjustGridPositionForSide(integerPosition, side).toI nt(); | |
70 } | |
71 | 58 |
72 GridResolvedPosition& operator*() | 59 GridResolvedPosition& operator*() |
73 { | 60 { |
74 return *this; | 61 return *this; |
75 } | 62 } |
76 | 63 |
77 GridResolvedPosition& operator++() | 64 GridResolvedPosition& operator++() |
78 { | 65 { |
79 m_integerPosition++; | 66 m_integerPosition++; |
80 return *this; | 67 return *this; |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
113 size_t toInt() const | 100 size_t toInt() const |
114 { | 101 { |
115 return m_integerPosition; | 102 return m_integerPosition; |
116 } | 103 } |
117 | 104 |
118 GridResolvedPosition next() const | 105 GridResolvedPosition next() const |
119 { | 106 { |
120 return GridResolvedPosition(m_integerPosition + 1); | 107 return GridResolvedPosition(m_integerPosition + 1); |
121 } | 108 } |
122 | 109 |
110 static bool isValidNamedLineOrArea(const String& lineName, const ComputedSty le&, GridPositionSide); | |
111 static GridSpan resolveGridPositionsFromAutoPlacementPosition(const Computed Style&, const LayoutBox&, GridTrackSizingDirection, const GridResolvedPosition&) ; | |
112 static GridUnresolvedSpan unresolvedSpanFromStyle(const ComputedStyle&, cons t LayoutBox&, GridTrackSizingDirection); | |
113 static GridSpan resolveGridPositionsFromStyle(const GridUnresolvedSpan&, con st ComputedStyle&); | |
123 static size_t explicitGridColumnCount(const ComputedStyle&); | 114 static size_t explicitGridColumnCount(const ComputedStyle&); |
124 static size_t explicitGridRowCount(const ComputedStyle&); | 115 static size_t explicitGridRowCount(const ComputedStyle&); |
125 | 116 |
126 private: | 117 private: |
127 | 118 |
119 static void initialAndFinalPositionsFromStyle(const ComputedStyle&, const La youtBox&, GridTrackSizingDirection, GridPosition &initialPosition, GridPosition &finalPosition); | |
120 static PassOwnPtr<GridSpan> resolveNamedGridLinePositionAgainstOppositePosit ion(const ComputedStyle&, const GridResolvedPosition& resolvedOppositePosition, const GridPosition&, GridPositionSide); | |
Manuel Rego
2015/11/10 09:08:03
Nit: Probably this should be plural ("Positions" i
svillar
2015/11/10 10:56:37
Actually that method should not be there, we must
| |
128 static size_t explicitGridSizeForSide(const ComputedStyle&, GridPositionSide ); | 121 static size_t explicitGridSizeForSide(const ComputedStyle&, GridPositionSide ); |
129 | 122 |
130 size_t m_integerPosition; | 123 size_t m_integerPosition; |
131 }; | 124 }; |
132 | 125 |
133 } // namespace blink | 126 } // namespace blink |
134 | 127 |
135 #endif // GridResolvedPosition_h | 128 #endif // GridResolvedPosition_h |
OLD | NEW |