Chromium Code Reviews| 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 |
| 11 * documentation and/or other materials provided with the distribution. | 11 * documentation and/or other materials provided with the distribution. |
| 12 * | 12 * |
| 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY | 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY |
| 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
| 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR | 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR |
| 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
| 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
| 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
| 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
| 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 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 LayoutGrid_h | 26 #ifndef LayoutGrid_h |
| 27 #define LayoutGrid_h | 27 #define LayoutGrid_h |
| 28 | 28 |
| 29 #include "core/layout/Grid.h" | |
| 30 #include "core/layout/GridTrackSizingAlgorithm.h" | |
| 29 #include "core/layout/LayoutBlock.h" | 31 #include "core/layout/LayoutBlock.h" |
| 30 #include "core/layout/OrderIterator.h" | 32 #include "core/layout/OrderIterator.h" |
| 31 #include "core/style/GridPositionsResolver.h" | 33 #include "core/style/GridPositionsResolver.h" |
| 32 #include <memory> | 34 #include <memory> |
| 33 | 35 |
| 34 namespace blink { | 36 namespace blink { |
| 35 | 37 |
| 36 struct ContentAlignmentData; | 38 struct ContentAlignmentData; |
| 37 struct GridArea; | 39 struct GridArea; |
| 38 struct GridSpan; | 40 struct GridSpan; |
| 39 class GridTrack; | |
| 40 | 41 |
| 41 enum TrackSizeComputationPhase { | |
| 42 ResolveIntrinsicMinimums, | |
| 43 ResolveContentBasedMinimums, | |
| 44 ResolveMaxContentMinimums, | |
| 45 ResolveIntrinsicMaximums, | |
| 46 ResolveMaxContentMaximums, | |
| 47 MaximizeTracks, | |
| 48 }; | |
| 49 enum GridAxisPosition { GridAxisStart, GridAxisEnd, GridAxisCenter }; | 42 enum GridAxisPosition { GridAxisStart, GridAxisEnd, GridAxisCenter }; |
| 50 | 43 |
| 51 class LayoutGrid final : public LayoutBlock { | 44 class LayoutGrid final : public LayoutBlock { |
| 52 public: | 45 public: |
| 53 explicit LayoutGrid(Element*); | 46 explicit LayoutGrid(Element*); |
| 54 ~LayoutGrid() override; | 47 ~LayoutGrid() override; |
| 55 | 48 |
| 56 static LayoutGrid* createAnonymous(Document*); | 49 static LayoutGrid* createAnonymous(Document*); |
| 57 const char* name() const override { return "LayoutGrid"; } | 50 const char* name() const override { return "LayoutGrid"; } |
| 58 | 51 |
| 59 void layoutBlock(bool relayoutChildren) override; | 52 void layoutBlock(bool relayoutChildren) override; |
| 60 | 53 |
| 61 void dirtyGrid(); | 54 void dirtyGrid(); |
| 62 | 55 |
| 63 Vector<LayoutUnit> trackSizesForComputedStyle(GridTrackSizingDirection) const; | 56 Vector<LayoutUnit> trackSizesForComputedStyle(GridTrackSizingDirection) const; |
| 64 | 57 |
| 65 const Vector<LayoutUnit>& columnPositions() const { | 58 const Vector<LayoutUnit>& columnPositions() const { |
| 66 DCHECK(!m_grid.needsItemsPlacement()); | 59 DCHECK(!m_grid.needsItemsPlacement()); |
| 67 return m_columnPositions; | 60 return m_columnPositions; |
| 68 } | 61 } |
| 69 | 62 |
| 70 const Vector<LayoutUnit>& rowPositions() const { | 63 const Vector<LayoutUnit>& rowPositions() const { |
| 71 DCHECK(!m_grid.needsItemsPlacement()); | 64 DCHECK(!m_grid.needsItemsPlacement()); |
| 72 return m_rowPositions; | 65 return m_rowPositions; |
| 73 } | 66 } |
| 74 | 67 |
| 75 typedef Vector<LayoutBox*, 1> GridCell; | |
| 76 const GridCell& gridCell(int row, int column) const { | 68 const GridCell& gridCell(int row, int column) const { |
| 77 SECURITY_DCHECK(!m_grid.needsItemsPlacement()); | 69 SECURITY_DCHECK(!m_grid.needsItemsPlacement()); |
| 78 return m_grid.cell(row, column); | 70 return m_grid.cell(row, column); |
| 79 } | 71 } |
| 80 | 72 |
| 81 const Vector<LayoutBox*>& itemsOverflowingGridArea() const { | 73 const Vector<LayoutBox*>& itemsOverflowingGridArea() const { |
| 82 SECURITY_DCHECK(!m_grid.needsItemsPlacement()); | 74 SECURITY_DCHECK(!m_grid.needsItemsPlacement()); |
| 83 return m_gridItemsOverflowingGridArea; | 75 return m_gridItemsOverflowingGridArea; |
| 84 } | 76 } |
| 85 | 77 |
| 86 int paintIndexForGridItem(const LayoutBox* layoutBox) const { | 78 int paintIndexForGridItem(const LayoutBox* layoutBox) const { |
| 87 SECURITY_DCHECK(!m_grid.needsItemsPlacement()); | 79 SECURITY_DCHECK(!m_grid.needsItemsPlacement()); |
| 88 return m_grid.gridItemPaintOrder(*layoutBox); | 80 return m_grid.gridItemPaintOrder(*layoutBox); |
| 89 } | 81 } |
| 90 | 82 |
| 91 size_t autoRepeatCountForDirection(GridTrackSizingDirection direction) const { | 83 size_t autoRepeatCountForDirection(GridTrackSizingDirection direction) const { |
| 92 return m_grid.autoRepeatTracks(direction); | 84 return m_grid.autoRepeatTracks(direction); |
| 93 } | 85 } |
| 94 | 86 |
| 95 LayoutUnit translateRTLCoordinate(LayoutUnit) const; | 87 LayoutUnit translateRTLCoordinate(LayoutUnit) const; |
| 96 | 88 |
| 89 // TODO(ALGO): temporarily making these public. | |
|
Manuel Rego
2017/01/30 11:00:46
Again, use "svillar", also "T" should be a capital
| |
| 90 LayoutUnit guttersSize(const Grid&, | |
| 91 GridTrackSizingDirection, | |
| 92 size_t startLine, | |
| 93 size_t span, | |
| 94 SizingOperation) const; | |
| 95 bool cachedHasDefiniteLogicalHeight() const; | |
| 96 | |
| 97 private: | 97 private: |
| 98 bool isOfType(LayoutObjectType type) const override { | 98 bool isOfType(LayoutObjectType type) const override { |
| 99 return type == LayoutObjectLayoutGrid || LayoutBlock::isOfType(type); | 99 return type == LayoutObjectLayoutGrid || LayoutBlock::isOfType(type); |
| 100 } | 100 } |
| 101 void computeIntrinsicLogicalWidths( | 101 void computeIntrinsicLogicalWidths( |
| 102 LayoutUnit& minLogicalWidth, | 102 LayoutUnit& minLogicalWidth, |
| 103 LayoutUnit& maxLogicalWidth) const override; | 103 LayoutUnit& maxLogicalWidth) const override; |
| 104 | 104 |
| 105 LayoutUnit computeIntrinsicLogicalContentHeightUsing( | 105 LayoutUnit computeIntrinsicLogicalContentHeightUsing( |
| 106 const Length& logicalHeightLength, | 106 const Length& logicalHeightLength, |
| 107 LayoutUnit intrinsicContentHeight, | 107 LayoutUnit intrinsicContentHeight, |
| 108 LayoutUnit borderAndPadding) const override; | 108 LayoutUnit borderAndPadding) const override; |
| 109 | 109 |
| 110 void addChild(LayoutObject* newChild, | 110 void addChild(LayoutObject* newChild, |
| 111 LayoutObject* beforeChild = nullptr) override; | 111 LayoutObject* beforeChild = nullptr) override; |
| 112 void removeChild(LayoutObject*) override; | 112 void removeChild(LayoutObject*) override; |
| 113 | 113 |
| 114 void styleDidChange(StyleDifference, const ComputedStyle*) override; | 114 void styleDidChange(StyleDifference, const ComputedStyle*) override; |
| 115 | 115 |
| 116 bool explicitGridDidResize(const ComputedStyle&) const; | 116 bool explicitGridDidResize(const ComputedStyle&) const; |
| 117 bool namedGridLinesDefinitionDidChange(const ComputedStyle&) const; | 117 bool namedGridLinesDefinitionDidChange(const ComputedStyle&) const; |
| 118 | 118 |
| 119 class Grid; | |
| 120 class GridIterator; | |
| 121 struct GridSizingData; | |
| 122 enum SizingOperation { TrackSizing, IntrinsicSizeComputation }; | |
| 123 void computeUsedBreadthOfGridTracks( | |
| 124 GridTrackSizingDirection, | |
| 125 GridSizingData&, | |
| 126 LayoutUnit& baseSizesWithoutMaximization, | |
| 127 LayoutUnit& growthLimitsWithoutMaximization) const; | |
| 128 void computeFlexSizedTracksGrowth( | |
| 129 GridTrackSizingDirection, | |
| 130 Vector<GridTrack>&, | |
| 131 const Vector<size_t>& flexibleSizedTracksIndex, | |
| 132 double flexFraction, | |
| 133 Vector<LayoutUnit>& increments, | |
| 134 LayoutUnit& totalGrowth, | |
| 135 const GridSizingData&) const; | |
| 136 LayoutUnit computeUsedBreadthOfMinLength(const GridTrackSize&, | |
| 137 LayoutUnit maxBreadth) const; | |
| 138 LayoutUnit computeUsedBreadthOfMaxLength(const GridTrackSize&, | |
| 139 LayoutUnit usedBreadth, | |
| 140 LayoutUnit maxBreadth) const; | |
| 141 void resolveContentBasedTrackSizingFunctions(GridTrackSizingDirection, | |
| 142 GridSizingData&) const; | |
| 143 | |
| 144 size_t computeAutoRepeatTracksCount(GridTrackSizingDirection, | 119 size_t computeAutoRepeatTracksCount(GridTrackSizingDirection, |
| 145 SizingOperation) const; | 120 SizingOperation) const; |
| 146 | 121 |
| 147 typedef ListHashSet<size_t> OrderedTrackIndexSet; | |
| 148 std::unique_ptr<OrderedTrackIndexSet> computeEmptyTracksForAutoRepeat( | 122 std::unique_ptr<OrderedTrackIndexSet> computeEmptyTracksForAutoRepeat( |
| 149 Grid&, | 123 Grid&, |
| 150 GridTrackSizingDirection) const; | 124 GridTrackSizingDirection) const; |
| 151 | 125 |
| 152 void placeItemsOnGrid(Grid&, SizingOperation) const; | 126 void placeItemsOnGrid(Grid&, SizingOperation) const; |
| 153 void populateExplicitGridAndOrderIterator(Grid&) const; | 127 void populateExplicitGridAndOrderIterator(Grid&) const; |
| 154 std::unique_ptr<GridArea> createEmptyGridAreaAtSpecifiedPositionsOutsideGrid( | 128 std::unique_ptr<GridArea> createEmptyGridAreaAtSpecifiedPositionsOutsideGrid( |
| 155 const Grid&, | 129 const Grid&, |
| 156 const LayoutBox&, | 130 const LayoutBox&, |
| 157 GridTrackSizingDirection, | 131 GridTrackSizingDirection, |
| 158 const GridSpan& specifiedPositions) const; | 132 const GridSpan& specifiedPositions) const; |
| 159 void placeSpecifiedMajorAxisItemsOnGrid(Grid&, | 133 void placeSpecifiedMajorAxisItemsOnGrid(Grid&, |
| 160 const Vector<LayoutBox*>&) const; | 134 const Vector<LayoutBox*>&) const; |
| 161 void placeAutoMajorAxisItemsOnGrid(Grid&, const Vector<LayoutBox*>&) const; | 135 void placeAutoMajorAxisItemsOnGrid(Grid&, const Vector<LayoutBox*>&) const; |
| 162 void placeAutoMajorAxisItemOnGrid( | 136 void placeAutoMajorAxisItemOnGrid( |
| 163 Grid&, | 137 Grid&, |
| 164 LayoutBox&, | 138 LayoutBox&, |
| 165 std::pair<size_t, size_t>& autoPlacementCursor) const; | 139 std::pair<size_t, size_t>& autoPlacementCursor) const; |
| 166 GridTrackSizingDirection autoPlacementMajorAxisDirection() const; | 140 GridTrackSizingDirection autoPlacementMajorAxisDirection() const; |
| 167 GridTrackSizingDirection autoPlacementMinorAxisDirection() const; | 141 GridTrackSizingDirection autoPlacementMinorAxisDirection() const; |
| 168 | 142 |
| 169 void computeTrackSizesForIndefiniteSize(GridTrackSizingDirection, | 143 void computeTrackSizesForIndefiniteSize(GridTrackSizingAlgorithm&, |
| 170 GridSizingData&, | 144 GridTrackSizingDirection, |
| 145 Grid&, | |
| 171 LayoutUnit& minIntrinsicSize, | 146 LayoutUnit& minIntrinsicSize, |
| 172 LayoutUnit& maxIntrinsicSize) const; | 147 LayoutUnit& maxIntrinsicSize) const; |
| 173 LayoutUnit computeTrackBasedLogicalHeight(const GridSizingData&) const; | 148 LayoutUnit computeTrackBasedLogicalHeight() const; |
| 174 void computeTrackSizesForDefiniteSize(GridTrackSizingDirection, | 149 void computeTrackSizesForDefiniteSize(GridTrackSizingDirection, |
| 175 GridSizingData&, | 150 LayoutUnit freeSpace); |
| 176 LayoutUnit freeSpace) const; | |
| 177 | 151 |
| 178 void repeatTracksSizingIfNeeded(GridSizingData&, | 152 void repeatTracksSizingIfNeeded(LayoutUnit availableSpaceForColumns, |
| 179 LayoutUnit availableSpaceForColumns, | |
| 180 LayoutUnit availableSpaceForRows); | 153 LayoutUnit availableSpaceForRows); |
| 181 | 154 |
| 182 void layoutGridItems(GridSizingData&); | 155 void layoutGridItems(); |
| 183 void prepareChildForPositionedLayout(LayoutBox&); | 156 void prepareChildForPositionedLayout(LayoutBox&); |
| 184 void layoutPositionedObjects( | 157 void layoutPositionedObjects( |
| 185 bool relayoutChildren, | 158 bool relayoutChildren, |
| 186 PositionedLayoutBehavior = DefaultLayout) override; | 159 PositionedLayoutBehavior = DefaultLayout) override; |
| 187 void offsetAndBreadthForPositionedChild(const LayoutBox&, | 160 void offsetAndBreadthForPositionedChild(const LayoutBox&, |
| 188 GridTrackSizingDirection, | 161 GridTrackSizingDirection, |
| 189 LayoutUnit& offset, | 162 LayoutUnit& offset, |
| 190 LayoutUnit& breadth); | 163 LayoutUnit& breadth); |
| 191 void populateGridPositionsForDirection(GridSizingData&, | 164 void populateGridPositionsForDirection(GridTrackSizingDirection); |
| 192 GridTrackSizingDirection); | |
| 193 | 165 |
| 194 typedef struct GridItemsSpanGroupRange GridItemsSpanGroupRange; | |
| 195 LayoutUnit currentItemSizeForTrackSizeComputationPhase( | |
| 196 TrackSizeComputationPhase, | |
| 197 LayoutBox&, | |
| 198 GridTrackSizingDirection, | |
| 199 GridSizingData&) const; | |
| 200 void resolveContentBasedTrackSizingFunctionsForNonSpanningItems( | |
| 201 GridTrackSizingDirection, | |
| 202 const GridSpan&, | |
| 203 LayoutBox& gridItem, | |
| 204 GridTrack&, | |
| 205 GridSizingData&) const; | |
| 206 template <TrackSizeComputationPhase> | |
| 207 void resolveContentBasedTrackSizingFunctionsForItems( | |
| 208 GridTrackSizingDirection, | |
| 209 GridSizingData&, | |
| 210 const GridItemsSpanGroupRange&) const; | |
| 211 template <TrackSizeComputationPhase> | |
| 212 void distributeSpaceToTracks(Vector<GridTrack*>&, | |
| 213 Vector<GridTrack*>* growBeyondGrowthLimitsTracks, | |
| 214 GridSizingData&, | |
| 215 LayoutUnit& availableLogicalSpace) const; | |
| 216 | |
| 217 typedef HashSet<size_t, | |
| 218 DefaultHash<size_t>::Hash, | |
| 219 WTF::UnsignedWithZeroKeyHashTraits<size_t>> | |
| 220 TrackIndexSet; | |
| 221 double computeFlexFactorUnitSize( | |
| 222 const Vector<GridTrack>&, | |
| 223 GridTrackSizingDirection, | |
| 224 double flexFactorSum, | |
| 225 LayoutUnit& leftOverSpace, | |
| 226 const Vector<size_t, 8>& flexibleTracksIndexes, | |
| 227 const GridSizingData&, | |
| 228 std::unique_ptr<TrackIndexSet> tracksToTreatAsInflexible = nullptr) const; | |
| 229 double findFlexFactorUnitSize(const Vector<GridTrack>&, | |
| 230 const GridSpan&, | |
| 231 GridTrackSizingDirection, | |
| 232 LayoutUnit leftOverSpace, | |
| 233 const GridSizingData&) const; | |
| 234 | |
| 235 const GridTrackSize& rawGridTrackSize(GridTrackSizingDirection, | |
| 236 size_t, | |
| 237 const GridSizingData&) const; | |
| 238 GridTrackSize gridTrackSize(GridTrackSizingDirection, | |
| 239 size_t, | |
| 240 const GridSizingData&) const; | |
| 241 | |
| 242 bool updateOverrideContainingBlockContentSizeForChild( | |
| 243 LayoutBox&, | |
| 244 GridTrackSizingDirection, | |
| 245 GridSizingData&) const; | |
| 246 LayoutUnit logicalHeightForChild(LayoutBox&, GridSizingData&) const; | |
| 247 LayoutUnit minSizeForChild(LayoutBox&, | |
| 248 GridTrackSizingDirection, | |
| 249 GridSizingData&) const; | |
| 250 LayoutUnit minContentForChild(LayoutBox&, | |
| 251 GridTrackSizingDirection, | |
| 252 GridSizingData&) const; | |
| 253 LayoutUnit maxContentForChild(LayoutBox&, | |
| 254 GridTrackSizingDirection, | |
| 255 GridSizingData&) const; | |
| 256 GridAxisPosition columnAxisPositionForChild(const LayoutBox&) const; | 166 GridAxisPosition columnAxisPositionForChild(const LayoutBox&) const; |
| 257 GridAxisPosition rowAxisPositionForChild(const LayoutBox&) const; | 167 GridAxisPosition rowAxisPositionForChild(const LayoutBox&) const; |
| 258 LayoutUnit rowAxisOffsetForChild(const LayoutBox&, GridSizingData&) const; | 168 LayoutUnit rowAxisOffsetForChild(const LayoutBox&) const; |
| 259 LayoutUnit columnAxisOffsetForChild(const LayoutBox&, GridSizingData&) const; | 169 LayoutUnit columnAxisOffsetForChild(const LayoutBox&) const; |
| 260 ContentAlignmentData computeContentPositionAndDistributionOffset( | 170 ContentAlignmentData computeContentPositionAndDistributionOffset( |
| 261 GridTrackSizingDirection, | 171 GridTrackSizingDirection, |
| 262 const LayoutUnit& availableFreeSpace, | 172 const LayoutUnit& availableFreeSpace, |
| 263 unsigned numberOfGridTracks) const; | 173 unsigned numberOfGridTracks) const; |
| 264 LayoutPoint gridAreaLogicalPosition(const GridArea&) const; | 174 LayoutPoint gridAreaLogicalPosition(const GridArea&) const; |
| 265 LayoutPoint findChildLogicalPosition(const LayoutBox&, GridSizingData&) const; | 175 LayoutPoint findChildLogicalPosition(const LayoutBox&) const; |
| 266 GridArea cachedGridArea(const LayoutBox&) const; | |
| 267 GridSpan cachedGridSpan(const LayoutBox&, GridTrackSizingDirection) const; | |
| 268 | 176 |
| 269 LayoutUnit gridAreaBreadthForChild(const LayoutBox& child, | |
| 270 GridTrackSizingDirection, | |
| 271 const GridSizingData&) const; | |
| 272 LayoutUnit gridAreaBreadthForChildIncludingAlignmentOffsets( | 177 LayoutUnit gridAreaBreadthForChildIncludingAlignmentOffsets( |
| 273 const LayoutBox&, | 178 const LayoutBox&, |
| 274 GridTrackSizingDirection, | 179 GridTrackSizingDirection) const; |
| 275 const GridSizingData&) const; | |
| 276 LayoutUnit assumedRowsSizeForOrthogonalChild(const LayoutBox&, | |
| 277 const GridSizingData&) const; | |
| 278 | 180 |
| 279 void applyStretchAlignmentToTracksIfNeeded(GridTrackSizingDirection, | 181 void applyStretchAlignmentToTracksIfNeeded(GridTrackSizingDirection); |
| 280 GridSizingData&); | |
| 281 | 182 |
| 282 void paintChildren(const PaintInfo&, const LayoutPoint&) const override; | 183 void paintChildren(const PaintInfo&, const LayoutPoint&) const override; |
| 283 | 184 |
| 284 LayoutUnit marginLogicalHeightForChild(const LayoutBox&) const; | 185 LayoutUnit marginLogicalHeightForChild(const LayoutBox&) const; |
| 285 LayoutUnit computeMarginLogicalSizeForChild(MarginDirection, | 186 LayoutUnit computeMarginLogicalSizeForChild(MarginDirection, |
| 286 const LayoutBox&) const; | 187 const LayoutBox&) const; |
| 287 LayoutUnit availableAlignmentSpaceForChildBeforeStretching( | 188 LayoutUnit availableAlignmentSpaceForChildBeforeStretching( |
| 288 LayoutUnit gridAreaBreadthForChild, | 189 LayoutUnit gridAreaBreadthForChild, |
| 289 const LayoutBox&) const; | 190 const LayoutBox&) const; |
| 290 StyleSelfAlignmentData justifySelfForChild(const LayoutBox&) const; | 191 StyleSelfAlignmentData justifySelfForChild(const LayoutBox&) const; |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 313 | 214 |
| 314 int baselinePosition( | 215 int baselinePosition( |
| 315 FontBaseline, | 216 FontBaseline, |
| 316 bool firstLine, | 217 bool firstLine, |
| 317 LineDirectionMode, | 218 LineDirectionMode, |
| 318 LinePositionMode = PositionOnContainingLine) const override; | 219 LinePositionMode = PositionOnContainingLine) const override; |
| 319 int firstLineBoxBaseline() const override; | 220 int firstLineBoxBaseline() const override; |
| 320 int inlineBlockBaseline(LineDirectionMode) const override; | 221 int inlineBlockBaseline(LineDirectionMode) const override; |
| 321 bool isInlineBaselineAlignedChild(const LayoutBox* child) const; | 222 bool isInlineBaselineAlignedChild(const LayoutBox* child) const; |
| 322 | 223 |
| 323 #if DCHECK_IS_ON() | |
| 324 bool tracksAreWiderThanMinTrackBreadth(GridTrackSizingDirection, | |
| 325 GridSizingData&) const; | |
| 326 #endif | |
| 327 | |
| 328 LayoutUnit gridGapForDirection(GridTrackSizingDirection, | 224 LayoutUnit gridGapForDirection(GridTrackSizingDirection, |
| 329 SizingOperation) const; | 225 SizingOperation) const; |
| 330 LayoutUnit guttersSize(const Grid&, | |
| 331 GridTrackSizingDirection, | |
| 332 size_t startLine, | |
| 333 size_t span, | |
| 334 SizingOperation) const; | |
| 335 | 226 |
| 336 size_t gridItemSpan(const LayoutBox&, GridTrackSizingDirection); | 227 size_t gridItemSpan(const LayoutBox&, GridTrackSizingDirection); |
| 337 bool spanningItemCrossesFlexibleSizedTracks(const GridSpan&, | |
| 338 GridTrackSizingDirection, | |
| 339 const GridSizingData&) const; | |
| 340 | 228 |
| 341 bool isOrthogonalChild(const LayoutBox&) const; | 229 bool isOrthogonalChild(const LayoutBox&) const; |
| 342 GridTrackSizingDirection flowAwareDirectionForChild( | 230 GridTrackSizingDirection flowAwareDirectionForChild( |
| 343 const LayoutBox&, | 231 const LayoutBox&, |
| 344 GridTrackSizingDirection) const; | 232 GridTrackSizingDirection) const; |
| 345 | 233 |
| 346 bool cachedHasDefiniteLogicalHeight() const; | |
| 347 | |
| 348 size_t numTracks(GridTrackSizingDirection, const Grid&) const; | 234 size_t numTracks(GridTrackSizingDirection, const Grid&) const; |
| 349 | 235 |
| 350 // TODO(svillar): move into this class once GridIterator is added. | |
| 351 typedef Vector<Vector<GridCell>> GridAsMatrix; | |
| 352 class Grid final { | |
| 353 public: | |
| 354 Grid(const LayoutGrid* grid) : m_orderIterator(grid) {} | |
| 355 | |
| 356 size_t numTracks(GridTrackSizingDirection) const; | |
| 357 | |
| 358 void ensureGridSize(size_t maximumRowSize, size_t maximumColumnSize); | |
| 359 void insert(LayoutBox&, const GridArea&); | |
| 360 | |
| 361 // Note that out of flow children are not grid items. | |
| 362 bool hasGridItems() const { return !m_gridItemArea.isEmpty(); } | |
| 363 | |
| 364 // TODO(svillar): move this to SizingData once it's passed to | |
| 365 // placeItemsOnGrid. | |
| 366 bool hasAnyOrthogonalGridItem() const { return m_hasAnyOrthogonalGridItem; } | |
| 367 void setHasAnyOrthogonalGridItem(bool); | |
| 368 | |
| 369 GridArea gridItemArea(const LayoutBox& item) const; | |
| 370 void setGridItemArea(const LayoutBox& item, GridArea); | |
| 371 | |
| 372 GridSpan gridItemSpan(const LayoutBox&, GridTrackSizingDirection) const; | |
| 373 | |
| 374 size_t gridItemPaintOrder(const LayoutBox& item) const; | |
| 375 void setGridItemPaintOrder(const LayoutBox& item, size_t order); | |
| 376 | |
| 377 const GridCell& cell(size_t row, size_t column) const { | |
| 378 return m_grid[row][column]; | |
| 379 } | |
| 380 | |
| 381 int smallestTrackStart(GridTrackSizingDirection) const; | |
| 382 void setSmallestTracksStart(int rowStart, int columnStart); | |
| 383 | |
| 384 size_t autoRepeatTracks(GridTrackSizingDirection) const; | |
| 385 void setAutoRepeatTracks(size_t autoRepeatRows, size_t autoRepeatColumns); | |
| 386 | |
| 387 void setAutoRepeatEmptyColumns(std::unique_ptr<OrderedTrackIndexSet>); | |
| 388 void setAutoRepeatEmptyRows(std::unique_ptr<OrderedTrackIndexSet>); | |
| 389 | |
| 390 size_t autoRepeatEmptyTracksCount(GridTrackSizingDirection) const; | |
| 391 bool hasAutoRepeatEmptyTracks(GridTrackSizingDirection) const; | |
| 392 bool isEmptyAutoRepeatTrack(GridTrackSizingDirection, size_t) const; | |
| 393 | |
| 394 OrderedTrackIndexSet* autoRepeatEmptyTracks(GridTrackSizingDirection) const; | |
| 395 | |
| 396 OrderIterator& orderIterator() { return m_orderIterator; } | |
| 397 | |
| 398 void setNeedsItemsPlacement(bool); | |
| 399 bool needsItemsPlacement() const { return m_needsItemsPlacement; }; | |
| 400 | |
| 401 #if DCHECK_IS_ON() | |
| 402 bool hasAnyGridItemPaintOrder() const; | |
| 403 #endif | |
| 404 | |
| 405 private: | |
| 406 friend class GridIterator; | |
| 407 | |
| 408 OrderIterator m_orderIterator; | |
| 409 | |
| 410 int m_smallestColumnStart{0}; | |
| 411 int m_smallestRowStart{0}; | |
| 412 | |
| 413 size_t m_autoRepeatColumns{0}; | |
| 414 size_t m_autoRepeatRows{0}; | |
| 415 | |
| 416 bool m_hasAnyOrthogonalGridItem{false}; | |
| 417 bool m_needsItemsPlacement{true}; | |
| 418 | |
| 419 GridAsMatrix m_grid; | |
| 420 | |
| 421 HashMap<const LayoutBox*, GridArea> m_gridItemArea; | |
| 422 HashMap<const LayoutBox*, size_t> m_gridItemsIndexesMap; | |
| 423 | |
| 424 std::unique_ptr<OrderedTrackIndexSet> m_autoRepeatEmptyColumns{nullptr}; | |
| 425 std::unique_ptr<OrderedTrackIndexSet> m_autoRepeatEmptyRows{nullptr}; | |
| 426 }; | |
| 427 Grid m_grid; | 236 Grid m_grid; |
| 237 GridTrackSizingAlgorithm m_trackSizingAlgorithm; | |
| 428 | 238 |
| 429 Vector<LayoutUnit> m_rowPositions; | 239 Vector<LayoutUnit> m_rowPositions; |
| 430 Vector<LayoutUnit> m_columnPositions; | 240 Vector<LayoutUnit> m_columnPositions; |
| 431 LayoutUnit m_offsetBetweenColumns; | 241 LayoutUnit m_offsetBetweenColumns; |
| 432 LayoutUnit m_offsetBetweenRows; | 242 LayoutUnit m_offsetBetweenRows; |
| 433 Vector<LayoutBox*> m_gridItemsOverflowingGridArea; | 243 Vector<LayoutBox*> m_gridItemsOverflowingGridArea; |
| 434 | 244 |
| 435 LayoutUnit m_minContentHeight{-1}; | 245 LayoutUnit m_minContentHeight{-1}; |
| 436 LayoutUnit m_maxContentHeight{-1}; | 246 LayoutUnit m_maxContentHeight{-1}; |
| 437 | 247 |
| 438 Optional<bool> m_hasDefiniteLogicalHeight; | 248 Optional<bool> m_hasDefiniteLogicalHeight; |
| 439 }; | 249 }; |
| 440 | 250 |
| 441 DEFINE_LAYOUT_OBJECT_TYPE_CASTS(LayoutGrid, isLayoutGrid()); | 251 DEFINE_LAYOUT_OBJECT_TYPE_CASTS(LayoutGrid, isLayoutGrid()); |
| 442 | 252 |
| 443 } // namespace blink | 253 } // namespace blink |
| 444 | 254 |
| 445 #endif // LayoutGrid_h | 255 #endif // LayoutGrid_h |
| OLD | NEW |