| 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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 SECURITY_DCHECK(!m_gridIsDirty); | 82 SECURITY_DCHECK(!m_gridIsDirty); |
| 83 return m_gridItemsOverflowingGridArea; | 83 return m_gridItemsOverflowingGridArea; |
| 84 } | 84 } |
| 85 | 85 |
| 86 int paintIndexForGridItem(const LayoutBox* layoutBox) const { | 86 int paintIndexForGridItem(const LayoutBox* layoutBox) const { |
| 87 SECURITY_DCHECK(!m_gridIsDirty); | 87 SECURITY_DCHECK(!m_gridIsDirty); |
| 88 return m_grid.gridItemPaintOrder(*layoutBox); | 88 return m_grid.gridItemPaintOrder(*layoutBox); |
| 89 } | 89 } |
| 90 | 90 |
| 91 size_t autoRepeatCountForDirection(GridTrackSizingDirection direction) const { | 91 size_t autoRepeatCountForDirection(GridTrackSizingDirection direction) const { |
| 92 return direction == ForColumns ? m_autoRepeatColumns : m_autoRepeatRows; | 92 return m_grid.autoRepeatTracks(direction); |
| 93 } | 93 } |
| 94 | 94 |
| 95 LayoutUnit translateRTLCoordinate(LayoutUnit) const; | 95 LayoutUnit translateRTLCoordinate(LayoutUnit) const; |
| 96 | 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, |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 void resolveContentBasedTrackSizingFunctions(GridTrackSizingDirection, | 139 void resolveContentBasedTrackSizingFunctions(GridTrackSizingDirection, |
| 140 GridSizingData&) const; | 140 GridSizingData&) const; |
| 141 | 141 |
| 142 size_t computeAutoRepeatTracksCount(GridTrackSizingDirection, | 142 size_t computeAutoRepeatTracksCount(GridTrackSizingDirection, |
| 143 SizingOperation) const; | 143 SizingOperation) const; |
| 144 | 144 |
| 145 typedef ListHashSet<size_t> OrderedTrackIndexSet; | 145 typedef ListHashSet<size_t> OrderedTrackIndexSet; |
| 146 std::unique_ptr<OrderedTrackIndexSet> computeEmptyTracksForAutoRepeat( | 146 std::unique_ptr<OrderedTrackIndexSet> computeEmptyTracksForAutoRepeat( |
| 147 GridTrackSizingDirection) const; | 147 GridTrackSizingDirection) const; |
| 148 | 148 |
| 149 bool hasAutoRepeatEmptyTracks(GridTrackSizingDirection) const; | |
| 150 bool isEmptyAutoRepeatTrack(GridTrackSizingDirection, | |
| 151 size_t lineNumber) const; | |
| 152 | |
| 153 void placeItemsOnGrid(SizingOperation); | 149 void placeItemsOnGrid(SizingOperation); |
| 154 void populateExplicitGridAndOrderIterator(); | 150 void populateExplicitGridAndOrderIterator(); |
| 155 std::unique_ptr<GridArea> createEmptyGridAreaAtSpecifiedPositionsOutsideGrid( | 151 std::unique_ptr<GridArea> createEmptyGridAreaAtSpecifiedPositionsOutsideGrid( |
| 156 const LayoutBox&, | 152 const LayoutBox&, |
| 157 GridTrackSizingDirection, | 153 GridTrackSizingDirection, |
| 158 const GridSpan& specifiedPositions) const; | 154 const GridSpan& specifiedPositions) const; |
| 159 void placeSpecifiedMajorAxisItemsOnGrid(const Vector<LayoutBox*>&); | 155 void placeSpecifiedMajorAxisItemsOnGrid(const Vector<LayoutBox*>&); |
| 160 void placeAutoMajorAxisItemsOnGrid(const Vector<LayoutBox*>&); | 156 void placeAutoMajorAxisItemsOnGrid(const Vector<LayoutBox*>&); |
| 161 void placeAutoMajorAxisItemOnGrid( | 157 void placeAutoMajorAxisItemOnGrid( |
| 162 LayoutBox&, | 158 LayoutBox&, |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 324 LayoutUnit guttersSize(GridTrackSizingDirection, | 320 LayoutUnit guttersSize(GridTrackSizingDirection, |
| 325 size_t startLine, | 321 size_t startLine, |
| 326 size_t span, | 322 size_t span, |
| 327 SizingOperation) const; | 323 SizingOperation) const; |
| 328 | 324 |
| 329 size_t gridItemSpan(const LayoutBox&, GridTrackSizingDirection); | 325 size_t gridItemSpan(const LayoutBox&, GridTrackSizingDirection); |
| 330 bool spanningItemCrossesFlexibleSizedTracks(const GridSpan&, | 326 bool spanningItemCrossesFlexibleSizedTracks(const GridSpan&, |
| 331 GridTrackSizingDirection, | 327 GridTrackSizingDirection, |
| 332 SizingOperation) const; | 328 SizingOperation) const; |
| 333 | 329 |
| 334 size_t gridColumnCount() const; | |
| 335 size_t gridRowCount() const; | |
| 336 | |
| 337 bool isOrthogonalChild(const LayoutBox&) const; | 330 bool isOrthogonalChild(const LayoutBox&) const; |
| 338 GridTrackSizingDirection flowAwareDirectionForChild( | 331 GridTrackSizingDirection flowAwareDirectionForChild( |
| 339 const LayoutBox&, | 332 const LayoutBox&, |
| 340 GridTrackSizingDirection) const; | 333 GridTrackSizingDirection) const; |
| 341 | 334 |
| 342 bool cachedHasDefiniteLogicalHeight() const; | 335 bool cachedHasDefiniteLogicalHeight() const; |
| 343 | 336 |
| 344 size_t numTracks(GridTrackSizingDirection) const; | 337 size_t numTracks(GridTrackSizingDirection) const; |
| 345 | 338 |
| 346 // TODO(svillar): move into this class once GridIterator is added. | 339 // TODO(svillar): move into this class once GridIterator is added. |
| 347 typedef Vector<Vector<GridCell>> GridAsMatrix; | 340 typedef Vector<Vector<GridCell>> GridAsMatrix; |
| 348 class Grid final { | 341 class Grid final { |
| 349 public: | 342 public: |
| 350 Grid() {} | 343 Grid(LayoutGrid* grid) : m_orderIterator(grid) {} |
| 351 | 344 |
| 352 size_t numColumns() const { return m_grid.size() ? m_grid[0].size() : 0; } | 345 size_t numTracks(GridTrackSizingDirection) const; |
| 353 size_t numRows() const { return m_grid.size(); } | |
| 354 | 346 |
| 355 void ensureGridSize(size_t maximumRowSize, size_t maximumColumnSize); | 347 void ensureGridSize(size_t maximumRowSize, size_t maximumColumnSize); |
| 356 void insert(LayoutBox&, const GridArea&, bool isOrthogonalChild); | 348 void insert(LayoutBox&, const GridArea&, bool isOrthogonalChild); |
| 357 | 349 |
| 358 bool hasInFlowGridItems() const { return !m_gridItemArea.isEmpty(); } | 350 bool hasInFlowGridItems() const { return !m_gridItemArea.isEmpty(); } |
| 359 bool hasAnyOrthogonalChildren() const { return m_hasAnyOrthogonalChildren; } | 351 bool hasAnyOrthogonalChildren() const { return m_hasAnyOrthogonalChildren; } |
| 360 | 352 |
| 361 GridArea gridItemArea(const LayoutBox& item) const; | 353 GridArea gridItemArea(const LayoutBox& item) const; |
| 362 void setGridItemArea(const LayoutBox& item, GridArea); | 354 void setGridItemArea(const LayoutBox& item, GridArea); |
| 363 | 355 |
| 356 GridSpan gridItemSpan(const LayoutBox&, GridTrackSizingDirection) const; |
| 357 |
| 364 size_t gridItemPaintOrder(const LayoutBox& item) const; | 358 size_t gridItemPaintOrder(const LayoutBox& item) const; |
| 365 void setGridItemPaintOrder(const LayoutBox& item, size_t order); | 359 void setGridItemPaintOrder(const LayoutBox& item, size_t order); |
| 366 | 360 |
| 367 const GridCell& cell(size_t row, size_t column) const { | 361 const GridCell& cell(size_t row, size_t column) const { |
| 368 return m_grid[row][column]; | 362 return m_grid[row][column]; |
| 369 } | 363 } |
| 370 | 364 |
| 371 int smallestTrackStart(GridTrackSizingDirection) const; | 365 int smallestTrackStart(GridTrackSizingDirection) const; |
| 372 void setSmallestTracksStart(int rowStart, int columnStart); | 366 void setSmallestTracksStart(int rowStart, int columnStart); |
| 373 | 367 |
| 368 size_t autoRepeatTracks(GridTrackSizingDirection) const; |
| 369 void setAutoRepeatTracks(size_t autoRepeatRows, size_t autoRepeatColumns); |
| 370 |
| 371 void setAutoRepeatEmptyColumns(std::unique_ptr<OrderedTrackIndexSet>); |
| 372 void setAutoRepeatEmptyRows(std::unique_ptr<OrderedTrackIndexSet>); |
| 373 |
| 374 size_t autoRepeatEmptyTracksCount(GridTrackSizingDirection) const; |
| 375 bool hasAutoRepeatEmptyTracks(GridTrackSizingDirection) const; |
| 376 bool isEmptyAutoRepeatTrack(GridTrackSizingDirection, size_t) const; |
| 377 |
| 378 OrderedTrackIndexSet* autoRepeatEmptyTracks(GridTrackSizingDirection) const; |
| 379 |
| 380 OrderIterator& orderIterator() { return m_orderIterator; } |
| 381 |
| 374 void shrinkToFit() { m_grid.shrinkToFit(); } | 382 void shrinkToFit() { m_grid.shrinkToFit(); } |
| 375 void clear(); | 383 void clear(); |
| 376 | 384 |
| 377 #if ENABLE(ASSERT) | 385 #if ENABLE(ASSERT) |
| 378 bool hasAnyGridItemPaintOrder() const; | 386 bool hasAnyGridItemPaintOrder() const; |
| 379 #endif | 387 #endif |
| 380 | 388 |
| 381 private: | 389 private: |
| 382 friend class GridIterator; | 390 friend class GridIterator; |
| 383 | 391 |
| 392 OrderIterator m_orderIterator; |
| 393 |
| 384 int m_smallestColumnStart{0}; | 394 int m_smallestColumnStart{0}; |
| 385 int m_smallestRowStart{0}; | 395 int m_smallestRowStart{0}; |
| 386 | 396 |
| 397 size_t m_autoRepeatColumns{0}; |
| 398 size_t m_autoRepeatRows{0}; |
| 399 |
| 387 bool m_hasAnyOrthogonalChildren{false}; | 400 bool m_hasAnyOrthogonalChildren{false}; |
| 388 GridAsMatrix m_grid; | 401 GridAsMatrix m_grid; |
| 389 | 402 |
| 390 HashMap<const LayoutBox*, GridArea> m_gridItemArea; | 403 HashMap<const LayoutBox*, GridArea> m_gridItemArea; |
| 391 HashMap<const LayoutBox*, size_t> m_gridItemsIndexesMap; | 404 HashMap<const LayoutBox*, size_t> m_gridItemsIndexesMap; |
| 405 |
| 406 std::unique_ptr<OrderedTrackIndexSet> m_autoRepeatEmptyColumns{nullptr}; |
| 407 std::unique_ptr<OrderedTrackIndexSet> m_autoRepeatEmptyRows{nullptr}; |
| 392 }; | 408 }; |
| 393 Grid m_grid; | 409 Grid m_grid; |
| 394 | 410 |
| 395 bool m_gridIsDirty; | 411 bool m_gridIsDirty; |
| 396 Vector<LayoutUnit> m_rowPositions; | 412 Vector<LayoutUnit> m_rowPositions; |
| 397 Vector<LayoutUnit> m_columnPositions; | 413 Vector<LayoutUnit> m_columnPositions; |
| 398 LayoutUnit m_offsetBetweenColumns; | 414 LayoutUnit m_offsetBetweenColumns; |
| 399 LayoutUnit m_offsetBetweenRows; | 415 LayoutUnit m_offsetBetweenRows; |
| 400 OrderIterator m_orderIterator; | |
| 401 Vector<LayoutBox*> m_gridItemsOverflowingGridArea; | 416 Vector<LayoutBox*> m_gridItemsOverflowingGridArea; |
| 402 | 417 |
| 403 LayoutUnit m_minContentHeight{-1}; | 418 LayoutUnit m_minContentHeight{-1}; |
| 404 LayoutUnit m_maxContentHeight{-1}; | 419 LayoutUnit m_maxContentHeight{-1}; |
| 405 | 420 |
| 406 size_t m_autoRepeatColumns{0}; | |
| 407 size_t m_autoRepeatRows{0}; | |
| 408 | |
| 409 std::unique_ptr<OrderedTrackIndexSet> m_autoRepeatEmptyColumns{nullptr}; | |
| 410 std::unique_ptr<OrderedTrackIndexSet> m_autoRepeatEmptyRows{nullptr}; | |
| 411 | |
| 412 Optional<bool> m_hasDefiniteLogicalHeight; | 421 Optional<bool> m_hasDefiniteLogicalHeight; |
| 413 }; | 422 }; |
| 414 | 423 |
| 415 DEFINE_LAYOUT_OBJECT_TYPE_CASTS(LayoutGrid, isLayoutGrid()); | 424 DEFINE_LAYOUT_OBJECT_TYPE_CASTS(LayoutGrid, isLayoutGrid()); |
| 416 | 425 |
| 417 } // namespace blink | 426 } // namespace blink |
| 418 | 427 |
| 419 #endif // LayoutGrid_h | 428 #endif // LayoutGrid_h |
| OLD | NEW |