OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2011 Apple Inc. All rights reserved. | 2 * Copyright (C) 2011 Apple Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 12 matching lines...) Expand all Loading... |
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
24 */ | 24 */ |
25 | 25 |
26 #ifndef RenderGrid_h | 26 #ifndef RenderGrid_h |
27 #define RenderGrid_h | 27 #define RenderGrid_h |
28 | 28 |
29 #include "core/rendering/RenderBlock.h" | 29 #include "core/rendering/RenderBlock.h" |
30 | 30 |
31 namespace WebCore { | 31 namespace WebCore { |
32 | 32 |
| 33 class GridCoordinate; |
| 34 class GridSpan; |
33 class GridTrack; | 35 class GridTrack; |
34 | 36 |
35 enum GridPositionSide { | 37 enum GridPositionSide { |
36 ColumnStartSide, | 38 ColumnStartSide, |
37 ColumnEndSide, | 39 ColumnEndSide, |
38 RowStartSide, | 40 RowStartSide, |
39 RowEndSide | 41 RowEndSide |
40 }; | 42 }; |
41 | 43 |
42 class RenderGrid FINAL : public RenderBlock { | 44 class RenderGrid FINAL : public RenderBlock { |
43 public: | 45 public: |
44 RenderGrid(Element*); | 46 RenderGrid(Element*); |
45 virtual ~RenderGrid(); | 47 virtual ~RenderGrid(); |
46 | 48 |
47 virtual const char* renderName() const OVERRIDE; | 49 virtual const char* renderName() const OVERRIDE; |
48 | 50 |
49 virtual void layoutBlock(bool relayoutChildren, LayoutUnit pageLogicalHeight
= 0) OVERRIDE; | 51 virtual void layoutBlock(bool relayoutChildren, LayoutUnit pageLogicalHeight
= 0) OVERRIDE; |
50 | 52 |
51 virtual bool avoidsFloats() const OVERRIDE { return true; } | 53 virtual bool avoidsFloats() const OVERRIDE { return true; } |
52 virtual bool canCollapseAnonymousBlockChild() const OVERRIDE { return false;
} | 54 virtual bool canCollapseAnonymousBlockChild() const OVERRIDE { return false;
} |
53 | 55 |
54 private: | 56 private: |
55 virtual bool isRenderGrid() const OVERRIDE { return true; } | 57 virtual bool isRenderGrid() const OVERRIDE { return true; } |
56 virtual void computeIntrinsicLogicalWidths(LayoutUnit& minLogicalWidth, Layo
utUnit& maxLogicalWidth) const OVERRIDE; | 58 virtual void computeIntrinsicLogicalWidths(LayoutUnit& minLogicalWidth, Layo
utUnit& maxLogicalWidth) const OVERRIDE; |
57 virtual void computePreferredLogicalWidths() OVERRIDE; | 59 virtual void computePreferredLogicalWidths() OVERRIDE; |
58 | 60 |
59 LayoutUnit computePreferredTrackWidth(const GridLength&, size_t) const; | 61 LayoutUnit computePreferredTrackWidth(const GridLength&, size_t) const; |
60 | 62 |
61 struct GridSpan { | |
62 static PassOwnPtr<GridSpan> create(size_t initialPosition, size_t finalP
osition) | |
63 { | |
64 return adoptPtr(new GridSpan(initialPosition, finalPosition)); | |
65 } | |
66 | |
67 GridSpan(size_t initialPosition, size_t finalPosition) | |
68 : initialPositionIndex(initialPosition) | |
69 , finalPositionIndex(finalPosition) | |
70 { | |
71 ASSERT(initialPositionIndex <= finalPositionIndex); | |
72 } | |
73 | |
74 size_t initialPositionIndex; | |
75 size_t finalPositionIndex; | |
76 }; | |
77 | |
78 struct GridCoordinate { | |
79 // HashMap requires a default constuctor. | |
80 GridCoordinate() | |
81 : columns(0, 0) | |
82 , rows(0, 0) | |
83 { | |
84 } | |
85 | |
86 GridCoordinate(const GridSpan& r, const GridSpan& c) | |
87 : columns(c) | |
88 , rows(r) | |
89 { | |
90 } | |
91 | |
92 GridSpan columns; | |
93 GridSpan rows; | |
94 }; | |
95 | |
96 class GridIterator; | 63 class GridIterator; |
97 enum TrackSizingDirection { ForColumns, ForRows }; | 64 enum TrackSizingDirection { ForColumns, ForRows }; |
98 void computedUsedBreadthOfGridTracks(TrackSizingDirection, Vector<GridTrack>
& columnTracks, Vector<GridTrack>& rowTracks); | 65 void computedUsedBreadthOfGridTracks(TrackSizingDirection, Vector<GridTrack>
& columnTracks, Vector<GridTrack>& rowTracks); |
99 LayoutUnit computeUsedBreadthOfMinLength(TrackSizingDirection, const GridLen
gth&) const; | 66 LayoutUnit computeUsedBreadthOfMinLength(TrackSizingDirection, const GridLen
gth&) const; |
100 LayoutUnit computeUsedBreadthOfMaxLength(TrackSizingDirection, const GridLen
gth&, LayoutUnit usedBreadth) const; | 67 LayoutUnit computeUsedBreadthOfMaxLength(TrackSizingDirection, const GridLen
gth&, LayoutUnit usedBreadth) const; |
101 LayoutUnit computeUsedBreadthOfSpecifiedLength(TrackSizingDirection, const L
ength&) const; | 68 LayoutUnit computeUsedBreadthOfSpecifiedLength(TrackSizingDirection, const L
ength&) const; |
102 void resolveContentBasedTrackSizingFunctions(TrackSizingDirection, Vector<Gr
idTrack>& columnTracks, Vector<GridTrack>& rowTracks, LayoutUnit& availableLogic
alSpace); | 69 void resolveContentBasedTrackSizingFunctions(TrackSizingDirection, Vector<Gr
idTrack>& columnTracks, Vector<GridTrack>& rowTracks, LayoutUnit& availableLogic
alSpace); |
103 | 70 |
104 void growGrid(TrackSizingDirection); | 71 void growGrid(TrackSizingDirection); |
105 void insertItemIntoGrid(RenderBox*, size_t rowTrack, size_t columnTrack); | 72 void insertItemIntoGrid(RenderBox*, size_t rowTrack, size_t columnTrack); |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 return m_grid.size(); | 126 return m_grid.size(); |
160 } | 127 } |
161 | 128 |
162 Vector<Vector<Vector<RenderBox*, 1> > > m_grid; | 129 Vector<Vector<Vector<RenderBox*, 1> > > m_grid; |
163 HashMap<const RenderBox*, GridCoordinate> m_gridItemCoordinate; | 130 HashMap<const RenderBox*, GridCoordinate> m_gridItemCoordinate; |
164 }; | 131 }; |
165 | 132 |
166 } // namespace WebCore | 133 } // namespace WebCore |
167 | 134 |
168 #endif // RenderGrid_h | 135 #endif // RenderGrid_h |
OLD | NEW |