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

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

Issue 2524963002: [css-grid] Move LayoutGrid attributes to Grid class (Closed)
Patch Set: Patch for landing v2 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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 return m_grid.cell(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_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 direction == ForColumns ? m_autoRepeatColumns : m_autoRepeatRows;
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 {
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
346 // TODO(svillar): move into this class once GridIterator is added. 346 // TODO(svillar): move into this class once GridIterator is added.
347 typedef Vector<Vector<GridCell>> GridAsMatrix; 347 typedef Vector<Vector<GridCell>> GridAsMatrix;
348 class Grid final { 348 class Grid final {
349 public: 349 public:
350 Grid() {} 350 Grid() {}
351 351
352 size_t numColumns() const { return m_grid.size() ? m_grid[0].size() : 0; } 352 size_t numColumns() const { return m_grid.size() ? m_grid[0].size() : 0; }
353 size_t numRows() const { return m_grid.size(); } 353 size_t numRows() const { return m_grid.size(); }
354 354
355 void ensureGridSize(size_t maximumRowSize, size_t maximumColumnSize); 355 void ensureGridSize(size_t maximumRowSize, size_t maximumColumnSize);
356 void insert(LayoutBox&, const GridArea&); 356 void insert(LayoutBox&, const GridArea&, bool isOrthogonalChild);
357
358 bool hasInFlowGridItems() const { return !m_gridItemArea.isEmpty(); }
359 bool hasAnyOrthogonalChildren() const { return m_hasAnyOrthogonalChildren; }
360
361 GridArea gridItemArea(const LayoutBox& item) const;
362 void setGridItemArea(const LayoutBox& item, GridArea);
363
364 size_t gridItemPaintOrder(const LayoutBox& item) const;
365 void setGridItemPaintOrder(const LayoutBox& item, size_t order);
357 366
358 const GridCell& cell(size_t row, size_t column) const { 367 const GridCell& cell(size_t row, size_t column) const {
359 return m_grid[row][column]; 368 return m_grid[row][column];
360 } 369 }
361 370
371 int smallestTrackStart(GridTrackSizingDirection) const;
372 void setSmallestTracksStart(int rowStart, int columnStart);
373
362 void shrinkToFit() { m_grid.shrinkToFit(); } 374 void shrinkToFit() { m_grid.shrinkToFit(); }
375 void clear();
363 376
364 void clear(); 377 #if ENABLE(ASSERT)
378 bool hasAnyGridItemPaintOrder() const;
379 #endif
365 380
366 private: 381 private:
367 friend class GridIterator; 382 friend class GridIterator;
383
384 int m_smallestColumnStart{0};
385 int m_smallestRowStart{0};
386
387 bool m_hasAnyOrthogonalChildren{false};
368 GridAsMatrix m_grid; 388 GridAsMatrix m_grid;
389
390 HashMap<const LayoutBox*, GridArea> m_gridItemArea;
391 HashMap<const LayoutBox*, size_t> m_gridItemsIndexesMap;
369 }; 392 };
370 Grid m_grid; 393 Grid m_grid;
371 394
372 bool m_gridIsDirty; 395 bool m_gridIsDirty;
373 Vector<LayoutUnit> m_rowPositions; 396 Vector<LayoutUnit> m_rowPositions;
374 Vector<LayoutUnit> m_columnPositions; 397 Vector<LayoutUnit> m_columnPositions;
375 LayoutUnit m_offsetBetweenColumns; 398 LayoutUnit m_offsetBetweenColumns;
376 LayoutUnit m_offsetBetweenRows; 399 LayoutUnit m_offsetBetweenRows;
377 HashMap<const LayoutBox*, GridArea> m_gridItemArea;
378 OrderIterator m_orderIterator; 400 OrderIterator m_orderIterator;
379 Vector<LayoutBox*> m_gridItemsOverflowingGridArea; 401 Vector<LayoutBox*> m_gridItemsOverflowingGridArea;
380 HashMap<const LayoutBox*, size_t> m_gridItemsIndexesMap;
381 402
382 LayoutUnit m_minContentHeight{-1}; 403 LayoutUnit m_minContentHeight{-1};
383 LayoutUnit m_maxContentHeight{-1}; 404 LayoutUnit m_maxContentHeight{-1};
384 405
385 int m_smallestRowStart;
386 int m_smallestColumnStart;
387
388 size_t m_autoRepeatColumns{0}; 406 size_t m_autoRepeatColumns{0};
389 size_t m_autoRepeatRows{0}; 407 size_t m_autoRepeatRows{0};
390 408
391 bool m_hasAnyOrthogonalChildren;
392
393 std::unique_ptr<OrderedTrackIndexSet> m_autoRepeatEmptyColumns{nullptr}; 409 std::unique_ptr<OrderedTrackIndexSet> m_autoRepeatEmptyColumns{nullptr};
394 std::unique_ptr<OrderedTrackIndexSet> m_autoRepeatEmptyRows{nullptr}; 410 std::unique_ptr<OrderedTrackIndexSet> m_autoRepeatEmptyRows{nullptr};
395 411
396 Optional<bool> m_hasDefiniteLogicalHeight; 412 Optional<bool> m_hasDefiniteLogicalHeight;
397 }; 413 };
398 414
399 DEFINE_LAYOUT_OBJECT_TYPE_CASTS(LayoutGrid, isLayoutGrid()); 415 DEFINE_LAYOUT_OBJECT_TYPE_CASTS(LayoutGrid, isLayoutGrid());
400 416
401 } // namespace blink 417 } // namespace blink
402 418
403 #endif // LayoutGrid_h 419 #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