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

Side by Side Diff: Source/core/rendering/RenderGrid.cpp

Issue 319593002: [CSS Grid Layout] RenderGrid::growGrid refactoring (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Patch for landing Created 6 years, 6 months 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 | « Source/core/rendering/RenderGrid.h ('k') | no next file » | 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 710 matching lines...) Expand 10 before | Expand all | Expand 10 after
721 for (size_t i = 0; i < tracks.size(); ++i) { 721 for (size_t i = 0; i < tracks.size(); ++i) {
722 const GridTrackSize& trackSize = gridTrackSize(direction, i); 722 const GridTrackSize& trackSize = gridTrackSize(direction, i);
723 const GridLength& minTrackBreadth = trackSize.minTrackBreadth(); 723 const GridLength& minTrackBreadth = trackSize.minTrackBreadth();
724 if (computeUsedBreadthOfMinLength(direction, minTrackBreadth) > tracks[i ].m_usedBreadth) 724 if (computeUsedBreadthOfMinLength(direction, minTrackBreadth) > tracks[i ].m_usedBreadth)
725 return false; 725 return false;
726 } 726 }
727 return true; 727 return true;
728 } 728 }
729 #endif 729 #endif
730 730
731 void RenderGrid::growGrid(GridTrackSizingDirection direction, size_t maximumPosi tionIndex) 731 void RenderGrid::ensureGridSize(size_t maximumRowIndex, size_t maximumColumnInde x)
732 { 732 {
733 if (direction == ForColumns) { 733 const size_t oldRowSize = gridRowCount();
734 ASSERT(maximumPositionIndex >= gridColumnCount()); 734 if (maximumRowIndex >= oldRowSize) {
735 for (size_t row = 0; row < gridRowCount(); ++row) 735 m_grid.grow(maximumRowIndex + 1);
736 m_grid[row].grow(maximumPositionIndex + 1);
737 } else {
738 ASSERT(maximumPositionIndex >= gridRowCount());
739 const size_t oldRowSize = gridRowCount();
740 m_grid.grow(maximumPositionIndex + 1);
741 for (size_t row = oldRowSize; row < gridRowCount(); ++row) 736 for (size_t row = oldRowSize; row < gridRowCount(); ++row)
742 m_grid[row].grow(gridColumnCount()); 737 m_grid[row].grow(gridColumnCount());
743 } 738 }
739
740 if (maximumColumnIndex >= gridColumnCount()) {
741 for (size_t row = 0; row < gridRowCount(); ++row)
742 m_grid[row].grow(maximumColumnIndex + 1);
743 }
744 } 744 }
745 745
746 void RenderGrid::insertItemIntoGrid(RenderBox* child, const GridCoordinate& coor dinate) 746 void RenderGrid::insertItemIntoGrid(RenderBox* child, const GridCoordinate& coor dinate)
747 { 747 {
748 // Ensure that the grid is big enough to contain new grid item. 748 ensureGridSize(coordinate.rows.resolvedFinalPosition.toInt(), coordinate.col umns.resolvedFinalPosition.toInt());
749 if (gridRowCount() <= coordinate.rows.resolvedFinalPosition.toInt())
750 growGrid(ForRows, coordinate.rows.resolvedFinalPosition.toInt());
751 if (gridColumnCount() <= coordinate.columns.resolvedFinalPosition.toInt())
752 growGrid(ForColumns, coordinate.columns.resolvedFinalPosition.toInt());
753 749
754 for (GridSpan::iterator row = coordinate.rows.begin(); row != coordinate.row s.end(); ++row) { 750 for (GridSpan::iterator row = coordinate.rows.begin(); row != coordinate.row s.end(); ++row) {
755 for (GridSpan::iterator column = coordinate.columns.begin(); column != c oordinate.columns.end(); ++column) 751 for (GridSpan::iterator column = coordinate.columns.begin(); column != c oordinate.columns.end(); ++column)
756 m_grid[row.toInt()][column.toInt()].append(child); 752 m_grid[row.toInt()][column.toInt()].append(child);
757 } 753 }
758 754
759 m_gridItemCoordinate.set(child, coordinate); 755 m_gridItemCoordinate.set(child, coordinate);
760 } 756 }
761 757
762 void RenderGrid::placeItemsOnGrid() 758 void RenderGrid::placeItemsOnGrid()
(...skipping 496 matching lines...) Expand 10 before | Expand all | Expand 10 after
1259 if (isOutOfFlowPositioned()) 1255 if (isOutOfFlowPositioned())
1260 return "RenderGrid (positioned)"; 1256 return "RenderGrid (positioned)";
1261 if (isAnonymous()) 1257 if (isAnonymous())
1262 return "RenderGrid (generated)"; 1258 return "RenderGrid (generated)";
1263 if (isRelPositioned()) 1259 if (isRelPositioned())
1264 return "RenderGrid (relative positioned)"; 1260 return "RenderGrid (relative positioned)";
1265 return "RenderGrid"; 1261 return "RenderGrid";
1266 } 1262 }
1267 1263
1268 } // namespace WebCore 1264 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/rendering/RenderGrid.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698