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

Unified Diff: third_party/WebKit/Source/core/layout/LayoutGrid.cpp

Issue 2263213002: [css-grid] Do not recursively call layout during auto repeat computation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/core/layout/LayoutGrid.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/layout/LayoutGrid.cpp
diff --git a/third_party/WebKit/Source/core/layout/LayoutGrid.cpp b/third_party/WebKit/Source/core/layout/LayoutGrid.cpp
index 784ab711f8449cd0e337ac60d7f8090aba6c38b0..2f0dccccb881997d688f2c3479d3455045263d40 100644
--- a/third_party/WebKit/Source/core/layout/LayoutGrid.cpp
+++ b/third_party/WebKit/Source/core/layout/LayoutGrid.cpp
@@ -441,10 +441,9 @@ void LayoutGrid::layoutBlock(bool relayoutChildren)
// TODO(svillar): we won't need to do this once the intrinsic width computation is isolated
// from the LayoutGrid object state (it should not touch any attribute) (see crbug.com/627812)
- size_t autoRepeatColumnsCount = computeAutoRepeatTracksCount(ForColumns);
- if (m_autoRepeatColumns && m_autoRepeatColumns != autoRepeatColumnsCount)
+ if (m_autoRepeatColumns && m_autoRepeatColumns != computeAutoRepeatTracksCount(ForColumns, TrackSizing))
dirtyGrid();
- placeItemsOnGrid(autoRepeatColumnsCount);
+ placeItemsOnGrid(TrackSizing);
GridSizingData sizingData(gridColumnCount(), gridRowCount());
@@ -575,7 +574,7 @@ LayoutUnit LayoutGrid::guttersSize(GridTrackSizingDirection direction, size_t st
void LayoutGrid::computeIntrinsicLogicalWidths(LayoutUnit& minLogicalWidth, LayoutUnit& maxLogicalWidth) const
{
- const_cast<LayoutGrid*>(this)->placeItemsOnGrid(styleRef().gridAutoRepeatColumns().size());
+ const_cast<LayoutGrid*>(this)->placeItemsOnGrid(IntrinsicSizeComputation);
GridSizingData sizingData(gridColumnCount(), gridRowCount());
sizingData.freeSpaceForDirection(ForColumns) = LayoutUnit();
@@ -1384,7 +1383,7 @@ void LayoutGrid::insertItemIntoGrid(LayoutBox& child, const GridArea& area)
}
}
-size_t LayoutGrid::computeAutoRepeatTracksCount(GridTrackSizingDirection direction) const
+size_t LayoutGrid::computeAutoRepeatTracksCount(GridTrackSizingDirection direction, SizingOperation sizingOperation) const
{
bool isRowAxis = direction == ForColumns;
const auto& autoRepeatTracks = isRowAxis ? styleRef().gridAutoRepeatColumns() : styleRef().gridAutoRepeatRows();
@@ -1393,18 +1392,23 @@ size_t LayoutGrid::computeAutoRepeatTracksCount(GridTrackSizingDirection directi
if (!autoRepeatTrackListLength)
return 0;
- LayoutUnit availableSize = isRowAxis ? availableLogicalWidth() : computeContentLogicalHeight(MainOrPreferredSize, styleRef().logicalHeight(), LayoutUnit(-1));
- if (availableSize == -1) {
- const Length& maxLength = isRowAxis ? styleRef().logicalMaxWidth() : styleRef().logicalMaxHeight();
- if (!maxLength.isMaxSizeNone()) {
- availableSize = isRowAxis
- ? computeLogicalWidthUsing(MaxSize, maxLength, containingBlockLogicalWidthForContent(), containingBlock())
jfernandez 2016/08/22 14:44:48 Where is this case defined in the new logic ? Is i
svillar 2016/08/22 16:01:52 You can see it defined for rows in the else block
jfernandez 2016/08/22 16:20:20 got it now, thanks.
- : computeContentLogicalHeight(MaxSize, maxLength, LayoutUnit(-1));
+ LayoutUnit availableSize(-1);
Manuel Rego 2016/08/23 07:43:03 Mmm, this means that for columns during intrinsic
svillar 2016/08/25 09:33:10 There is no intrinsic size computation with fixed
Manuel Rego 2016/08/25 09:59:35 Thanks for the explanations I knew I was missing s
+ // Widths are always definite except during intrinsic size computation. For heights we need to
+ // check whether the computed logical height is -1 or not to determine it.
+ if (sizingOperation != IntrinsicSizeComputation || !isRowAxis) {
+ if (isRowAxis) {
Manuel Rego 2016/08/23 07:43:03 Just in case I was wrong in my previous comment, I
svillar 2016/08/25 09:33:10 Acknowledged.
+ DCHECK_NE(sizingOperation, IntrinsicSizeComputation);
jfernandez 2016/08/22 14:44:48 Wouldn't be clearer if we define the DCHECK like i
svillar 2016/08/22 16:01:52 I really don't get what you mean. Could you rephra
jfernandez 2016/08/22 16:20:20 I was mistaken, forget about this suggestion.
+ availableSize = availableLogicalWidth();
+ } else {
+ availableSize = computeContentLogicalHeight(MainOrPreferredSize, styleRef().logicalHeight(), LayoutUnit(-1));
+ if (availableSize == -1) {
+ const Length& maxLength = styleRef().logicalMaxHeight();
+ if (!maxLength.isMaxSizeNone())
+ availableSize = computeContentLogicalHeight(MaxSize, maxLength, LayoutUnit(-1));
+ } else {
+ availableSize = constrainLogicalHeightByMinMax(availableSize, LayoutUnit(-1));
+ }
}
- } else {
- availableSize = isRowAxis
- ? constrainLogicalWidthByMinMax(availableSize, availableLogicalWidth(), containingBlock())
- : constrainLogicalHeightByMinMax(availableSize, LayoutUnit(-1));
}
bool needsToFulfillMinimumSize = false;
@@ -1491,15 +1495,19 @@ std::unique_ptr<LayoutGrid::OrderedTrackIndexSet> LayoutGrid::computeEmptyTracks
return emptyTrackIndexes;
}
-void LayoutGrid::placeItemsOnGrid(size_t autoRepeatColumnsCount)
+void LayoutGrid::placeItemsOnGrid(SizingOperation sizingOperation)
{
if (!m_gridIsDirty)
return;
- ASSERT(m_gridItemArea.isEmpty());
+ DCHECK(m_gridItemArea.isEmpty());
+ DCHECK(m_gridItemsIndexesMap.isEmpty());
- m_autoRepeatColumns = autoRepeatColumnsCount;
- m_autoRepeatRows = computeAutoRepeatTracksCount(ForRows);
+ if (sizingOperation == IntrinsicSizeComputation)
+ m_autoRepeatColumns = styleRef().gridAutoRepeatColumns().size();
+ else
+ m_autoRepeatColumns = computeAutoRepeatTracksCount(ForColumns, sizingOperation);
+ m_autoRepeatRows = computeAutoRepeatTracksCount(ForRows, sizingOperation);
populateExplicitGridAndOrderIterator();
« no previous file with comments | « third_party/WebKit/Source/core/layout/LayoutGrid.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698