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

Unified Diff: Source/core/css/CSSComputedStyleDeclaration.cpp

Issue 14786002: Allow defining named grid lines on the grid element (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebaselined patch for try job / landing Created 7 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/CSSComputedStyleDeclaration.cpp
diff --git a/Source/core/css/CSSComputedStyleDeclaration.cpp b/Source/core/css/CSSComputedStyleDeclaration.cpp
index e05369c4ce12fefbadbe08994ed24cc928b54226..4b7281954b74b3dbae074481150eb2d7ccfdf936 100644
--- a/Source/core/css/CSSComputedStyleDeclaration.cpp
+++ b/Source/core/css/CSSComputedStyleDeclaration.cpp
@@ -1026,15 +1026,39 @@ static PassRefPtr<CSSValue> valueForGridTrackSize(const GridTrackSize& trackSize
return 0;
}
-static PassRefPtr<CSSValue> valueForGridTrackList(const Vector<GridTrackSize>& trackSizes, const RenderStyle* style, RenderView *renderView)
+static void addValuesForNamedGridLinesAtIndex(const NamedGridLinesMap& namedGridLines, size_t i, CSSValueList& list)
+{
+ // Note that this won't return the results in the order specified in the style sheet,
+ // which is probably fine as we stil *do* return all the expected values.
+ NamedGridLinesMap::const_iterator it = namedGridLines.begin();
+ NamedGridLinesMap::const_iterator end = namedGridLines.end();
+ for (; it != end; ++it) {
+ const Vector<size_t>& linesIndexes = it->value;
+ for (size_t j = 0; j < linesIndexes.size(); ++j) {
+ if (linesIndexes[j] != i)
+ continue;
+
+ list.append(cssValuePool().createValue(it->key, CSSPrimitiveValue::CSS_STRING));
+ break;
+ }
+ }
+}
+
+static PassRefPtr<CSSValue> valueForGridTrackList(const Vector<GridTrackSize>& trackSizes, const NamedGridLinesMap& namedGridLines, const RenderStyle* style, RenderView* renderView)
{
// Handle the 'none' case here.
- if (!trackSizes.size())
+ if (!trackSizes.size()) {
+ ASSERT(namedGridLines.isEmpty());
return cssValuePool().createIdentifierValue(CSSValueNone);
+ }
RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
- for (size_t i = 0; i < trackSizes.size(); ++i)
+ for (size_t i = 0; i < trackSizes.size(); ++i) {
+ addValuesForNamedGridLinesAtIndex(namedGridLines, i, *list);
list->append(valueForGridTrackSize(trackSizes[i], style, renderView));
+ }
+ // Those are the trailing <string>* allowed in the syntax.
+ addValuesForNamedGridLinesAtIndex(namedGridLines, trackSizes.size(), *list);
return list.release();
}
@@ -1905,9 +1929,9 @@ PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(CSSPropert
case CSSPropertyWebkitGridAutoRows:
return valueForGridTrackSize(style->gridAutoRows(), style.get(), m_node->document()->renderView());
case CSSPropertyWebkitGridColumns:
- return valueForGridTrackList(style->gridColumns(), style.get(), m_node->document()->renderView());
+ return valueForGridTrackList(style->gridColumns(), style->namedGridColumnLines(), style.get(), m_node->document()->renderView());
case CSSPropertyWebkitGridRows:
- return valueForGridTrackList(style->gridRows(), style.get(), m_node->document()->renderView());
+ return valueForGridTrackList(style->gridRows(), style->namedGridRowLines(), style.get(), m_node->document()->renderView());
case CSSPropertyWebkitGridStart:
return valueForGridPosition(style->gridStart());
« no previous file with comments | « LayoutTests/fast/css-grid-layout/named-grid-line-get-set-expected.txt ('k') | Source/core/css/CSSParser.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698