Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(93)

Side by Side Diff: third_party/WebKit/Source/core/style/GridResolvedPosition.h

Issue 1500433003: [css-grid] Get rid of GridResolvedPosition (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Change operators overloaded in GridSpanIterator Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 { 17 enum GridPositionSide {
18 ColumnStartSide, 18 ColumnStartSide,
19 ColumnEndSide, 19 ColumnEndSide,
20 RowStartSide, 20 RowStartSide,
21 RowEndSide 21 RowEndSide
22 }; 22 };
23 23
24 enum GridTrackSizingDirection { 24 enum GridTrackSizingDirection {
25 ForColumns, 25 ForColumns,
26 ForRows 26 ForRows
27 }; 27 };
28 28
29 // This class represents a line index into one of the dimensions of the grid arr ay. 29 // This is a utility class with all the code related to grid items positions res olution.
30 // Wraps a size_t integer just for the purpose of knowing what we manipulate in the grid code. 30 // TODO(rego): Rename class to GridPositionsResolver.
31 class GridResolvedPosition { 31 class GridResolvedPosition {
32 DISALLOW_NEW(); 32 DISALLOW_NEW();
33 public: 33 public:
34 34
35 GridResolvedPosition(size_t position)
36 : m_integerPosition(position)
37 {
38 }
39
40 GridResolvedPosition& operator*()
41 {
42 return *this;
43 }
44
45 GridResolvedPosition& operator++()
46 {
47 m_integerPosition++;
48 return *this;
49 }
50
51 bool operator==(const GridResolvedPosition& other) const
52 {
53 return m_integerPosition == other.m_integerPosition;
54 }
55
56 bool operator!=(const GridResolvedPosition& other) const
57 {
58 return m_integerPosition != other.m_integerPosition;
59 }
60
61 bool operator<(const GridResolvedPosition& other) const
62 {
63 return m_integerPosition < other.m_integerPosition;
64 }
65
66 bool operator>(const GridResolvedPosition& other) const
67 {
68 return m_integerPosition > other.m_integerPosition;
69 }
70
71 bool operator<=(const GridResolvedPosition& other) const
72 {
73 return m_integerPosition <= other.m_integerPosition;
74 }
75
76 bool operator>=(const GridResolvedPosition& other) const
77 {
78 return m_integerPosition >= other.m_integerPosition;
79 }
80
81 size_t toInt() const
82 {
83 return m_integerPosition;
84 }
85
86 GridResolvedPosition next() const
87 {
88 return GridResolvedPosition(m_integerPosition + 1);
89 }
90
91 GridResolvedPosition prev() const
92 {
93 return GridResolvedPosition(m_integerPosition > 0 ? m_integerPosition - 1 : 0);
94 }
95
96 static size_t explicitGridColumnCount(const ComputedStyle&); 35 static size_t explicitGridColumnCount(const ComputedStyle&);
97 static size_t explicitGridRowCount(const ComputedStyle&); 36 static size_t explicitGridRowCount(const ComputedStyle&);
98 37
99 static bool isValidNamedLineOrArea(const String& lineName, const ComputedSty le&, GridPositionSide); 38 static bool isValidNamedLineOrArea(const String& lineName, const ComputedSty le&, GridPositionSide);
100 39
101 static GridPositionSide initialPositionSide(GridTrackSizingDirection); 40 static GridPositionSide initialPositionSide(GridTrackSizingDirection);
102 static GridPositionSide finalPositionSide(GridTrackSizingDirection); 41 static GridPositionSide finalPositionSide(GridTrackSizingDirection);
103 42
104 static GridSpan resolveGridPositionsFromAutoPlacementPosition(const Computed Style&, const LayoutBox&, GridTrackSizingDirection, const GridResolvedPosition&) ; 43 static GridSpan resolveGridPositionsFromAutoPlacementPosition(const Computed Style&, const LayoutBox&, GridTrackSizingDirection, size_t resolvedInitialPositi on);
105 static GridSpan resolveGridPositionsFromStyle(const ComputedStyle&, const La youtBox&, GridTrackSizingDirection); 44 static GridSpan resolveGridPositionsFromStyle(const ComputedStyle&, const La youtBox&, GridTrackSizingDirection);
106 45
107 private:
108
109 size_t m_integerPosition;
110 }; 46 };
111 47
112 } // namespace blink 48 } // namespace blink
113 49
114 #endif // GridResolvedPosition_h 50 #endif // GridResolvedPosition_h
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/style/GridCoordinate.h ('k') | third_party/WebKit/Source/core/style/GridResolvedPosition.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698