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

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 some new tests Created 7 years, 3 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
« Source/core/css/CSSGrammar.y.in ('K') | « Source/core/css/CSSParser.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 4746 matching lines...) Expand 10 before | Expand all | Expand 10 after
4757 if (!isForwardSlashOperator(m_valueList->current())) 4757 if (!isForwardSlashOperator(m_valueList->current()))
4758 return false; 4758 return false;
4759 4759
4760 if (!m_valueList->next()) 4760 if (!m_valueList->next())
4761 return false; 4761 return false;
4762 4762
4763 property = parseGridPosition(); 4763 property = parseGridPosition();
4764 return true; 4764 return true;
4765 } 4765 }
4766 4766
4767 static inline bool isOpenParenthesisOperator(CSSParserValue* value)
4768 {
4769 return value->unit == CSSParserValue::Operator && value->iValue == '(';
4770 }
4771
4772 void CSSParser::parseGridLineNames(CSSParserValueList* parserValueList, CSSValue List& valueList)
4773 {
4774 ASSERT(isOpenParenthesisOperator(parserValueList->current()));
4775 parserValueList->next(); // skip '('
4776
4777 while (parserValueList->current() && parserValueList->current()->unit == CSS PrimitiveValue::CSS_IDENT) {
4778 RefPtr<CSSPrimitiveValue> name = createPrimitiveStringValue(parserValueL ist->current());
4779 valueList.append(name);
4780 parserValueList->next();
4781 }
4782
4783 ASSERT(parserValueList->current()->unit == CSSParserValue::Operator && parse rValueList->current()->iValue == ')');
4784 parserValueList->next(); // skip ')'
4785 }
4786
4767 bool CSSParser::parseGridTrackList(CSSPropertyID propId, bool important) 4787 bool CSSParser::parseGridTrackList(CSSPropertyID propId, bool important)
4768 { 4788 {
4769 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled()); 4789 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled());
4770 4790
4771 CSSParserValue* value = m_valueList->current(); 4791 CSSParserValue* value = m_valueList->current();
4772 if (value->id == CSSValueNone) { 4792 if (value->id == CSSValueNone) {
4773 if (m_valueList->next()) 4793 if (m_valueList->next())
4774 return false; 4794 return false;
4775 4795
4776 addProperty(propId, cssValuePool().createIdentifierValue(value->id), imp ortant); 4796 addProperty(propId, cssValuePool().createIdentifierValue(value->id), imp ortant);
4777 return true; 4797 return true;
4778 } 4798 }
4779 4799
4780 RefPtr<CSSValueList> values = CSSValueList::createSpaceSeparated(); 4800 RefPtr<CSSValueList> values = CSSValueList::createSpaceSeparated();
4781 // Handle leading <string>*. 4801 // Handle leading <ident>*.
4782 while (m_valueList->current() && m_valueList->current()->unit == CSSPrimitiv eValue::CSS_STRING) { 4802 value = m_valueList->current();
4783 RefPtr<CSSPrimitiveValue> name = createPrimitiveStringValue(m_valueList- >current()); 4803 if (value && isOpenParenthesisOperator(value))
4784 values->append(name); 4804 parseGridLineNames(m_valueList.get(), *values);
4785 m_valueList->next();
4786 }
4787 4805
4788 bool seenTrackSizeOrRepeatFunction = false; 4806 bool seenTrackSizeOrRepeatFunction = false;
4789 while (CSSParserValue* currentValue = m_valueList->current()) { 4807 while (CSSParserValue* currentValue = m_valueList->current()) {
4790 if (currentValue->unit == CSSParserValue::Function && equalIgnoringCase( currentValue->function->name, "repeat(")) { 4808 if (currentValue->unit == CSSParserValue::Function && equalIgnoringCase( currentValue->function->name, "repeat(")) {
4791 if (!parseGridTrackRepeatFunction(*values)) 4809 if (!parseGridTrackRepeatFunction(*values))
4792 return false; 4810 return false;
4793 seenTrackSizeOrRepeatFunction = true; 4811 seenTrackSizeOrRepeatFunction = true;
4794 } else { 4812 } else {
4795 RefPtr<CSSValue> value = parseGridTrackSize(*m_valueList); 4813 RefPtr<CSSValue> value = parseGridTrackSize(*m_valueList);
4796 if (!value) 4814 if (!value)
4797 return false; 4815 return false;
4798 values->append(value); 4816 values->append(value);
4799 seenTrackSizeOrRepeatFunction = true; 4817 seenTrackSizeOrRepeatFunction = true;
4800 } 4818 }
4801 4819 // This will handle the trailing <ident>* in the grammar.
4802 // This will handle the trailing <string>* in the grammar. 4820 value = m_valueList->current();
4803 while (m_valueList->current() && m_valueList->current()->unit == CSSPrim itiveValue::CSS_STRING) { 4821 if (value && isOpenParenthesisOperator(value))
4804 RefPtr<CSSPrimitiveValue> name = createPrimitiveStringValue(m_valueL ist->current()); 4822 parseGridLineNames(m_valueList.get(), *values);
4805 values->append(name);
4806 m_valueList->next();
4807 }
4808 } 4823 }
4809 4824
4810 // We should have found a <track-size> or else it is not a valid <track-list > 4825 // We should have found a <track-size> or else it is not a valid <track-list >
4811 if (!seenTrackSizeOrRepeatFunction) 4826 if (!seenTrackSizeOrRepeatFunction)
4812 return false; 4827 return false;
4813 4828
4814 addProperty(propId, values.release(), important); 4829 addProperty(propId, values.release(), important);
4815 return true; 4830 return true;
4816 } 4831 }
4817 4832
4818 bool CSSParser::parseGridTrackRepeatFunction(CSSValueList& list) 4833 bool CSSParser::parseGridTrackRepeatFunction(CSSValueList& list)
4819 { 4834 {
4820 CSSParserValueList* arguments = m_valueList->current()->function->args.get() ; 4835 CSSParserValueList* arguments = m_valueList->current()->function->args.get() ;
4821 if (!arguments || arguments->size() < 3 || !validUnit(arguments->valueAt(0), FPositiveInteger) || !isComma(arguments->valueAt(1))) 4836 if (!arguments || arguments->size() < 3 || !validUnit(arguments->valueAt(0), FPositiveInteger) || !isComma(arguments->valueAt(1)))
4822 return false; 4837 return false;
4823 4838
4824 ASSERT_WITH_SECURITY_IMPLICATION(arguments->valueAt(0)->fValue > 0); 4839 ASSERT_WITH_SECURITY_IMPLICATION(arguments->valueAt(0)->fValue > 0);
4825 size_t repetitions = arguments->valueAt(0)->fValue; 4840 size_t repetitions = arguments->valueAt(0)->fValue;
4826 RefPtr<CSSValueList> repeatedValues = CSSValueList::createSpaceSeparated(); 4841 RefPtr<CSSValueList> repeatedValues = CSSValueList::createSpaceSeparated();
4827 arguments->next(); // Skip the repetition count. 4842 arguments->next(); // Skip the repetition count.
4828 arguments->next(); // Skip the comma. 4843 arguments->next(); // Skip the comma.
4829 4844
4830 // Handle leading <string>*. 4845 // Handle leading <ident>*.
4831 while (arguments->current() && arguments->current()->unit == CSSPrimitiveVal ue::CSS_STRING) { 4846 CSSParserValue* currentValue = arguments->current();
4832 RefPtr<CSSPrimitiveValue> name = createPrimitiveStringValue(arguments->c urrent()); 4847 if (currentValue && isOpenParenthesisOperator(currentValue))
4833 repeatedValues->append(name); 4848 parseGridLineNames(arguments, *repeatedValues);
4834 arguments->next();
4835 }
4836 4849
4837 while (CSSParserValue* argumentValue = arguments->current()) { 4850 while (CSSParserValue* argumentValue = arguments->current()) {
4838 RefPtr<CSSValue> trackSize = parseGridTrackSize(*arguments); 4851 RefPtr<CSSValue> trackSize = parseGridTrackSize(*arguments);
4839 if (!trackSize) 4852 if (!trackSize)
4840 return false; 4853 return false;
4841 4854
4842 repeatedValues->append(trackSize); 4855 repeatedValues->append(trackSize);
4843 4856
4844 // This takes care of any trailing <string>* in the grammar. 4857 // This takes care of any trailing <ident>* in the grammar.
4845 while (arguments->current() && arguments->current()->unit == CSSPrimitiv eValue::CSS_STRING) { 4858 currentValue = arguments->current();
4846 RefPtr<CSSPrimitiveValue> name = createPrimitiveStringValue(argument s->current()); 4859 if (currentValue && isOpenParenthesisOperator(currentValue))
4847 repeatedValues->append(name); 4860 parseGridLineNames(arguments, *repeatedValues);
4848 arguments->next();
4849 }
4850 } 4861 }
4851 4862
4852 for (size_t i = 0; i < repetitions; ++i) { 4863 for (size_t i = 0; i < repetitions; ++i) {
4853 for (size_t j = 0; j < repeatedValues->length(); ++j) 4864 for (size_t j = 0; j < repeatedValues->length(); ++j)
4854 list.append(repeatedValues->itemWithoutBoundsCheck(j)); 4865 list.append(repeatedValues->itemWithoutBoundsCheck(j));
4855 } 4866 }
4856 4867
4857 // parseGridTrackSize iterated over the repeat arguments, move to the next v alue. 4868 // parseGridTrackSize iterated over the repeat arguments, move to the next v alue.
4858 m_valueList->next(); 4869 m_valueList->next();
4859 return true; 4870 return true;
(...skipping 7120 matching lines...) Expand 10 before | Expand all | Expand 10 after
11980 { 11991 {
11981 // The tokenizer checks for the construct of an+b. 11992 // The tokenizer checks for the construct of an+b.
11982 // However, since the {ident} rule precedes the {nth} rule, some of those 11993 // However, since the {ident} rule precedes the {nth} rule, some of those
11983 // tokens are identified as string literal. Furthermore we need to accept 11994 // tokens are identified as string literal. Furthermore we need to accept
11984 // "odd" and "even" which does not match to an+b. 11995 // "odd" and "even" which does not match to an+b.
11985 return equalIgnoringCase(token, "odd") || equalIgnoringCase(token, "even") 11996 return equalIgnoringCase(token, "odd") || equalIgnoringCase(token, "even")
11986 || equalIgnoringCase(token, "n") || equalIgnoringCase(token, "-n"); 11997 || equalIgnoringCase(token, "n") || equalIgnoringCase(token, "-n");
11987 } 11998 }
11988 11999
11989 } 12000 }
OLDNEW
« Source/core/css/CSSGrammar.y.in ('K') | « Source/core/css/CSSParser.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698