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

Side by Side Diff: Source/core/css/CSSParser-in.cpp

Issue 23528004: [CSS Grid Layout] Update named grid lines syntax to the last version of the specs (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@named
Patch Set: Added empty track-name list test case Created 7 years, 1 month 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2003 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 2003 Lars Knoll (knoll@kde.org)
3 * Copyright (C) 2005 Allan Sandfeld Jensen (kde@carewolf.com) 3 * Copyright (C) 2005 Allan Sandfeld Jensen (kde@carewolf.com)
4 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights reserved. 4 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights reserved.
5 * Copyright (C) 2007 Nicholas Shanks <webkit@nickshanks.com> 5 * Copyright (C) 2007 Nicholas Shanks <webkit@nickshanks.com>
6 * Copyright (C) 2008 Eric Seidel <eric@webkit.org> 6 * Copyright (C) 2008 Eric Seidel <eric@webkit.org>
7 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo bile.com/) 7 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo bile.com/)
8 * Copyright (C) 2012 Adobe Systems Incorporated. All rights reserved. 8 * Copyright (C) 2012 Adobe Systems Incorporated. All rights reserved.
9 * Copyright (C) 2012 Intel Corporation. All rights reserved. 9 * Copyright (C) 2012 Intel Corporation. All rights reserved.
10 * 10 *
(...skipping 4793 matching lines...) Expand 10 before | Expand all | Expand 10 after
4804 if (!isForwardSlashOperator(m_valueList->current())) 4804 if (!isForwardSlashOperator(m_valueList->current()))
4805 return false; 4805 return false;
4806 4806
4807 if (!m_valueList->next()) 4807 if (!m_valueList->next())
4808 return false; 4808 return false;
4809 4809
4810 property = parseGridPosition(); 4810 property = parseGridPosition();
4811 return true; 4811 return true;
4812 } 4812 }
4813 4813
4814 void CSSParser::parseGridTrackNames(CSSParserValueList* parserValueList, CSSValu eList& valueList)
4815 {
4816 ASSERT(parserValueList->current() && parserValueList->current()->unit == CSS ParserValue::ValueList);
4817
4818 CSSParserValueList* trackNames = parserValueList->current()->valueList;
4819 while (trackNames->current() && trackNames->current()->unit == CSSPrimitiveV alue::CSS_IDENT) {
4820 RefPtr<CSSPrimitiveValue> name = createPrimitiveStringValue(trackNames-> current());
4821 valueList.append(name);
4822 trackNames->next();
4823 }
4824
4825 parserValueList->next();
4826 }
4827
4814 bool CSSParser::parseGridTrackList(CSSPropertyID propId, bool important) 4828 bool CSSParser::parseGridTrackList(CSSPropertyID propId, bool important)
4815 { 4829 {
4816 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled()); 4830 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled());
4817 4831
4818 CSSParserValue* value = m_valueList->current(); 4832 CSSParserValue* value = m_valueList->current();
4819 if (value->id == CSSValueNone) { 4833 if (value->id == CSSValueNone) {
4820 if (m_valueList->next()) 4834 if (m_valueList->next())
4821 return false; 4835 return false;
4822 4836
4823 addProperty(propId, cssValuePool().createIdentifierValue(value->id), imp ortant); 4837 addProperty(propId, cssValuePool().createIdentifierValue(value->id), imp ortant);
4824 return true; 4838 return true;
4825 } 4839 }
4826 4840
4827 RefPtr<CSSValueList> values = CSSValueList::createSpaceSeparated(); 4841 RefPtr<CSSValueList> values = CSSValueList::createSpaceSeparated();
4828 // Handle leading <string>*. 4842 // Handle leading <ident>*.
4829 while (m_valueList->current() && m_valueList->current()->unit == CSSPrimitiv eValue::CSS_STRING) { 4843 value = m_valueList->current();
4830 RefPtr<CSSPrimitiveValue> name = createPrimitiveStringValue(m_valueList- >current()); 4844 if (value && value->unit == CSSParserValue::ValueList)
4831 values->append(name); 4845 parseGridTrackNames(m_valueList.get(), *values);
4832 m_valueList->next();
4833 }
4834 4846
4835 bool seenTrackSizeOrRepeatFunction = false; 4847 bool seenTrackSizeOrRepeatFunction = false;
4836 while (CSSParserValue* currentValue = m_valueList->current()) { 4848 while (CSSParserValue* currentValue = m_valueList->current()) {
4837 if (currentValue->unit == CSSParserValue::Function && equalIgnoringCase( currentValue->function->name, "repeat(")) { 4849 if (currentValue->unit == CSSParserValue::Function && equalIgnoringCase( currentValue->function->name, "repeat(")) {
4838 if (!parseGridTrackRepeatFunction(*values)) 4850 if (!parseGridTrackRepeatFunction(*values))
4839 return false; 4851 return false;
4840 seenTrackSizeOrRepeatFunction = true; 4852 seenTrackSizeOrRepeatFunction = true;
4841 } else { 4853 } else {
4842 RefPtr<CSSValue> value = parseGridTrackSize(*m_valueList); 4854 RefPtr<CSSValue> value = parseGridTrackSize(*m_valueList);
4843 if (!value) 4855 if (!value)
4844 return false; 4856 return false;
4845 values->append(value); 4857 values->append(value);
4846 seenTrackSizeOrRepeatFunction = true; 4858 seenTrackSizeOrRepeatFunction = true;
4847 } 4859 }
4848 4860 // This will handle the trailing <ident>* in the grammar.
4849 // This will handle the trailing <string>* in the grammar. 4861 value = m_valueList->current();
4850 while (m_valueList->current() && m_valueList->current()->unit == CSSPrim itiveValue::CSS_STRING) { 4862 if (value && value->unit == CSSParserValue::ValueList)
4851 RefPtr<CSSPrimitiveValue> name = createPrimitiveStringValue(m_valueL ist->current()); 4863 parseGridTrackNames(m_valueList.get(), *values);
4852 values->append(name);
4853 m_valueList->next();
4854 }
4855 } 4864 }
4856 4865
4857 // We should have found a <track-size> or else it is not a valid <track-list > 4866 // We should have found a <track-size> or else it is not a valid <track-list >
4858 if (!seenTrackSizeOrRepeatFunction) 4867 if (!seenTrackSizeOrRepeatFunction)
4859 return false; 4868 return false;
4860 4869
4861 addProperty(propId, values.release(), important); 4870 addProperty(propId, values.release(), important);
4862 return true; 4871 return true;
4863 } 4872 }
4864 4873
4865 bool CSSParser::parseGridTrackRepeatFunction(CSSValueList& list) 4874 bool CSSParser::parseGridTrackRepeatFunction(CSSValueList& list)
4866 { 4875 {
4867 CSSParserValueList* arguments = m_valueList->current()->function->args.get() ; 4876 CSSParserValueList* arguments = m_valueList->current()->function->args.get() ;
4868 if (!arguments || arguments->size() < 3 || !validUnit(arguments->valueAt(0), FPositiveInteger) || !isComma(arguments->valueAt(1))) 4877 if (!arguments || arguments->size() < 3 || !validUnit(arguments->valueAt(0), FPositiveInteger) || !isComma(arguments->valueAt(1)))
4869 return false; 4878 return false;
4870 4879
4871 ASSERT_WITH_SECURITY_IMPLICATION(arguments->valueAt(0)->fValue > 0); 4880 ASSERT_WITH_SECURITY_IMPLICATION(arguments->valueAt(0)->fValue > 0);
4872 size_t repetitions = arguments->valueAt(0)->fValue; 4881 size_t repetitions = arguments->valueAt(0)->fValue;
4873 RefPtr<CSSValueList> repeatedValues = CSSValueList::createSpaceSeparated(); 4882 RefPtr<CSSValueList> repeatedValues = CSSValueList::createSpaceSeparated();
4874 arguments->next(); // Skip the repetition count. 4883 arguments->next(); // Skip the repetition count.
4875 arguments->next(); // Skip the comma. 4884 arguments->next(); // Skip the comma.
4876 4885
4877 // Handle leading <string>*. 4886 // Handle leading <ident>*.
4878 while (arguments->current() && arguments->current()->unit == CSSPrimitiveVal ue::CSS_STRING) { 4887 CSSParserValue* currentValue = arguments->current();
4879 RefPtr<CSSPrimitiveValue> name = createPrimitiveStringValue(arguments->c urrent()); 4888 if (currentValue && currentValue->unit == CSSParserValue::ValueList)
4880 repeatedValues->append(name); 4889 parseGridTrackNames(arguments, *repeatedValues);
4881 arguments->next();
4882 }
4883 4890
4884 while (arguments->current()) { 4891 while (arguments->current()) {
4885 RefPtr<CSSValue> trackSize = parseGridTrackSize(*arguments); 4892 RefPtr<CSSValue> trackSize = parseGridTrackSize(*arguments);
4886 if (!trackSize) 4893 if (!trackSize)
4887 return false; 4894 return false;
4888 4895
4889 repeatedValues->append(trackSize); 4896 repeatedValues->append(trackSize);
4890 4897
4891 // This takes care of any trailing <string>* in the grammar. 4898 // This takes care of any trailing <ident>* in the grammar.
4892 while (arguments->current() && arguments->current()->unit == CSSPrimitiv eValue::CSS_STRING) { 4899 currentValue = arguments->current();
4893 RefPtr<CSSPrimitiveValue> name = createPrimitiveStringValue(argument s->current()); 4900 if (currentValue && currentValue->unit == CSSParserValue::ValueList)
4894 repeatedValues->append(name); 4901 parseGridTrackNames(arguments, *repeatedValues);
4895 arguments->next();
4896 }
4897 } 4902 }
4898 4903
4899 for (size_t i = 0; i < repetitions; ++i) { 4904 for (size_t i = 0; i < repetitions; ++i) {
4900 for (size_t j = 0; j < repeatedValues->length(); ++j) 4905 for (size_t j = 0; j < repeatedValues->length(); ++j)
4901 list.append(repeatedValues->itemWithoutBoundsCheck(j)); 4906 list.append(repeatedValues->itemWithoutBoundsCheck(j));
4902 } 4907 }
4903 4908
4904 // parseGridTrackSize iterated over the repeat arguments, move to the next v alue. 4909 // parseGridTrackSize iterated over the repeat arguments, move to the next v alue.
4905 m_valueList->next(); 4910 m_valueList->next();
4906 return true; 4911 return true;
(...skipping 7046 matching lines...) Expand 10 before | Expand all | Expand 10 after
11953 { 11958 {
11954 // The tokenizer checks for the construct of an+b. 11959 // The tokenizer checks for the construct of an+b.
11955 // However, since the {ident} rule precedes the {nth} rule, some of those 11960 // However, since the {ident} rule precedes the {nth} rule, some of those
11956 // tokens are identified as string literal. Furthermore we need to accept 11961 // tokens are identified as string literal. Furthermore we need to accept
11957 // "odd" and "even" which does not match to an+b. 11962 // "odd" and "even" which does not match to an+b.
11958 return equalIgnoringCase(token, "odd") || equalIgnoringCase(token, "even") 11963 return equalIgnoringCase(token, "odd") || equalIgnoringCase(token, "even")
11959 || equalIgnoringCase(token, "n") || equalIgnoringCase(token, "-n"); 11964 || equalIgnoringCase(token, "n") || equalIgnoringCase(token, "-n");
11960 } 11965 }
11961 11966
11962 } 11967 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698