Move parseFontFaceDescriptor to CSSPropertyParser.cpp
[chromium-blink-merge.git] / third_party / WebKit / Source / core / style / GridResolvedPosition.h
blobe35441fa95c437ab8181b1b97e5a4700acb4a50e
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.
5 #ifndef GridResolvedPosition_h
6 #define GridResolvedPosition_h
8 #include "core/style/GridPosition.h"
9 #include "wtf/Allocator.h"
11 namespace blink {
13 struct GridSpan;
14 class LayoutBox;
15 class ComputedStyle;
17 enum GridPositionSide {
18 ColumnStartSide,
19 ColumnEndSide,
20 RowStartSide,
21 RowEndSide
24 enum GridTrackSizingDirection {
25 ForColumns,
26 ForRows
29 // 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.
31 class GridResolvedPosition {
32 DISALLOW_ALLOCATION();
33 public:
34 static GridResolvedPosition adjustGridPositionForAfterEndSide(size_t resolvedPosition)
36 return resolvedPosition ? GridResolvedPosition(resolvedPosition - 1) : GridResolvedPosition(0);
39 static GridResolvedPosition adjustGridPositionForSide(size_t resolvedPosition, GridPositionSide side)
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);
45 return GridResolvedPosition(resolvedPosition);
48 static void initialAndFinalPositionsFromStyle(const ComputedStyle&, const LayoutBox&, GridTrackSizingDirection, GridPosition &initialPosition, GridPosition &finalPosition);
49 static GridSpan resolveGridPositionsFromAutoPlacementPosition(const ComputedStyle&, const LayoutBox&, GridTrackSizingDirection, const GridResolvedPosition&);
50 static PassOwnPtr<GridSpan> resolveGridPositionsFromStyle(const ComputedStyle&, const LayoutBox&, GridTrackSizingDirection);
51 static GridResolvedPosition resolveNamedGridLinePositionFromStyle(const ComputedStyle&, const GridPosition&, GridPositionSide);
52 static GridResolvedPosition resolveGridPositionFromStyle(const ComputedStyle&, const GridPosition&, GridPositionSide);
53 static PassOwnPtr<GridSpan> resolveGridPositionAgainstOppositePosition(const ComputedStyle&, const GridResolvedPosition& resolvedOppositePosition, const GridPosition&, GridPositionSide);
54 static PassOwnPtr<GridSpan> resolveNamedGridLinePositionAgainstOppositePosition(const ComputedStyle&, const GridResolvedPosition& resolvedOppositePosition, const GridPosition&, GridPositionSide);
56 GridResolvedPosition(size_t position)
57 : m_integerPosition(position)
61 GridResolvedPosition(const GridPosition& position, GridPositionSide side)
63 ASSERT(position.integerPosition());
64 size_t integerPosition = position.integerPosition() - 1;
66 m_integerPosition = adjustGridPositionForSide(integerPosition, side).toInt();
69 GridResolvedPosition& operator*()
71 return *this;
74 GridResolvedPosition& operator++()
76 m_integerPosition++;
77 return *this;
80 bool operator==(const GridResolvedPosition& other) const
82 return m_integerPosition == other.m_integerPosition;
85 bool operator!=(const GridResolvedPosition& other) const
87 return m_integerPosition != other.m_integerPosition;
90 bool operator<(const GridResolvedPosition& other) const
92 return m_integerPosition < other.m_integerPosition;
95 bool operator>(const GridResolvedPosition& other) const
97 return m_integerPosition > other.m_integerPosition;
100 bool operator<=(const GridResolvedPosition& other) const
102 return m_integerPosition <= other.m_integerPosition;
105 bool operator>=(const GridResolvedPosition& other) const
107 return m_integerPosition >= other.m_integerPosition;
110 size_t toInt() const
112 return m_integerPosition;
115 GridResolvedPosition next() const
117 return GridResolvedPosition(m_integerPosition + 1);
120 static size_t explicitGridColumnCount(const ComputedStyle&);
121 static size_t explicitGridRowCount(const ComputedStyle&);
123 private:
125 static size_t explicitGridSizeForSide(const ComputedStyle&, GridPositionSide);
127 size_t m_integerPosition;
130 } // namespace blink
132 #endif // GridResolvedPosition_h