Index: Source/core/css/CSSComputedStyleDeclaration.cpp |
diff --git a/Source/core/css/CSSComputedStyleDeclaration.cpp b/Source/core/css/CSSComputedStyleDeclaration.cpp |
index d2aae7dff888c26e3357ccb41d925bf2ef766978..b764569d33f6cb7c011fd7d07e24c6adce3ae218 100644 |
--- a/Source/core/css/CSSComputedStyleDeclaration.cpp |
+++ b/Source/core/css/CSSComputedStyleDeclaration.cpp |
@@ -887,21 +887,30 @@ static PassRefPtrWillBeRawPtr<CSSValue> valueForGridTrackList(GridTrackSizingDir |
{ |
const Vector<GridTrackSize>& trackSizes = direction == ForColumns ? style.gridTemplateColumns() : style.gridTemplateRows(); |
const OrderedNamedGridLines& orderedNamedGridLines = direction == ForColumns ? style.orderedNamedGridColumnLines() : style.orderedNamedGridRowLines(); |
+ bool isRenderGrid = renderer && renderer->isRenderGrid(); |
+ |
+ // Handle the 'none' case. |
+ bool trackListIsEmpty = trackSizes.isEmpty(); |
+ if (isRenderGrid && trackListIsEmpty) { |
+ // For grids we should consider every listed track, whether implicitly or explicitly created. If we don't have |
+ // any explicit track and there are no children then there are no implicit tracks. We cannot simply check the |
+ // number of rows/columns in our internal grid representation because it's always at least 1x1 (see r143331). |
+ trackListIsEmpty = !toRenderBlock(renderer)->firstChild(); |
+ } |
- // Handle the 'none' case here. |
- if (!trackSizes.size()) { |
+ if (trackListIsEmpty) { |
ASSERT(orderedNamedGridLines.isEmpty()); |
return cssValuePool().createIdentifierValue(CSSValueNone); |
} |
RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createSpaceSeparated(); |
- if (renderer && renderer->isRenderGrid()) { |
+ if (isRenderGrid) { |
const Vector<LayoutUnit>& trackPositions = direction == ForColumns ? toRenderGrid(renderer)->columnPositions() : toRenderGrid(renderer)->rowPositions(); |
// There are at least #tracks + 1 grid lines (trackPositions). Apart from that, the grid container can generate implicit grid tracks, |
// so we'll have more trackPositions than trackSizes as the latter only contain the explicit grid. |
ASSERT(trackPositions.size() - 1 >= trackSizes.size()); |
- for (size_t i = 0; i < trackSizes.size(); ++i) { |
+ for (size_t i = 0; i < trackPositions.size() - 1; ++i) { |
addValuesForNamedGridLinesAtIndex(orderedNamedGridLines, i, *list); |
list->append(zoomAdjustedPixelValue(trackPositions[i + 1] - trackPositions[i], style)); |
} |