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

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

Issue 2522503002: [css-grid] Convert GridRepresentation into an actual class (Closed)
Patch Set: Pach for landing. Rebased Created 4 years 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
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/layout/LayoutGrid.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
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 size_t computeAutoRepeatTracksCount(GridTrackSizingDirection, 142 size_t computeAutoRepeatTracksCount(GridTrackSizingDirection,
146 SizingOperation) const; 143 SizingOperation) const;
147 144
148 typedef ListHashSet<size_t> OrderedTrackIndexSet; 145 typedef ListHashSet<size_t> OrderedTrackIndexSet;
149 std::unique_ptr<OrderedTrackIndexSet> computeEmptyTracksForAutoRepeat( 146 std::unique_ptr<OrderedTrackIndexSet> computeEmptyTracksForAutoRepeat(
150 GridTrackSizingDirection) const; 147 GridTrackSizingDirection) const;
151 148
152 bool hasAutoRepeatEmptyTracks(GridTrackSizingDirection) const; 149 bool hasAutoRepeatEmptyTracks(GridTrackSizingDirection) const;
153 bool isEmptyAutoRepeatTrack(GridTrackSizingDirection, 150 bool isEmptyAutoRepeatTrack(GridTrackSizingDirection,
154 size_t lineNumber) const; 151 size_t lineNumber) const;
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 336
340 bool isOrthogonalChild(const LayoutBox&) const; 337 bool isOrthogonalChild(const LayoutBox&) const;
341 GridTrackSizingDirection flowAwareDirectionForChild( 338 GridTrackSizingDirection flowAwareDirectionForChild(
342 const LayoutBox&, 339 const LayoutBox&,
343 GridTrackSizingDirection) const; 340 GridTrackSizingDirection) const;
344 341
345 bool cachedHasDefiniteLogicalHeight() const; 342 bool cachedHasDefiniteLogicalHeight() const;
346 343
347 size_t numTracks(GridTrackSizingDirection) const; 344 size_t numTracks(GridTrackSizingDirection) const;
348 345
349 typedef Vector<Vector<GridCell>> GridRepresentation; 346 // TODO(svillar): move into this class once GridIterator is added.
350 GridRepresentation m_grid; 347 typedef Vector<Vector<GridCell>> GridAsMatrix;
348 class Grid final {
349 public:
350 Grid() {}
351
352 size_t numColumns() const { return m_grid.size() ? m_grid[0].size() : 0; }
353 size_t numRows() const { return m_grid.size(); }
354
355 void ensureGridSize(size_t maximumRowSize, size_t maximumColumnSize);
356 void insert(LayoutBox&, const GridArea&);
357
358 const GridCell& cell(size_t row, size_t column) const {
359 return m_grid[row][column];
360 }
361
362 void shrinkToFit() { m_grid.shrinkToFit(); }
363
364 void clear();
365
366 private:
367 friend class GridIterator;
368 GridAsMatrix m_grid;
369 };
370 Grid m_grid;
371
351 bool m_gridIsDirty; 372 bool m_gridIsDirty;
352 Vector<LayoutUnit> m_rowPositions; 373 Vector<LayoutUnit> m_rowPositions;
353 Vector<LayoutUnit> m_columnPositions; 374 Vector<LayoutUnit> m_columnPositions;
354 LayoutUnit m_offsetBetweenColumns; 375 LayoutUnit m_offsetBetweenColumns;
355 LayoutUnit m_offsetBetweenRows; 376 LayoutUnit m_offsetBetweenRows;
356 HashMap<const LayoutBox*, GridArea> m_gridItemArea; 377 HashMap<const LayoutBox*, GridArea> m_gridItemArea;
357 OrderIterator m_orderIterator; 378 OrderIterator m_orderIterator;
358 Vector<LayoutBox*> m_gridItemsOverflowingGridArea; 379 Vector<LayoutBox*> m_gridItemsOverflowingGridArea;
359 HashMap<const LayoutBox*, size_t> m_gridItemsIndexesMap; 380 HashMap<const LayoutBox*, size_t> m_gridItemsIndexesMap;
360 381
(...skipping 12 matching lines...) Expand all
373 std::unique_ptr<OrderedTrackIndexSet> m_autoRepeatEmptyRows{nullptr}; 394 std::unique_ptr<OrderedTrackIndexSet> m_autoRepeatEmptyRows{nullptr};
374 395
375 Optional<bool> m_hasDefiniteLogicalHeight; 396 Optional<bool> m_hasDefiniteLogicalHeight;
376 }; 397 };
377 398
378 DEFINE_LAYOUT_OBJECT_TYPE_CASTS(LayoutGrid, isLayoutGrid()); 399 DEFINE_LAYOUT_OBJECT_TYPE_CASTS(LayoutGrid, isLayoutGrid());
379 400
380 } // namespace blink 401 } // namespace blink
381 402
382 #endif // LayoutGrid_h 403 #endif // LayoutGrid_h
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/layout/LayoutGrid.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698