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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2004 Zack Rusin <zack@kde.org> 2 * Copyright (C) 2004 Zack Rusin <zack@kde.org>
3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights reserved. 3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights reserved.
4 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org> 4 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org>
5 * Copyright (C) 2007 Nicholas Shanks <webkit@nickshanks.com> 5 * Copyright (C) 2007 Nicholas Shanks <webkit@nickshanks.com>
6 * Copyright (C) 2011 Sencha, Inc. All rights reserved. 6 * Copyright (C) 2011 Sencha, Inc. All rights reserved.
7 * 7 *
8 * This library is free software; you can redistribute it and/or 8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public 9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either 10 * License as published by the Free Software Foundation; either
(...skipping 1008 matching lines...) Expand 10 before | Expand all | Expand 10 after
1019 case MinMaxTrackSizing: 1019 case MinMaxTrackSizing:
1020 RefPtr<CSSValueList> minMaxTrackBreadths = CSSValueList::createCommaSepa rated(); 1020 RefPtr<CSSValueList> minMaxTrackBreadths = CSSValueList::createCommaSepa rated();
1021 minMaxTrackBreadths->append(valueForGridTrackBreadth(trackSize.minTrackB readth(), style, renderView)); 1021 minMaxTrackBreadths->append(valueForGridTrackBreadth(trackSize.minTrackB readth(), style, renderView));
1022 minMaxTrackBreadths->append(valueForGridTrackBreadth(trackSize.maxTrackB readth(), style, renderView)); 1022 minMaxTrackBreadths->append(valueForGridTrackBreadth(trackSize.maxTrackB readth(), style, renderView));
1023 return CSSFunctionValue::create("minmax(", minMaxTrackBreadths); 1023 return CSSFunctionValue::create("minmax(", minMaxTrackBreadths);
1024 } 1024 }
1025 ASSERT_NOT_REACHED(); 1025 ASSERT_NOT_REACHED();
1026 return 0; 1026 return 0;
1027 } 1027 }
1028 1028
1029 static PassRefPtr<CSSValue> valueForGridTrackList(const Vector<GridTrackSize>& t rackSizes, const RenderStyle* style, RenderView *renderView) 1029 static void addValuesForNamedGridLinesAtIndex(const NamedGridLinesMap& namedGrid Lines, size_t i, CSSValueList& list)
1030 {
1031 // Note that this won't return the results in the order specified in the sty le sheet,
1032 // which is probably fine as we stil *do* return all the expected values.
1033 NamedGridLinesMap::const_iterator it = namedGridLines.begin();
1034 NamedGridLinesMap::const_iterator end = namedGridLines.end();
1035 for (; it != end; ++it) {
1036 const Vector<size_t>& linesIndexes = it->value;
1037 for (size_t j = 0; j < linesIndexes.size(); ++j) {
1038 if (linesIndexes[j] != i)
1039 continue;
1040
1041 list.append(cssValuePool().createValue(it->key, CSSPrimitiveValue::C SS_STRING));
1042 break;
1043 }
1044 }
1045 }
1046
1047 static PassRefPtr<CSSValue> valueForGridTrackList(const Vector<GridTrackSize>& t rackSizes, const NamedGridLinesMap& namedGridLines, const RenderStyle* style, Re nderView* renderView)
1030 { 1048 {
1031 // Handle the 'none' case here. 1049 // Handle the 'none' case here.
1032 if (!trackSizes.size()) 1050 if (!trackSizes.size()) {
1051 ASSERT(namedGridLines.isEmpty());
1033 return cssValuePool().createIdentifierValue(CSSValueNone); 1052 return cssValuePool().createIdentifierValue(CSSValueNone);
1053 }
1034 1054
1035 RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated(); 1055 RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
1036 for (size_t i = 0; i < trackSizes.size(); ++i) 1056 for (size_t i = 0; i < trackSizes.size(); ++i) {
1057 addValuesForNamedGridLinesAtIndex(namedGridLines, i, *list);
1037 list->append(valueForGridTrackSize(trackSizes[i], style, renderView)); 1058 list->append(valueForGridTrackSize(trackSizes[i], style, renderView));
1059 }
1060 // Those are the trailing <string>* allowed in the syntax.
1061 addValuesForNamedGridLinesAtIndex(namedGridLines, trackSizes.size(), *list);
1038 return list.release(); 1062 return list.release();
1039 } 1063 }
1040 1064
1041 static PassRefPtr<CSSValue> valueForGridPosition(const GridPosition& position) 1065 static PassRefPtr<CSSValue> valueForGridPosition(const GridPosition& position)
1042 { 1066 {
1043 if (position.isAuto()) 1067 if (position.isAuto())
1044 return cssValuePool().createIdentifierValue(CSSValueAuto); 1068 return cssValuePool().createIdentifierValue(CSSValueAuto);
1045 1069
1046 if (position.isInteger()) 1070 if (position.isInteger())
1047 return cssValuePool().createValue(position.integerPosition(), CSSPrimiti veValue::CSS_NUMBER); 1071 return cssValuePool().createValue(position.integerPosition(), CSSPrimiti veValue::CSS_NUMBER);
(...skipping 850 matching lines...) Expand 10 before | Expand all | Expand 10 after
1898 } 1922 }
1899 return list.release(); 1923 return list.release();
1900 } 1924 }
1901 case CSSPropertyWebkitGridAutoColumns: 1925 case CSSPropertyWebkitGridAutoColumns:
1902 return valueForGridTrackSize(style->gridAutoColumns(), style.get(), m_node->document()->renderView()); 1926 return valueForGridTrackSize(style->gridAutoColumns(), style.get(), m_node->document()->renderView());
1903 case CSSPropertyWebkitGridAutoFlow: 1927 case CSSPropertyWebkitGridAutoFlow:
1904 return cssValuePool().createValue(style->gridAutoFlow()); 1928 return cssValuePool().createValue(style->gridAutoFlow());
1905 case CSSPropertyWebkitGridAutoRows: 1929 case CSSPropertyWebkitGridAutoRows:
1906 return valueForGridTrackSize(style->gridAutoRows(), style.get(), m_n ode->document()->renderView()); 1930 return valueForGridTrackSize(style->gridAutoRows(), style.get(), m_n ode->document()->renderView());
1907 case CSSPropertyWebkitGridColumns: 1931 case CSSPropertyWebkitGridColumns:
1908 return valueForGridTrackList(style->gridColumns(), style.get(), m_no de->document()->renderView()); 1932 return valueForGridTrackList(style->gridColumns(), style->namedGridC olumnLines(), style.get(), m_node->document()->renderView());
1909 case CSSPropertyWebkitGridRows: 1933 case CSSPropertyWebkitGridRows:
1910 return valueForGridTrackList(style->gridRows(), style.get(), m_node- >document()->renderView()); 1934 return valueForGridTrackList(style->gridRows(), style->namedGridRowL ines(), style.get(), m_node->document()->renderView());
1911 1935
1912 case CSSPropertyWebkitGridStart: 1936 case CSSPropertyWebkitGridStart:
1913 return valueForGridPosition(style->gridStart()); 1937 return valueForGridPosition(style->gridStart());
1914 case CSSPropertyWebkitGridEnd: 1938 case CSSPropertyWebkitGridEnd:
1915 return valueForGridPosition(style->gridEnd()); 1939 return valueForGridPosition(style->gridEnd());
1916 case CSSPropertyWebkitGridBefore: 1940 case CSSPropertyWebkitGridBefore:
1917 return valueForGridPosition(style->gridBefore()); 1941 return valueForGridPosition(style->gridBefore());
1918 case CSSPropertyWebkitGridAfter: 1942 case CSSPropertyWebkitGridAfter:
1919 return valueForGridPosition(style->gridAfter()); 1943 return valueForGridPosition(style->gridAfter());
1920 case CSSPropertyWebkitGridColumn: 1944 case CSSPropertyWebkitGridColumn:
(...skipping 1054 matching lines...) Expand 10 before | Expand all | Expand 10 after
2975 static const CSSPropertyID propertiesAfterSlashSeperator[3] = { CSSPropertyB ackgroundSize, CSSPropertyBackgroundOrigin, 2999 static const CSSPropertyID propertiesAfterSlashSeperator[3] = { CSSPropertyB ackgroundSize, CSSPropertyBackgroundOrigin,
2976 CSSPropertyB ackgroundClip }; 3000 CSSPropertyB ackgroundClip };
2977 3001
2978 RefPtr<CSSValueList> list = CSSValueList::createSlashSeparated(); 3002 RefPtr<CSSValueList> list = CSSValueList::createSlashSeparated();
2979 list->append(getCSSPropertyValuesForShorthandProperties(StylePropertyShortha nd(propertiesBeforeSlashSeperator, WTF_ARRAY_LENGTH(propertiesBeforeSlashSeperat or)))); 3003 list->append(getCSSPropertyValuesForShorthandProperties(StylePropertyShortha nd(propertiesBeforeSlashSeperator, WTF_ARRAY_LENGTH(propertiesBeforeSlashSeperat or))));
2980 list->append(getCSSPropertyValuesForShorthandProperties(StylePropertyShortha nd(propertiesAfterSlashSeperator, WTF_ARRAY_LENGTH(propertiesAfterSlashSeperator )))); 3004 list->append(getCSSPropertyValuesForShorthandProperties(StylePropertyShortha nd(propertiesAfterSlashSeperator, WTF_ARRAY_LENGTH(propertiesAfterSlashSeperator ))));
2981 return list.release(); 3005 return list.release();
2982 } 3006 }
2983 3007
2984 } // namespace WebCore 3008 } // namespace WebCore
OLDNEW
« 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