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 |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 68 } | 68 } |
| 69 | 69 |
| 70 const Vector<LayoutUnit>& rowPositions() const { | 70 const Vector<LayoutUnit>& rowPositions() const { |
| 71 ASSERT(!m_gridIsDirty); | 71 ASSERT(!m_gridIsDirty); |
| 72 return m_rowPositions; | 72 return m_rowPositions; |
| 73 } | 73 } |
| 74 | 74 |
| 75 typedef Vector<LayoutBox*, 1> GridCell; | 75 typedef Vector<LayoutBox*, 1> GridCell; |
| 76 const GridCell& gridCell(int row, int column) const { | 76 const GridCell& gridCell(int row, int column) const { |
| 77 SECURITY_DCHECK(!m_gridIsDirty); | 77 SECURITY_DCHECK(!m_gridIsDirty); |
| 78 return m_grid[row][column]; | 78 return m_grid.cell(row, column); |
| 79 } | 79 } |
| 80 | 80 |
| 81 const Vector<LayoutBox*>& itemsOverflowingGridArea() const { | 81 const Vector<LayoutBox*>& itemsOverflowingGridArea() const { |
| 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_gridItemsIndexesMap.get(layoutBox); | 88 return m_gridItemsIndexesMap.get(layoutBox); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 132 Vector<LayoutUnit>& increments, | 132 Vector<LayoutUnit>& increments, |
| 133 LayoutUnit& totalGrowth) const; | 133 LayoutUnit& totalGrowth) const; |
| 134 LayoutUnit computeUsedBreadthOfMinLength(const GridTrackSize&, | 134 LayoutUnit computeUsedBreadthOfMinLength(const GridTrackSize&, |
| 135 LayoutUnit maxBreadth) const; | 135 LayoutUnit maxBreadth) const; |
| 136 LayoutUnit computeUsedBreadthOfMaxLength(const GridTrackSize&, | 136 LayoutUnit computeUsedBreadthOfMaxLength(const GridTrackSize&, |
| 137 LayoutUnit usedBreadth, | 137 LayoutUnit usedBreadth, |
| 138 LayoutUnit maxBreadth) const; | 138 LayoutUnit maxBreadth) const; |
| 139 void resolveContentBasedTrackSizingFunctions(GridTrackSizingDirection, | 139 void resolveContentBasedTrackSizingFunctions(GridTrackSizingDirection, |
| 140 GridSizingData&) const; | 140 GridSizingData&) const; |
| 141 | 141 |
| 142 void ensureGridSize(size_t maximumRowSize, size_t maximumColumnSize); | |
| 143 void insertItemIntoGrid(LayoutBox&, const GridArea&); | |
| 144 | |
| 145 void updateAutoRepeatTracksAndSetDirtyIfNeeded(SizingOperation); | 142 void updateAutoRepeatTracksAndSetDirtyIfNeeded(SizingOperation); |
| 146 size_t computeAutoRepeatTracksCount(GridTrackSizingDirection, | 143 size_t computeAutoRepeatTracksCount(GridTrackSizingDirection, |
| 147 SizingOperation) const; | 144 SizingOperation) const; |
| 148 | 145 |
| 149 typedef ListHashSet<size_t> OrderedTrackIndexSet; | 146 typedef ListHashSet<size_t> OrderedTrackIndexSet; |
| 150 std::unique_ptr<OrderedTrackIndexSet> computeEmptyTracksForAutoRepeat( | 147 std::unique_ptr<OrderedTrackIndexSet> computeEmptyTracksForAutoRepeat( |
| 151 GridTrackSizingDirection) const; | 148 GridTrackSizingDirection) const; |
| 152 | 149 |
| 153 bool hasAutoRepeatEmptyTracks(GridTrackSizingDirection) const; | 150 bool hasAutoRepeatEmptyTracks(GridTrackSizingDirection) const; |
| 154 bool isEmptyAutoRepeatTrack(GridTrackSizingDirection, | 151 bool isEmptyAutoRepeatTrack(GridTrackSizingDirection, |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 340 | 337 |
| 341 bool isOrthogonalChild(const LayoutBox&) const; | 338 bool isOrthogonalChild(const LayoutBox&) const; |
| 342 GridTrackSizingDirection flowAwareDirectionForChild( | 339 GridTrackSizingDirection flowAwareDirectionForChild( |
| 343 const LayoutBox&, | 340 const LayoutBox&, |
| 344 GridTrackSizingDirection) const; | 341 GridTrackSizingDirection) const; |
| 345 | 342 |
| 346 bool cachedHasDefiniteLogicalHeight() const; | 343 bool cachedHasDefiniteLogicalHeight() const; |
| 347 | 344 |
| 348 size_t numTracks(GridTrackSizingDirection) const; | 345 size_t numTracks(GridTrackSizingDirection) const; |
| 349 | 346 |
| 350 typedef Vector<Vector<GridCell>> GridRepresentation; | 347 // TODO(svillar): move into this class once GridIterator is added. |
| 351 GridRepresentation m_grid; | 348 typedef Vector<Vector<GridCell>> GridAsVector; |
|
Manuel Rego
2016/11/22 10:07:17
Or GridAsMatrix?
svillar
2016/11/22 10:15:18
If you don't feel strongly about it I'd prefer to
Manuel Rego
2016/11/22 10:38:01
I'd prefer to change it if possible.
| |
| 349 class Grid final { | |
| 350 public: | |
| 351 Grid() {} | |
| 352 | |
| 353 size_t numColumns() const { return m_grid.size() ? m_grid[0].size() : 0; } | |
| 354 size_t numRows() const { return m_grid.size(); } | |
| 355 | |
| 356 void ensureGridSize(size_t maximumRowSize, size_t maximumColumnSize); | |
| 357 void insert(LayoutBox&, const GridArea&); | |
| 358 | |
| 359 const GridCell& cell(size_t row, size_t column) const { | |
| 360 return m_grid[row][column]; | |
| 361 } | |
| 362 | |
| 363 void shrinkToFit() { m_grid.shrinkToFit(); } | |
| 364 | |
| 365 void clear(); | |
|
Manuel Rego
2016/11/22 10:07:17
Nit: Why this is not defined here?
It seems stran
svillar
2016/11/22 10:15:18
I don't think it's strange. Don't know if this is
Manuel Rego
2016/11/22 10:38:01
It's strange to me compared to shrinkToFit() for e
| |
| 366 | |
| 367 private: | |
| 368 friend class GridIterator; | |
| 369 GridAsVector m_grid; | |
|
Manuel Rego
2016/11/22 10:07:17
Nit: I think it's kind of confusing to have 2 "m_g
svillar
2016/11/22 10:15:18
I agree but it's a private method, so there should
Manuel Rego
2016/11/22 10:38:01
I know but still, when you see the LayoutGrid code
| |
| 370 }; | |
| 371 Grid m_grid; | |
| 372 | |
| 352 bool m_gridIsDirty; | 373 bool m_gridIsDirty; |
| 353 Vector<LayoutUnit> m_rowPositions; | 374 Vector<LayoutUnit> m_rowPositions; |
| 354 Vector<LayoutUnit> m_columnPositions; | 375 Vector<LayoutUnit> m_columnPositions; |
| 355 LayoutUnit m_offsetBetweenColumns; | 376 LayoutUnit m_offsetBetweenColumns; |
| 356 LayoutUnit m_offsetBetweenRows; | 377 LayoutUnit m_offsetBetweenRows; |
| 357 HashMap<const LayoutBox*, GridArea> m_gridItemArea; | 378 HashMap<const LayoutBox*, GridArea> m_gridItemArea; |
| 358 OrderIterator m_orderIterator; | 379 OrderIterator m_orderIterator; |
| 359 Vector<LayoutBox*> m_gridItemsOverflowingGridArea; | 380 Vector<LayoutBox*> m_gridItemsOverflowingGridArea; |
| 360 HashMap<const LayoutBox*, size_t> m_gridItemsIndexesMap; | 381 HashMap<const LayoutBox*, size_t> m_gridItemsIndexesMap; |
| 361 | 382 |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 374 std::unique_ptr<OrderedTrackIndexSet> m_autoRepeatEmptyRows{nullptr}; | 395 std::unique_ptr<OrderedTrackIndexSet> m_autoRepeatEmptyRows{nullptr}; |
| 375 | 396 |
| 376 Optional<bool> m_hasDefiniteLogicalHeight; | 397 Optional<bool> m_hasDefiniteLogicalHeight; |
| 377 }; | 398 }; |
| 378 | 399 |
| 379 DEFINE_LAYOUT_OBJECT_TYPE_CASTS(LayoutGrid, isLayoutGrid()); | 400 DEFINE_LAYOUT_OBJECT_TYPE_CASTS(LayoutGrid, isLayoutGrid()); |
| 380 | 401 |
| 381 } // namespace blink | 402 } // namespace blink |
| 382 | 403 |
| 383 #endif // LayoutGrid_h | 404 #endif // LayoutGrid_h |
| OLD | NEW |