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

Side by Side Diff: third_party/WebKit/Source/core/layout/LayoutGrid.h

Issue 1317643005: [css-grid] Fix track sizing algo w/ size restrictions and intrinsic sizes (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Patch for landing. Removed unused params Created 5 years, 1 month 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 /* 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 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 int paintIndexForGridItem(const LayoutBox* layoutBox) const 90 int paintIndexForGridItem(const LayoutBox* layoutBox) const
91 { 91 {
92 ASSERT_WITH_SECURITY_IMPLICATION(!m_gridIsDirty); 92 ASSERT_WITH_SECURITY_IMPLICATION(!m_gridIsDirty);
93 return m_gridItemsIndexesMap.get(layoutBox); 93 return m_gridItemsIndexesMap.get(layoutBox);
94 } 94 }
95 95
96 private: 96 private:
97 bool isOfType(LayoutObjectType type) const override { return type == LayoutO bjectLayoutGrid || LayoutBlock::isOfType(type); } 97 bool isOfType(LayoutObjectType type) const override { return type == LayoutO bjectLayoutGrid || LayoutBlock::isOfType(type); }
98 void computeIntrinsicLogicalWidths(LayoutUnit& minLogicalWidth, LayoutUnit& maxLogicalWidth) const override; 98 void computeIntrinsicLogicalWidths(LayoutUnit& minLogicalWidth, LayoutUnit& maxLogicalWidth) const override;
99 99
100 LayoutUnit computeIntrinsicLogicalContentHeightUsing(const Length& logicalHe ightLength, LayoutUnit intrinsicContentHeight, LayoutUnit borderAndPadding) cons t override;
101
100 void addChild(LayoutObject* newChild, LayoutObject* beforeChild = nullptr) o verride; 102 void addChild(LayoutObject* newChild, LayoutObject* beforeChild = nullptr) o verride;
101 void removeChild(LayoutObject*) override; 103 void removeChild(LayoutObject*) override;
102 104
103 void styleDidChange(StyleDifference, const ComputedStyle*) override; 105 void styleDidChange(StyleDifference, const ComputedStyle*) override;
104 106
105 bool explicitGridDidResize(const ComputedStyle&) const; 107 bool explicitGridDidResize(const ComputedStyle&) const;
106 bool namedGridLinesDefinitionDidChange(const ComputedStyle&) const; 108 bool namedGridLinesDefinitionDidChange(const ComputedStyle&) const;
107 109
108 class GridIterator; 110 class GridIterator;
109 struct GridSizingData; 111 struct GridSizingData;
110 bool gridElementIsShrinkToFit(); 112 void computeUsedBreadthOfGridTracks(GridTrackSizingDirection, GridSizingData &, LayoutUnit& baseSizesWithoutMaximization, LayoutUnit& growthLimitsWithoutMaxi mization);
111 void computeUsedBreadthOfGridTracks(GridTrackSizingDirection, GridSizingData &);
112 LayoutUnit computeUsedBreadthOfMinLength(const GridLength&, LayoutUnit maxBr eadth) const; 113 LayoutUnit computeUsedBreadthOfMinLength(const GridLength&, LayoutUnit maxBr eadth) const;
113 LayoutUnit computeUsedBreadthOfMaxLength(const GridLength&, LayoutUnit usedB readth, LayoutUnit maxBreadth) const; 114 LayoutUnit computeUsedBreadthOfMaxLength(const GridLength&, LayoutUnit usedB readth, LayoutUnit maxBreadth) const;
114 void resolveContentBasedTrackSizingFunctions(GridTrackSizingDirection, GridS izingData&); 115 void resolveContentBasedTrackSizingFunctions(GridTrackSizingDirection, GridS izingData&);
115 116
116 void ensureGridSize(size_t maximumRowIndex, size_t maximumColumnIndex); 117 void ensureGridSize(size_t maximumRowIndex, size_t maximumColumnIndex);
117 void insertItemIntoGrid(LayoutBox&, const GridCoordinate&); 118 void insertItemIntoGrid(LayoutBox&, const GridCoordinate&);
118 void placeItemsOnGrid(); 119 void placeItemsOnGrid();
119 void populateExplicitGridAndOrderIterator(); 120 void populateExplicitGridAndOrderIterator();
120 PassOwnPtr<GridCoordinate> createEmptyGridAreaAtSpecifiedPositionsOutsideGri d(const LayoutBox&, GridTrackSizingDirection, const GridSpan& specifiedPositions ) const; 121 PassOwnPtr<GridCoordinate> createEmptyGridAreaAtSpecifiedPositionsOutsideGri d(const LayoutBox&, GridTrackSizingDirection, const GridSpan& specifiedPositions ) const;
121 void placeSpecifiedMajorAxisItemsOnGrid(const Vector<LayoutBox*>&); 122 void placeSpecifiedMajorAxisItemsOnGrid(const Vector<LayoutBox*>&);
122 void placeAutoMajorAxisItemsOnGrid(const Vector<LayoutBox*>&); 123 void placeAutoMajorAxisItemsOnGrid(const Vector<LayoutBox*>&);
123 void placeAutoMajorAxisItemOnGrid(LayoutBox&, std::pair<size_t, size_t>& aut oPlacementCursor); 124 void placeAutoMajorAxisItemOnGrid(LayoutBox&, std::pair<size_t, size_t>& aut oPlacementCursor);
124 GridTrackSizingDirection autoPlacementMajorAxisDirection() const; 125 GridTrackSizingDirection autoPlacementMajorAxisDirection() const;
125 GridTrackSizingDirection autoPlacementMinorAxisDirection() const; 126 GridTrackSizingDirection autoPlacementMinorAxisDirection() const;
126 127
127 void layoutGridItems(); 128 void computeIntrinsicLogicalHeight(GridSizingData&);
129 LayoutUnit computeTrackBasedLogicalHeight(const GridSizingData&) const;
130 void computeTrackSizesForDirection(GridTrackSizingDirection, GridSizingData& , LayoutUnit freeSpace);
131
132 void layoutGridItems(GridSizingData&);
128 void prepareChildForPositionedLayout(LayoutBox&); 133 void prepareChildForPositionedLayout(LayoutBox&);
129 void layoutPositionedObjects(bool relayoutChildren, PositionedLayoutBehavior = DefaultLayout); 134 void layoutPositionedObjects(bool relayoutChildren, PositionedLayoutBehavior = DefaultLayout);
130 void offsetAndBreadthForPositionedChild(const LayoutBox&, GridTrackSizingDir ection, LayoutUnit& offset, LayoutUnit& breadth); 135 void offsetAndBreadthForPositionedChild(const LayoutBox&, GridTrackSizingDir ection, LayoutUnit& offset, LayoutUnit& breadth);
131 void populateGridPositions(GridSizingData&); 136 void populateGridPositions(GridSizingData&);
132 137
133 typedef struct GridItemsSpanGroupRange GridItemsSpanGroupRange; 138 typedef struct GridItemsSpanGroupRange GridItemsSpanGroupRange;
134 LayoutUnit currentItemSizeForTrackSizeComputationPhase(TrackSizeComputationP hase, LayoutBox&, GridTrackSizingDirection, Vector<GridTrack>& columnTracks); 139 LayoutUnit currentItemSizeForTrackSizeComputationPhase(TrackSizeComputationP hase, LayoutBox&, GridTrackSizingDirection, Vector<GridTrack>& columnTracks);
135 void resolveContentBasedTrackSizingFunctionsForNonSpanningItems(GridTrackSiz ingDirection, const GridCoordinate&, LayoutBox& gridItem, GridTrack&, Vector<Gri dTrack>& columnTracks); 140 void resolveContentBasedTrackSizingFunctionsForNonSpanningItems(GridTrackSiz ingDirection, const GridCoordinate&, LayoutBox& gridItem, GridTrack&, Vector<Gri dTrack>& columnTracks);
136 template <TrackSizeComputationPhase> void resolveContentBasedTrackSizingFunc tionsForItems(GridTrackSizingDirection, GridSizingData&, const GridItemsSpanGrou pRange&); 141 template <TrackSizeComputationPhase> void resolveContentBasedTrackSizingFunc tionsForItems(GridTrackSizingDirection, GridSizingData&, const GridItemsSpanGrou pRange&);
137 template <TrackSizeComputationPhase> void distributeSpaceToTracks(Vector<Gri dTrack*>&, const Vector<GridTrack*>* growBeyondGrowthLimitsTracks, GridSizingDat a&, LayoutUnit& availableLogicalSpace); 142 template <TrackSizeComputationPhase> void distributeSpaceToTracks(Vector<Gri dTrack*>&, const Vector<GridTrack*>* growBeyondGrowthLimitsTracks, GridSizingDat a&, LayoutUnit& availableLogicalSpace);
(...skipping 30 matching lines...) Expand all
168 LayoutUnit marginLogicalHeightForChild(const LayoutBox&) const; 173 LayoutUnit marginLogicalHeightForChild(const LayoutBox&) const;
169 LayoutUnit computeMarginLogicalHeightForChild(const LayoutBox&) const; 174 LayoutUnit computeMarginLogicalHeightForChild(const LayoutBox&) const;
170 LayoutUnit availableAlignmentSpaceForChildBeforeStretching(LayoutUnit gridAr eaBreadthForChild, const LayoutBox&) const; 175 LayoutUnit availableAlignmentSpaceForChildBeforeStretching(LayoutUnit gridAr eaBreadthForChild, const LayoutBox&) const;
171 void applyStretchAlignmentToChildIfNeeded(LayoutBox&); 176 void applyStretchAlignmentToChildIfNeeded(LayoutBox&);
172 bool hasAutoMarginsInColumnAxis(const LayoutBox&) const; 177 bool hasAutoMarginsInColumnAxis(const LayoutBox&) const;
173 bool hasAutoMarginsInRowAxis(const LayoutBox&) const; 178 bool hasAutoMarginsInRowAxis(const LayoutBox&) const;
174 void updateAutoMarginsInColumnAxisIfNeeded(LayoutBox&); 179 void updateAutoMarginsInColumnAxisIfNeeded(LayoutBox&);
175 void updateAutoMarginsInRowAxisIfNeeded(LayoutBox&); 180 void updateAutoMarginsInRowAxisIfNeeded(LayoutBox&);
176 181
177 #if ENABLE(ASSERT) 182 #if ENABLE(ASSERT)
178 bool tracksAreWiderThanMinTrackBreadth(GridTrackSizingDirection, const Vecto r<GridTrack>&); 183 bool tracksAreWiderThanMinTrackBreadth(GridTrackSizingDirection, GridSizingD ata&);
179 #endif 184 #endif
180 185
181 size_t gridItemSpan(const LayoutBox&, GridTrackSizingDirection); 186 size_t gridItemSpan(const LayoutBox&, GridTrackSizingDirection);
182 bool spanningItemCrossesFlexibleSizedTracks(const GridCoordinate&, GridTrack SizingDirection) const; 187 bool spanningItemCrossesFlexibleSizedTracks(const GridCoordinate&, GridTrack SizingDirection) const;
183 188
184 size_t gridColumnCount() const 189 size_t gridColumnCount() const
185 { 190 {
186 ASSERT(!m_gridIsDirty); 191 ASSERT(!m_gridIsDirty);
187 return m_grid[0].size(); 192 return m_grid[0].size();
188 } 193 }
189 size_t gridRowCount() const 194 size_t gridRowCount() const
190 { 195 {
191 ASSERT(!m_gridIsDirty); 196 ASSERT(!m_gridIsDirty);
192 return m_grid.size(); 197 return m_grid.size();
193 } 198 }
194 199
195 bool hasDefiniteLogicalSize(GridTrackSizingDirection) const; 200 bool hasDefiniteLogicalSize(GridTrackSizingDirection) const;
196 201
197 typedef Vector<Vector<GridCell>> GridRepresentation; 202 typedef Vector<Vector<GridCell>> GridRepresentation;
198 GridRepresentation m_grid; 203 GridRepresentation m_grid;
199 bool m_gridIsDirty; 204 bool m_gridIsDirty;
200 Vector<LayoutUnit> m_rowPositions; 205 Vector<LayoutUnit> m_rowPositions;
201 Vector<LayoutUnit> m_columnPositions; 206 Vector<LayoutUnit> m_columnPositions;
202 HashMap<const LayoutBox*, GridCoordinate> m_gridItemCoordinate; 207 HashMap<const LayoutBox*, GridCoordinate> m_gridItemCoordinate;
203 OrderIterator m_orderIterator; 208 OrderIterator m_orderIterator;
204 Vector<LayoutBox*> m_gridItemsOverflowingGridArea; 209 Vector<LayoutBox*> m_gridItemsOverflowingGridArea;
205 HashMap<const LayoutBox*, size_t> m_gridItemsIndexesMap; 210 HashMap<const LayoutBox*, size_t> m_gridItemsIndexesMap;
211
212 LayoutUnit m_minContentHeight { -1 };
213 LayoutUnit m_maxContentHeight { -1 };
206 }; 214 };
207 215
208 DEFINE_LAYOUT_OBJECT_TYPE_CASTS(LayoutGrid, isLayoutGrid()); 216 DEFINE_LAYOUT_OBJECT_TYPE_CASTS(LayoutGrid, isLayoutGrid());
209 217
210 } // namespace blink 218 } // namespace blink
211 219
212 #endif // LayoutGrid_h 220 #endif // LayoutGrid_h
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/layout/LayoutBox.h ('k') | third_party/WebKit/Source/core/layout/LayoutGrid.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698