Chromium Code Reviews| Index: third_party/WebKit/Source/core/layout/Grid.h |
| diff --git a/third_party/WebKit/Source/core/layout/Grid.h b/third_party/WebKit/Source/core/layout/Grid.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..d113f967970d7eaf4e18d9baea4da4d895c4592d |
| --- /dev/null |
| +++ b/third_party/WebKit/Source/core/layout/Grid.h |
| @@ -0,0 +1,124 @@ |
| +#ifndef Grid_h |
|
Manuel Rego
2017/01/30 11:00:45
I guess you miss the license header here. And in t
svillar
2017/01/30 11:28:28
Acknowledged.
|
| +#define Grid_h |
| + |
| +#include "core/layout/OrderIterator.h" |
| +#include "core/style/GridArea.h" |
| +#include "core/style/GridPositionsResolver.h" |
| +#include "wtf/Assertions.h" |
| +#include "wtf/ListHashSet.h" |
| +#include "wtf/Vector.h" |
| + |
| +namespace blink { |
| + |
| +typedef Vector<LayoutBox*, 1> GridCell; |
|
jfernandez
2017/01/30 08:48:48
Can those LayoutBox pointer be null ? Perhaps we c
svillar
2017/01/30 09:35:45
Right, but I guess we can do it in a follow up cha
Manuel Rego
2017/01/30 11:00:45
Then add a TODO so we don't forget about it. :-)
|
| +typedef Vector<Vector<GridCell>> GridAsMatrix; |
| +typedef ListHashSet<size_t> OrderedTrackIndexSet; |
| + |
| +class LayoutGrid; |
| + |
| +// TODO(svillar): move into this class once GridIterator is added. |
|
jfernandez
2017/01/30 08:48:48
I don't understand this comment.
svillar
2017/01/30 09:35:45
That's a legacy comment, I'll change it.
|
| +class Grid final { |
|
Manuel Rego
2017/01/30 11:00:45
Please add a brief comment explaining what's the p
|
| + public: |
| + Grid(const LayoutGrid*); |
|
jfernandez
2017/01/30 08:48:48
Could we use reference here ?
svillar
2017/01/30 09:35:45
I tried but it looks like we cannot because in com
|
| + |
| + size_t numTracks(GridTrackSizingDirection) const; |
| + |
| + void ensureGridSize(size_t maximumRowSize, size_t maximumColumnSize); |
| + void insert(LayoutBox&, const GridArea&); |
| + |
| + // Note that out of flow children are not grid items. |
| + bool hasGridItems() const { return !m_gridItemArea.isEmpty(); } |
| + |
| + bool hasAnyOrthogonalGridItem() const { return m_hasAnyOrthogonalGridItem; } |
| + void setHasAnyOrthogonalGridItem(bool); |
|
Manuel Rego
2017/01/30 11:00:45
This method could be implemented here, like the pr
svillar
2017/01/30 11:28:28
Nop because it'd break the rule of not having impl
|
| + |
| + GridArea gridItemArea(const LayoutBox& item) const; |
|
jfernandez
2017/01/30 08:48:48
We don't need the "item" arg name.
svillar
2017/01/30 09:35:45
Acknowledged.
|
| + void setGridItemArea(const LayoutBox& item, GridArea); |
|
jfernandez
2017/01/30 08:48:48
Ditto
|
| + |
| + GridSpan gridItemSpan(const LayoutBox&, GridTrackSizingDirection) const; |
| + |
| + size_t gridItemPaintOrder(const LayoutBox& item) const; |
| + void setGridItemPaintOrder(const LayoutBox& item, size_t order); |
| + |
| + const GridCell& cell(size_t row, size_t column) const { |
| + return m_grid[row][column]; |
| + } |
| + |
| + int smallestTrackStart(GridTrackSizingDirection) const; |
| + void setSmallestTracksStart(int rowStart, int columnStart); |
| + |
| + size_t autoRepeatTracks(GridTrackSizingDirection) const; |
| + void setAutoRepeatTracks(size_t autoRepeatRows, size_t autoRepeatColumns); |
| + |
| + typedef ListHashSet<size_t> OrderedTrackIndexSet; |
| + void setAutoRepeatEmptyColumns(std::unique_ptr<OrderedTrackIndexSet>); |
| + void setAutoRepeatEmptyRows(std::unique_ptr<OrderedTrackIndexSet>); |
| + |
| + size_t autoRepeatEmptyTracksCount(GridTrackSizingDirection) const; |
| + bool hasAutoRepeatEmptyTracks(GridTrackSizingDirection) const; |
| + bool isEmptyAutoRepeatTrack(GridTrackSizingDirection, size_t) const; |
| + |
| + OrderedTrackIndexSet* autoRepeatEmptyTracks(GridTrackSizingDirection) const; |
| + |
| + OrderIterator& orderIterator() { return m_orderIterator; } |
| + |
| + void setNeedsItemsPlacement(bool); |
| + bool needsItemsPlacement() const { return m_needsItemsPlacement; }; |
| + |
| +#if DCHECK_IS_ON() |
| + bool hasAnyGridItemPaintOrder() const; |
| +#endif |
| + |
| + private: |
| + friend class GridIterator; |
| + |
| + OrderIterator m_orderIterator; |
| + |
| + int m_smallestColumnStart{0}; |
| + int m_smallestRowStart{0}; |
| + |
| + size_t m_autoRepeatColumns{0}; |
| + size_t m_autoRepeatRows{0}; |
| + |
| + bool m_hasAnyOrthogonalGridItem{false}; |
| + bool m_needsItemsPlacement{true}; |
| + |
| + GridAsMatrix m_grid; |
| + |
| + HashMap<const LayoutBox*, GridArea> m_gridItemArea; |
| + HashMap<const LayoutBox*, size_t> m_gridItemsIndexesMap; |
|
jfernandez
2017/01/30 08:48:48
Ditton about LayoutBox pointers.
svillar
2017/01/30 09:35:45
Same comment here, perhaps for a followup change.
Manuel Rego
2017/01/30 11:00:45
I think for the HashMap we need pointers, but mayb
svillar
2017/01/30 11:28:28
Indeed, we cannot have references in the HashMap
|
| + |
| + std::unique_ptr<OrderedTrackIndexSet> m_autoRepeatEmptyColumns{nullptr}; |
| + std::unique_ptr<OrderedTrackIndexSet> m_autoRepeatEmptyRows{nullptr}; |
| +}; |
| + |
| +class GridIterator { |
| + WTF_MAKE_NONCOPYABLE(GridIterator); |
| + |
| + public: |
| + // |direction| is the direction that is fixed to |fixedTrackIndex| so e.g |
| + // GridIterator(m_grid, ForColumns, 1) will walk over the rows of the 2nd |
| + // column. |
| + GridIterator(const Grid&, |
| + GridTrackSizingDirection, |
| + size_t fixedTrackIndex, |
| + size_t varyingTrackIndex = 0); |
| + |
| + LayoutBox* nextGridItem(); |
| + |
| + bool checkEmptyCells(size_t rowSpan, size_t columnSpan) const; |
| + |
| + std::unique_ptr<GridArea> nextEmptyGridArea(size_t fixedTrackSpan, |
| + size_t varyingTrackSpan); |
| + |
| + private: |
| + const GridAsMatrix& m_grid; |
| + GridTrackSizingDirection m_direction; |
| + size_t m_rowIndex; |
| + size_t m_columnIndex; |
| + size_t m_childIndex; |
| +}; |
| + |
| +} // namespace blink |
| + |
| +#endif // Grid_h |