[css-grid] Remove compilation flag ENABLE_CSS_GRID_LAYOUT
[WebKit-https.git] / Source / WebCore / rendering / style / StyleGridData.h
1 /*
2  * Copyright (C) 2011 Google Inc. All Rights Reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  * 1. Redistributions of source code must retain the above copyright
8  *    notice, this list of conditions and the following disclaimer.
9  * 2. Redistributions in binary form must reproduce the above copyright
10  *    notice, this list of conditions and the following disclaimer in the
11  *    documentation and/or other materials provided with the distribution.
12  *
13  *  THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
14  *  EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
15  *  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
16  *  DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
17  *  DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
18  *  (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
19  *  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
20  *  ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
21  *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
22  *  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23  *
24  */
25
26 #pragma once
27
28 #include "GridArea.h"
29 #include "GridTrackSize.h"
30 #include "RenderStyleConstants.h"
31 #include <wtf/Ref.h>
32 #include <wtf/RefCounted.h>
33 #include <wtf/Vector.h>
34 #include <wtf/text/WTFString.h>
35
36 namespace WebCore {
37
38 typedef HashMap<String, Vector<unsigned>> NamedGridLinesMap;
39 typedef HashMap<unsigned, Vector<String>, WTF::IntHash<unsigned>, WTF::UnsignedWithZeroKeyHashTraits<unsigned>> OrderedNamedGridLinesMap;
40
41 class StyleGridData : public RefCounted<StyleGridData> {
42 public:
43     static Ref<StyleGridData> create() { return adoptRef(*new StyleGridData); }
44     Ref<StyleGridData> copy() const;
45
46     bool operator==(const StyleGridData& o) const
47     {
48         // FIXME: comparing two hashes doesn't look great for performance. Something to keep in mind going forward.
49         return gridColumns == o.gridColumns && gridRows == o.gridRows
50             && gridAutoFlow == o.gridAutoFlow && gridAutoRows == o.gridAutoRows && gridAutoColumns == o.gridAutoColumns
51             && namedGridColumnLines == o.namedGridColumnLines && namedGridRowLines == o.namedGridRowLines
52             && autoRepeatNamedGridColumnLines == o.autoRepeatNamedGridColumnLines && autoRepeatNamedGridRowLines == o.autoRepeatNamedGridRowLines
53             && autoRepeatOrderedNamedGridColumnLines == o.autoRepeatOrderedNamedGridColumnLines && autoRepeatOrderedNamedGridRowLines == o.autoRepeatOrderedNamedGridRowLines
54             && namedGridArea == o.namedGridArea && namedGridArea == o.namedGridArea
55             && namedGridAreaRowCount == o.namedGridAreaRowCount && namedGridAreaColumnCount == o.namedGridAreaColumnCount
56             && orderedNamedGridRowLines == o.orderedNamedGridRowLines && orderedNamedGridColumnLines == o.orderedNamedGridColumnLines
57             && gridColumnGap == o.gridColumnGap && gridRowGap == o.gridRowGap
58             && gridAutoRepeatColumns == o.gridAutoRepeatColumns && gridAutoRepeatRows == o.gridAutoRepeatRows
59             && autoRepeatColumnsInsertionPoint == o.autoRepeatColumnsInsertionPoint && autoRepeatRowsInsertionPoint == o.autoRepeatRowsInsertionPoint
60             && autoRepeatColumnsType == o.autoRepeatColumnsType && autoRepeatRowsType == o.autoRepeatRowsType;
61     }
62
63     bool operator!=(const StyleGridData& o) const
64     {
65         return !(*this == o);
66     }
67
68     Vector<GridTrackSize> gridColumns;
69     Vector<GridTrackSize> gridRows;
70
71     NamedGridLinesMap namedGridColumnLines;
72     NamedGridLinesMap namedGridRowLines;
73
74     OrderedNamedGridLinesMap orderedNamedGridColumnLines;
75     OrderedNamedGridLinesMap orderedNamedGridRowLines;
76
77     NamedGridLinesMap autoRepeatNamedGridColumnLines;
78     NamedGridLinesMap autoRepeatNamedGridRowLines;
79     OrderedNamedGridLinesMap autoRepeatOrderedNamedGridColumnLines;
80     OrderedNamedGridLinesMap autoRepeatOrderedNamedGridRowLines;
81
82     unsigned gridAutoFlow : GridAutoFlowBits;
83
84     Vector<GridTrackSize> gridAutoRows;
85     Vector<GridTrackSize> gridAutoColumns;
86
87     NamedGridAreaMap namedGridArea;
88     // Because namedGridArea doesn't store the unnamed grid areas, we need to keep track
89     // of the explicit grid size defined by both named and unnamed grid areas.
90     unsigned namedGridAreaRowCount;
91     unsigned namedGridAreaColumnCount;
92
93     Length gridColumnGap;
94     Length gridRowGap;
95
96     Vector<GridTrackSize> gridAutoRepeatColumns;
97     Vector<GridTrackSize> gridAutoRepeatRows;
98
99     unsigned autoRepeatColumnsInsertionPoint;
100     unsigned autoRepeatRowsInsertionPoint;
101
102     AutoRepeatType autoRepeatColumnsType;
103     AutoRepeatType autoRepeatRowsType;
104
105 private:
106     StyleGridData();
107     StyleGridData(const StyleGridData&);
108 };
109
110 } // namespace WebCore