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

Unified Diff: Source/core/css/resolver/StyleBuilderCustom.cpp

Issue 148293008: [CSS Grid Layout] Add support to place items using named grid lines (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Implementation following specs Created 6 years, 7 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
Index: Source/core/css/resolver/StyleBuilderCustom.cpp
diff --git a/Source/core/css/resolver/StyleBuilderCustom.cpp b/Source/core/css/resolver/StyleBuilderCustom.cpp
index d859c5ef4b42b8ecc27482eac5f08725642f02ec..a70e7be3d856b20d92b6d55aee21780e5d93809c 100644
--- a/Source/core/css/resolver/StyleBuilderCustom.cpp
+++ b/Source/core/css/resolver/StyleBuilderCustom.cpp
@@ -1049,6 +1049,22 @@ if (isInitial) { \
return; \
}
+static void createImplicitNamedGridLinesFromGridArea(const NamedGridAreaMap& namedGridAreas, NamedGridLinesMap& namedGridLines, GridTrackSizingDirection direction)
+{
+ NamedGridAreaMap::const_iterator end = namedGridAreas.end();
+ for (NamedGridAreaMap::const_iterator it = namedGridAreas.begin(); it != end; ++it) {
+ GridSpan areaSpan = direction == ForRows ? it->value.rows : it->value.columns;
+
+ NamedGridLinesMap::AddResult startResult = namedGridLines.add(it->key + "-start", Vector<size_t>());
+ startResult.storedValue->value.append(areaSpan.resolvedInitialPosition.toInt());
+ std::sort(startResult.storedValue->value.begin(), startResult.storedValue->value.end());
+
+ NamedGridLinesMap::AddResult endResult = namedGridLines.add(it->key + "-end", Vector<size_t>());
+ endResult.storedValue->value.append(areaSpan.resolvedFinalPosition.toInt() + 1);
+ std::sort(endResult.storedValue->value.begin(), endResult.storedValue->value.end());
+ }
+}
+
static GridLength createGridTrackBreadth(CSSPrimitiveValue* primitiveValue, const StyleResolverState& state)
{
if (primitiveValue->getValueID() == CSSValueMinContent)
@@ -1738,6 +1754,11 @@ void StyleBuilder::oldApplyProperty(CSSPropertyID id, StyleResolverState& state,
OrderedNamedGridLines orderedNamedGridLines;
if (!createGridTrackList(value, trackSizes, namedGridLines, orderedNamedGridLines, state))
return;
+
+ const NamedGridAreaMap& namedGridAreas = state.style()->namedGridArea();
+ if (!namedGridAreas.isEmpty())
+ createImplicitNamedGridLinesFromGridArea(namedGridAreas, namedGridLines, ForColumns);
+
state.style()->setGridTemplateColumns(trackSizes);
state.style()->setNamedGridColumnLines(namedGridLines);
state.style()->setOrderedNamedGridColumnLines(orderedNamedGridLines);
@@ -1762,6 +1783,11 @@ void StyleBuilder::oldApplyProperty(CSSPropertyID id, StyleResolverState& state,
OrderedNamedGridLines orderedNamedGridLines;
if (!createGridTrackList(value, trackSizes, namedGridLines, orderedNamedGridLines, state))
return;
+
+ const NamedGridAreaMap& namedGridAreas = state.style()->namedGridArea();
+ if (!namedGridAreas.isEmpty())
+ createImplicitNamedGridLinesFromGridArea(namedGridAreas, namedGridLines, ForRows);
+
state.style()->setGridTemplateRows(trackSizes);
state.style()->setNamedGridRowLines(namedGridLines);
state.style()->setOrderedNamedGridRowLines(orderedNamedGridLines);
@@ -1822,7 +1848,16 @@ void StyleBuilder::oldApplyProperty(CSSPropertyID id, StyleResolverState& state,
}
CSSGridTemplateAreasValue* gridTemplateAreasValue = toCSSGridTemplateAreasValue(value);
- state.style()->setNamedGridArea(gridTemplateAreasValue->gridAreaMap());
+ const NamedGridAreaMap& newNamedGridAreas = gridTemplateAreasValue->gridAreaMap();
+
+ NamedGridLinesMap namedGridColumnLines = state.style()->namedGridColumnLines();
+ NamedGridLinesMap namedGridRowLines = state.style()->namedGridRowLines();
Julien - ping for review 2014/05/12 11:42:12 You're right about RenderStyle returning a constan
+ createImplicitNamedGridLinesFromGridArea(newNamedGridAreas, namedGridColumnLines, ForColumns);
+ createImplicitNamedGridLinesFromGridArea(newNamedGridAreas, namedGridRowLines, ForRows);
+ state.style()->setNamedGridColumnLines(namedGridColumnLines);
+ state.style()->setNamedGridRowLines(namedGridRowLines);
+
+ state.style()->setNamedGridArea(newNamedGridAreas);
state.style()->setNamedGridAreaRowCount(gridTemplateAreasValue->rowCount());
state.style()->setNamedGridAreaColumnCount(gridTemplateAreasValue->columnCount());
return;

Powered by Google App Engine
This is Rietveld 408576698