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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 | 46 |
47 virtual void layoutBlock(bool relayoutChildren) override; | 47 virtual void layoutBlock(bool relayoutChildren) override; |
48 | 48 |
49 virtual bool canCollapseAnonymousBlockChild() const override { return false;
} | 49 virtual bool canCollapseAnonymousBlockChild() const override { return false;
} |
50 | 50 |
51 void dirtyGrid(); | 51 void dirtyGrid(); |
52 | 52 |
53 const Vector<LayoutUnit>& columnPositions() const { return m_columnPositions
; } | 53 const Vector<LayoutUnit>& columnPositions() const { return m_columnPositions
; } |
54 const Vector<LayoutUnit>& rowPositions() const { return m_rowPositions; } | 54 const Vector<LayoutUnit>& rowPositions() const { return m_rowPositions; } |
55 | 55 |
56 typedef Vector<RenderBox*, 1> GridCell; | 56 typedef Vector<LayoutBox*, 1> GridCell; |
57 const GridCell& gridCell(int row, int column) { return m_grid[row][column];
} | 57 const GridCell& gridCell(int row, int column) { return m_grid[row][column];
} |
58 const Vector<RenderBox*>& itemsOverflowingGridArea() { return m_gridItemsOve
rflowingGridArea; } | 58 const Vector<LayoutBox*>& itemsOverflowingGridArea() { return m_gridItemsOve
rflowingGridArea; } |
59 int paintIndexForGridItem(const RenderBox* renderBox) { return m_gridItemsIn
dexesMap.get(renderBox); } | 59 int paintIndexForGridItem(const LayoutBox* layoutBox) { return m_gridItemsIn
dexesMap.get(layoutBox); } |
60 | 60 |
61 bool gridIsDirty() const { return m_gridIsDirty; } | 61 bool gridIsDirty() const { return m_gridIsDirty; } |
62 | 62 |
63 typedef void (GridTrack::* AccumulatorGrowFunction)(LayoutUnit); | 63 typedef void (GridTrack::* AccumulatorGrowFunction)(LayoutUnit); |
64 private: | 64 private: |
65 virtual bool isOfType(LayoutObjectType type) const override { return type ==
LayoutObjectRenderGrid || RenderBlock::isOfType(type); } | 65 virtual bool isOfType(LayoutObjectType type) const override { return type ==
LayoutObjectRenderGrid || RenderBlock::isOfType(type); } |
66 virtual void computeIntrinsicLogicalWidths(LayoutUnit& minLogicalWidth, Layo
utUnit& maxLogicalWidth) const override; | 66 virtual void computeIntrinsicLogicalWidths(LayoutUnit& minLogicalWidth, Layo
utUnit& maxLogicalWidth) const override; |
67 virtual void computePreferredLogicalWidths() override; | 67 virtual void computePreferredLogicalWidths() override; |
68 | 68 |
69 virtual void addChild(LayoutObject* newChild, LayoutObject* beforeChild = 0)
override; | 69 virtual void addChild(LayoutObject* newChild, LayoutObject* beforeChild = 0)
override; |
70 virtual void removeChild(LayoutObject*) override; | 70 virtual void removeChild(LayoutObject*) override; |
71 | 71 |
72 virtual void styleDidChange(StyleDifference, const LayoutStyle*) override; | 72 virtual void styleDidChange(StyleDifference, const LayoutStyle*) override; |
73 | 73 |
74 bool explicitGridDidResize(const LayoutStyle&) const; | 74 bool explicitGridDidResize(const LayoutStyle&) const; |
75 bool namedGridLinesDefinitionDidChange(const LayoutStyle&) const; | 75 bool namedGridLinesDefinitionDidChange(const LayoutStyle&) const; |
76 | 76 |
77 class GridIterator; | 77 class GridIterator; |
78 struct GridSizingData; | 78 struct GridSizingData; |
79 bool gridElementIsShrinkToFit(); | 79 bool gridElementIsShrinkToFit(); |
80 void computeUsedBreadthOfGridTracks(GridTrackSizingDirection, GridSizingData
&); | 80 void computeUsedBreadthOfGridTracks(GridTrackSizingDirection, GridSizingData
&); |
81 void computeUsedBreadthOfGridTracks(GridTrackSizingDirection, GridSizingData
&, LayoutUnit& availableLogicalSpace); | 81 void computeUsedBreadthOfGridTracks(GridTrackSizingDirection, GridSizingData
&, LayoutUnit& availableLogicalSpace); |
82 LayoutUnit computeUsedBreadthOfMinLength(GridTrackSizingDirection, const Gri
dLength&) const; | 82 LayoutUnit computeUsedBreadthOfMinLength(GridTrackSizingDirection, const Gri
dLength&) const; |
83 LayoutUnit computeUsedBreadthOfMaxLength(GridTrackSizingDirection, const Gri
dLength&, LayoutUnit usedBreadth) const; | 83 LayoutUnit computeUsedBreadthOfMaxLength(GridTrackSizingDirection, const Gri
dLength&, LayoutUnit usedBreadth) const; |
84 LayoutUnit computeUsedBreadthOfSpecifiedLength(GridTrackSizingDirection, con
st Length&) const; | 84 LayoutUnit computeUsedBreadthOfSpecifiedLength(GridTrackSizingDirection, con
st Length&) const; |
85 void resolveContentBasedTrackSizingFunctions(GridTrackSizingDirection, GridS
izingData&, LayoutUnit& availableLogicalSpace); | 85 void resolveContentBasedTrackSizingFunctions(GridTrackSizingDirection, GridS
izingData&, LayoutUnit& availableLogicalSpace); |
86 | 86 |
87 void ensureGridSize(size_t maximumRowIndex, size_t maximumColumnIndex); | 87 void ensureGridSize(size_t maximumRowIndex, size_t maximumColumnIndex); |
88 void insertItemIntoGrid(RenderBox&, const GridCoordinate&); | 88 void insertItemIntoGrid(LayoutBox&, const GridCoordinate&); |
89 void placeItemsOnGrid(); | 89 void placeItemsOnGrid(); |
90 void populateExplicitGridAndOrderIterator(); | 90 void populateExplicitGridAndOrderIterator(); |
91 PassOwnPtr<GridCoordinate> createEmptyGridAreaAtSpecifiedPositionsOutsideGri
d(const RenderBox&, GridTrackSizingDirection, const GridSpan& specifiedPositions
) const; | 91 PassOwnPtr<GridCoordinate> createEmptyGridAreaAtSpecifiedPositionsOutsideGri
d(const LayoutBox&, GridTrackSizingDirection, const GridSpan& specifiedPositions
) const; |
92 void placeSpecifiedMajorAxisItemsOnGrid(const Vector<RenderBox*>&); | 92 void placeSpecifiedMajorAxisItemsOnGrid(const Vector<LayoutBox*>&); |
93 void placeAutoMajorAxisItemsOnGrid(const Vector<RenderBox*>&); | 93 void placeAutoMajorAxisItemsOnGrid(const Vector<LayoutBox*>&); |
94 void placeAutoMajorAxisItemOnGrid(RenderBox&, std::pair<size_t, size_t>& aut
oPlacementCursor); | 94 void placeAutoMajorAxisItemOnGrid(LayoutBox&, std::pair<size_t, size_t>& aut
oPlacementCursor); |
95 GridTrackSizingDirection autoPlacementMajorAxisDirection() const; | 95 GridTrackSizingDirection autoPlacementMajorAxisDirection() const; |
96 GridTrackSizingDirection autoPlacementMinorAxisDirection() const; | 96 GridTrackSizingDirection autoPlacementMinorAxisDirection() const; |
97 | 97 |
98 void layoutGridItems(); | 98 void layoutGridItems(); |
99 void layoutPositionedObjects(bool relayoutChildren, PositionedLayoutBehavior
= DefaultLayout); | 99 void layoutPositionedObjects(bool relayoutChildren, PositionedLayoutBehavior
= DefaultLayout); |
100 void offsetAndBreadthForPositionedChild(const RenderBox&, GridTrackSizingDir
ection, bool startIsAuto, bool endIsAuto, LayoutUnit& offset, LayoutUnit& breadt
h); | 100 void offsetAndBreadthForPositionedChild(const LayoutBox&, GridTrackSizingDir
ection, bool startIsAuto, bool endIsAuto, LayoutUnit& offset, LayoutUnit& breadt
h); |
101 void populateGridPositions(const GridSizingData&, LayoutUnit availableSpaceF
orColumns, LayoutUnit availableSpaceForRows); | 101 void populateGridPositions(const GridSizingData&, LayoutUnit availableSpaceF
orColumns, LayoutUnit availableSpaceForRows); |
102 | 102 |
103 typedef LayoutUnit (RenderGrid::* SizingFunction)(RenderBox&, GridTrackSizin
gDirection, Vector<GridTrack>&); | 103 typedef LayoutUnit (RenderGrid::* SizingFunction)(LayoutBox&, GridTrackSizin
gDirection, Vector<GridTrack>&); |
104 typedef const LayoutUnit& (GridTrack::* AccumulatorGetter)() const; | 104 typedef const LayoutUnit& (GridTrack::* AccumulatorGetter)() const; |
105 typedef bool (GridTrackSize::* FilterFunction)() const; | 105 typedef bool (GridTrackSize::* FilterFunction)() const; |
106 void resolveContentBasedTrackSizingFunctionsForNonSpanningItems(GridTrackSiz
ingDirection, const GridCoordinate&, RenderBox& gridItem, GridTrack&, Vector<Gri
dTrack>& columnTracks); | 106 void resolveContentBasedTrackSizingFunctionsForNonSpanningItems(GridTrackSiz
ingDirection, const GridCoordinate&, LayoutBox& gridItem, GridTrack&, Vector<Gri
dTrack>& columnTracks); |
107 void resolveContentBasedTrackSizingFunctionsForItems(GridTrackSizingDirectio
n, GridSizingData&, GridItemWithSpan&, FilterFunction, SizingFunction, Accumulat
orGetter, AccumulatorGrowFunction, FilterFunction growAboveMaxBreadthFilterFunct
ion = nullptr); | 107 void resolveContentBasedTrackSizingFunctionsForItems(GridTrackSizingDirectio
n, GridSizingData&, GridItemWithSpan&, FilterFunction, SizingFunction, Accumulat
orGetter, AccumulatorGrowFunction, FilterFunction growAboveMaxBreadthFilterFunct
ion = nullptr); |
108 void distributeSpaceToTracks(Vector<GridTrack*>&, const Vector<GridTrack*>*
growBeyondGrowthLimitsTracks, AccumulatorGetter, AccumulatorGrowFunction, GridSi
zingData&, LayoutUnit& availableLogicalSpace); | 108 void distributeSpaceToTracks(Vector<GridTrack*>&, const Vector<GridTrack*>*
growBeyondGrowthLimitsTracks, AccumulatorGetter, AccumulatorGrowFunction, GridSi
zingData&, LayoutUnit& availableLogicalSpace); |
109 | 109 |
110 double computeNormalizedFractionBreadth(Vector<GridTrack>&, const GridSpan&
tracksSpan, GridTrackSizingDirection, LayoutUnit availableLogicalSpace) const; | 110 double computeNormalizedFractionBreadth(Vector<GridTrack>&, const GridSpan&
tracksSpan, GridTrackSizingDirection, LayoutUnit availableLogicalSpace) const; |
111 | 111 |
112 GridTrackSize gridTrackSize(GridTrackSizingDirection, size_t) const; | 112 GridTrackSize gridTrackSize(GridTrackSizingDirection, size_t) const; |
113 | 113 |
114 LayoutUnit logicalHeightForChild(RenderBox&, Vector<GridTrack>&); | 114 LayoutUnit logicalHeightForChild(LayoutBox&, Vector<GridTrack>&); |
115 LayoutUnit minContentForChild(RenderBox&, GridTrackSizingDirection, Vector<G
ridTrack>& columnTracks); | 115 LayoutUnit minContentForChild(LayoutBox&, GridTrackSizingDirection, Vector<G
ridTrack>& columnTracks); |
116 LayoutUnit maxContentForChild(RenderBox&, GridTrackSizingDirection, Vector<G
ridTrack>& columnTracks); | 116 LayoutUnit maxContentForChild(LayoutBox&, GridTrackSizingDirection, Vector<G
ridTrack>& columnTracks); |
117 LayoutUnit startOfColumnForChild(const RenderBox& child) const; | 117 LayoutUnit startOfColumnForChild(const LayoutBox& child) const; |
118 LayoutUnit endOfColumnForChild(const RenderBox& child) const; | 118 LayoutUnit endOfColumnForChild(const LayoutBox& child) const; |
119 LayoutUnit columnPositionLeft(const RenderBox&) const; | 119 LayoutUnit columnPositionLeft(const LayoutBox&) const; |
120 LayoutUnit columnPositionRight(const RenderBox&) const; | 120 LayoutUnit columnPositionRight(const LayoutBox&) const; |
121 LayoutUnit centeredColumnPositionForChild(const RenderBox&) const; | 121 LayoutUnit centeredColumnPositionForChild(const LayoutBox&) const; |
122 LayoutUnit columnPositionForChild(const RenderBox&) const; | 122 LayoutUnit columnPositionForChild(const LayoutBox&) const; |
123 LayoutUnit startOfRowForChild(const RenderBox& child) const; | 123 LayoutUnit startOfRowForChild(const LayoutBox& child) const; |
124 LayoutUnit endOfRowForChild(const RenderBox& child) const; | 124 LayoutUnit endOfRowForChild(const LayoutBox& child) const; |
125 LayoutUnit centeredRowPositionForChild(const RenderBox&) const; | 125 LayoutUnit centeredRowPositionForChild(const LayoutBox&) const; |
126 LayoutUnit rowPositionForChild(const RenderBox&) const; | 126 LayoutUnit rowPositionForChild(const LayoutBox&) const; |
127 LayoutUnit contentPositionAndDistributionColumnOffset(LayoutUnit availableFr
eeSpace, ContentPosition, ContentDistributionType, OverflowAlignment, unsigned n
umberOfItems) const; | 127 LayoutUnit contentPositionAndDistributionColumnOffset(LayoutUnit availableFr
eeSpace, ContentPosition, ContentDistributionType, OverflowAlignment, unsigned n
umberOfItems) const; |
128 LayoutUnit contentPositionAndDistributionRowOffset(LayoutUnit availableFreeS
pace, ContentPosition, ContentDistributionType, OverflowAlignment, unsigned numb
erOfItems) const; | 128 LayoutUnit contentPositionAndDistributionRowOffset(LayoutUnit availableFreeS
pace, ContentPosition, ContentDistributionType, OverflowAlignment, unsigned numb
erOfItems) const; |
129 LayoutPoint findChildLogicalPosition(const RenderBox&, LayoutSize contentAli
gnmentOffset) const; | 129 LayoutPoint findChildLogicalPosition(const LayoutBox&, LayoutSize contentAli
gnmentOffset) const; |
130 GridCoordinate cachedGridCoordinate(const RenderBox&) const; | 130 GridCoordinate cachedGridCoordinate(const LayoutBox&) const; |
131 | 131 |
132 LayoutUnit gridAreaBreadthForChild(const RenderBox& child, GridTrackSizingDi
rection, const Vector<GridTrack>&) const; | 132 LayoutUnit gridAreaBreadthForChild(const LayoutBox& child, GridTrackSizingDi
rection, const Vector<GridTrack>&) const; |
133 | 133 |
134 virtual void paintChildren(const PaintInfo&, const LayoutPoint&) override; | 134 virtual void paintChildren(const PaintInfo&, const LayoutPoint&) override; |
135 bool allowedToStretchLogicalHeightForChild(const RenderBox& child) const; | 135 bool allowedToStretchLogicalHeightForChild(const LayoutBox& child) const; |
136 bool needToStretchChildLogicalHeight(const RenderBox&) const; | 136 bool needToStretchChildLogicalHeight(const LayoutBox&) const; |
137 LayoutUnit childIntrinsicHeight(const RenderBox&) const; | 137 LayoutUnit childIntrinsicHeight(const LayoutBox&) const; |
138 LayoutUnit childIntrinsicWidth(const RenderBox&) const; | 138 LayoutUnit childIntrinsicWidth(const LayoutBox&) const; |
139 LayoutUnit intrinsicLogicalHeightForChild(const RenderBox&) const; | 139 LayoutUnit intrinsicLogicalHeightForChild(const LayoutBox&) const; |
140 LayoutUnit marginLogicalHeightForChild(const RenderBox&) const; | 140 LayoutUnit marginLogicalHeightForChild(const LayoutBox&) const; |
141 LayoutUnit computeMarginLogicalHeightForChild(const RenderBox&) const; | 141 LayoutUnit computeMarginLogicalHeightForChild(const LayoutBox&) const; |
142 LayoutUnit availableAlignmentSpaceForChildBeforeStretching(LayoutUnit gridAr
eaBreadthForChild, const RenderBox&) const; | 142 LayoutUnit availableAlignmentSpaceForChildBeforeStretching(LayoutUnit gridAr
eaBreadthForChild, const LayoutBox&) const; |
143 void applyStretchAlignmentToChildIfNeeded(RenderBox&, LayoutUnit gridAreaBre
adthForChild); | 143 void applyStretchAlignmentToChildIfNeeded(LayoutBox&, LayoutUnit gridAreaBre
adthForChild); |
144 | 144 |
145 #if ENABLE(ASSERT) | 145 #if ENABLE(ASSERT) |
146 bool tracksAreWiderThanMinTrackBreadth(GridTrackSizingDirection, const Vecto
r<GridTrack>&); | 146 bool tracksAreWiderThanMinTrackBreadth(GridTrackSizingDirection, const Vecto
r<GridTrack>&); |
147 #endif | 147 #endif |
148 | 148 |
149 size_t gridItemSpan(const RenderBox&, GridTrackSizingDirection); | 149 size_t gridItemSpan(const LayoutBox&, GridTrackSizingDirection); |
150 bool spanningItemCrossesFlexibleSizedTracks(const GridCoordinate&, GridTrack
SizingDirection) const; | 150 bool spanningItemCrossesFlexibleSizedTracks(const GridCoordinate&, GridTrack
SizingDirection) const; |
151 | 151 |
152 size_t gridColumnCount() const | 152 size_t gridColumnCount() const |
153 { | 153 { |
154 ASSERT(!gridIsDirty()); | 154 ASSERT(!gridIsDirty()); |
155 return m_grid[0].size(); | 155 return m_grid[0].size(); |
156 } | 156 } |
157 size_t gridRowCount() const | 157 size_t gridRowCount() const |
158 { | 158 { |
159 ASSERT(!gridIsDirty()); | 159 ASSERT(!gridIsDirty()); |
160 return m_grid.size(); | 160 return m_grid.size(); |
161 } | 161 } |
162 | 162 |
163 bool hasDefiniteLogicalSize(GridTrackSizingDirection) const; | 163 bool hasDefiniteLogicalSize(GridTrackSizingDirection) const; |
164 | 164 |
165 typedef Vector<Vector<GridCell> > GridRepresentation; | 165 typedef Vector<Vector<GridCell> > GridRepresentation; |
166 GridRepresentation m_grid; | 166 GridRepresentation m_grid; |
167 bool m_gridIsDirty; | 167 bool m_gridIsDirty; |
168 Vector<LayoutUnit> m_rowPositions; | 168 Vector<LayoutUnit> m_rowPositions; |
169 Vector<LayoutUnit> m_columnPositions; | 169 Vector<LayoutUnit> m_columnPositions; |
170 HashMap<const RenderBox*, GridCoordinate> m_gridItemCoordinate; | 170 HashMap<const LayoutBox*, GridCoordinate> m_gridItemCoordinate; |
171 OrderIterator m_orderIterator; | 171 OrderIterator m_orderIterator; |
172 Vector<RenderBox*> m_gridItemsOverflowingGridArea; | 172 Vector<LayoutBox*> m_gridItemsOverflowingGridArea; |
173 HashMap<const RenderBox*, size_t> m_gridItemsIndexesMap; | 173 HashMap<const LayoutBox*, size_t> m_gridItemsIndexesMap; |
174 }; | 174 }; |
175 | 175 |
176 DEFINE_LAYOUT_OBJECT_TYPE_CASTS(RenderGrid, isRenderGrid()); | 176 DEFINE_LAYOUT_OBJECT_TYPE_CASTS(RenderGrid, isRenderGrid()); |
177 | 177 |
178 } // namespace blink | 178 } // namespace blink |
179 | 179 |
180 #endif // RenderGrid_h | 180 #endif // RenderGrid_h |
OLD | NEW |