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

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

Issue 179383003: [CSS Grid Layout] Disallow using <ident> and function names as <custom-ident> (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 9 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
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 4646 matching lines...) Expand 10 before | Expand all | Expand 10 after
4657 if (!isForwardSlashOperator(m_valueList->current())) 4657 if (!isForwardSlashOperator(m_valueList->current()))
4658 return false; 4658 return false;
4659 4659
4660 if (!m_valueList->next()) 4660 if (!m_valueList->next())
4661 return false; 4661 return false;
4662 4662
4663 property = parseGridPosition(); 4663 property = parseGridPosition();
4664 return true; 4664 return true;
4665 } 4665 }
4666 4666
4667 void CSSPropertyParser::parseGridLineNames(CSSParserValueList* parserValueList, CSSValueList& valueList) 4667 bool CSSPropertyParser::parseGridLineNames(CSSParserValueList* parserValueList, CSSValueList& valueList)
4668 { 4668 {
4669 ASSERT(parserValueList->current() && parserValueList->current()->unit == CSS ParserValue::ValueList); 4669 ASSERT(parserValueList->current() && parserValueList->current()->unit == CSS ParserValue::ValueList);
4670 4670
4671 CSSParserValueList* identList = parserValueList->current()->valueList; 4671 CSSParserValueList* identList = parserValueList->current()->valueList;
4672 if (!identList->size()) { 4672 if (!identList->size()) {
4673 parserValueList->next(); 4673 parserValueList->next();
4674 return; 4674 return true;
4675 } 4675 }
4676 4676
4677 RefPtrWillBeRawPtr<CSSGridLineNamesValue> lineNames = CSSGridLineNamesValue: :create(); 4677 RefPtrWillBeRawPtr<CSSGridLineNamesValue> lineNames = CSSGridLineNamesValue: :create();
4678 while (CSSParserValue* identValue = identList->current()) { 4678 while (CSSParserValue* identValue = identList->current()) {
4679 ASSERT(identValue->unit == CSSPrimitiveValue::CSS_IDENT); 4679 ASSERT(identValue->unit == CSSPrimitiveValue::CSS_IDENT);
4680 if (equalIgnoringCase(identValue->string, "auto")
4681 || equalIgnoringCase(identValue->string, "minmax")
4682 || equalIgnoringCase(identValue->string, "subgrid"))
Julien - ping for review 2014/03/01 00:42:21 subgrid will be moved to level 2 (http://lists.w3.
4683 return false;
4684
4680 RefPtrWillBeRawPtr<CSSPrimitiveValue> lineName = createPrimitiveStringVa lue(identValue); 4685 RefPtrWillBeRawPtr<CSSPrimitiveValue> lineName = createPrimitiveStringVa lue(identValue);
4681 lineNames->append(lineName.release()); 4686 lineNames->append(lineName.release());
4682 identList->next(); 4687 identList->next();
4683 } 4688 }
4684 valueList.append(lineNames.release()); 4689 valueList.append(lineNames.release());
4685 4690
4686 parserValueList->next(); 4691 parserValueList->next();
4692 return true;
4687 } 4693 }
4688 4694
4689 bool CSSPropertyParser::parseGridTrackList(CSSPropertyID propId, bool important) 4695 bool CSSPropertyParser::parseGridTrackList(CSSPropertyID propId, bool important)
4690 { 4696 {
4691 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled()); 4697 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled());
4692 4698
4693 CSSParserValue* value = m_valueList->current(); 4699 CSSParserValue* value = m_valueList->current();
4694 if (value->id == CSSValueNone) { 4700 if (value->id == CSSValueNone) {
4695 if (m_valueList->next()) 4701 if (m_valueList->next())
4696 return false; 4702 return false;
4697 4703
4698 addProperty(propId, cssValuePool().createIdentifierValue(value->id), imp ortant); 4704 addProperty(propId, cssValuePool().createIdentifierValue(value->id), imp ortant);
4699 return true; 4705 return true;
4700 } 4706 }
4701 4707
4702 RefPtrWillBeRawPtr<CSSValueList> values = CSSValueList::createSpaceSeparated (); 4708 RefPtrWillBeRawPtr<CSSValueList> values = CSSValueList::createSpaceSeparated ();
4703 // Handle leading <ident>*. 4709 // Handle leading <ident>*.
4704 value = m_valueList->current(); 4710 value = m_valueList->current();
4705 if (value && value->unit == CSSParserValue::ValueList) 4711 if (value && value->unit == CSSParserValue::ValueList) {
4706 parseGridLineNames(m_valueList.get(), *values); 4712 if (!parseGridLineNames(m_valueList.get(), *values))
4713 return false;
4714 }
4707 4715
4708 bool seenTrackSizeOrRepeatFunction = false; 4716 bool seenTrackSizeOrRepeatFunction = false;
4709 while (CSSParserValue* currentValue = m_valueList->current()) { 4717 while (CSSParserValue* currentValue = m_valueList->current()) {
4710 if (currentValue->unit == CSSParserValue::Function && equalIgnoringCase( currentValue->function->name, "repeat(")) { 4718 if (currentValue->unit == CSSParserValue::Function && equalIgnoringCase( currentValue->function->name, "repeat(")) {
4711 if (!parseGridTrackRepeatFunction(*values)) 4719 if (!parseGridTrackRepeatFunction(*values))
4712 return false; 4720 return false;
4713 seenTrackSizeOrRepeatFunction = true; 4721 seenTrackSizeOrRepeatFunction = true;
4714 } else { 4722 } else {
4715 RefPtrWillBeRawPtr<CSSValue> value = parseGridTrackSize(*m_valueList ); 4723 RefPtrWillBeRawPtr<CSSValue> value = parseGridTrackSize(*m_valueList );
4716 if (!value) 4724 if (!value)
4717 return false; 4725 return false;
4718 values->append(value); 4726 values->append(value);
4719 seenTrackSizeOrRepeatFunction = true; 4727 seenTrackSizeOrRepeatFunction = true;
4720 } 4728 }
4721 // This will handle the trailing <ident>* in the grammar. 4729 // This will handle the trailing <ident>* in the grammar.
4722 value = m_valueList->current(); 4730 value = m_valueList->current();
4723 if (value && value->unit == CSSParserValue::ValueList) 4731 if (value && value->unit == CSSParserValue::ValueList) {
4724 parseGridLineNames(m_valueList.get(), *values); 4732 if (!parseGridLineNames(m_valueList.get(), *values))
4733 return false;
4734 }
4725 } 4735 }
4726 4736
4727 // We should have found a <track-size> or else it is not a valid <track-list > 4737 // We should have found a <track-size> or else it is not a valid <track-list >
4728 if (!seenTrackSizeOrRepeatFunction) 4738 if (!seenTrackSizeOrRepeatFunction)
4729 return false; 4739 return false;
4730 4740
4731 addProperty(propId, values.release(), important); 4741 addProperty(propId, values.release(), important);
4732 return true; 4742 return true;
4733 } 4743 }
4734 4744
4735 bool CSSPropertyParser::parseGridTrackRepeatFunction(CSSValueList& list) 4745 bool CSSPropertyParser::parseGridTrackRepeatFunction(CSSValueList& list)
4736 { 4746 {
4737 CSSParserValueList* arguments = m_valueList->current()->function->args.get() ; 4747 CSSParserValueList* arguments = m_valueList->current()->function->args.get() ;
4738 if (!arguments || arguments->size() < 3 || !validUnit(arguments->valueAt(0), FPositiveInteger) || !isComma(arguments->valueAt(1))) 4748 if (!arguments || arguments->size() < 3 || !validUnit(arguments->valueAt(0), FPositiveInteger) || !isComma(arguments->valueAt(1)))
4739 return false; 4749 return false;
4740 4750
4741 ASSERT_WITH_SECURITY_IMPLICATION(arguments->valueAt(0)->fValue > 0); 4751 ASSERT_WITH_SECURITY_IMPLICATION(arguments->valueAt(0)->fValue > 0);
4742 size_t repetitions = arguments->valueAt(0)->fValue; 4752 size_t repetitions = arguments->valueAt(0)->fValue;
4743 RefPtrWillBeRawPtr<CSSValueList> repeatedValues = CSSValueList::createSpaceS eparated(); 4753 RefPtrWillBeRawPtr<CSSValueList> repeatedValues = CSSValueList::createSpaceS eparated();
4744 arguments->next(); // Skip the repetition count. 4754 arguments->next(); // Skip the repetition count.
4745 arguments->next(); // Skip the comma. 4755 arguments->next(); // Skip the comma.
4746 4756
4747 // Handle leading <ident>*. 4757 // Handle leading <ident>*.
4748 CSSParserValue* currentValue = arguments->current(); 4758 CSSParserValue* currentValue = arguments->current();
4749 if (currentValue && currentValue->unit == CSSParserValue::ValueList) 4759 if (currentValue && currentValue->unit == CSSParserValue::ValueList) {
4750 parseGridLineNames(arguments, *repeatedValues); 4760 if (!parseGridLineNames(arguments, *repeatedValues))
4761 return false;
4762 }
4751 4763
4752 while (arguments->current()) { 4764 while (arguments->current()) {
4753 RefPtrWillBeRawPtr<CSSValue> trackSize = parseGridTrackSize(*arguments); 4765 RefPtrWillBeRawPtr<CSSValue> trackSize = parseGridTrackSize(*arguments);
4754 if (!trackSize) 4766 if (!trackSize)
4755 return false; 4767 return false;
4756 4768
4757 repeatedValues->append(trackSize); 4769 repeatedValues->append(trackSize);
4758 4770
4759 // This takes care of any trailing <ident>* in the grammar. 4771 // This takes care of any trailing <ident>* in the grammar.
4760 currentValue = arguments->current(); 4772 currentValue = arguments->current();
4761 if (currentValue && currentValue->unit == CSSParserValue::ValueList) 4773 if (currentValue && currentValue->unit == CSSParserValue::ValueList) {
4762 parseGridLineNames(arguments, *repeatedValues); 4774 if (!parseGridLineNames(arguments, *repeatedValues))
4775 return false;
4776 }
4763 } 4777 }
4764 4778
4765 for (size_t i = 0; i < repetitions; ++i) { 4779 for (size_t i = 0; i < repetitions; ++i) {
4766 for (size_t j = 0; j < repeatedValues->length(); ++j) 4780 for (size_t j = 0; j < repeatedValues->length(); ++j)
4767 list.append(repeatedValues->itemWithoutBoundsCheck(j)); 4781 list.append(repeatedValues->itemWithoutBoundsCheck(j));
4768 } 4782 }
4769 4783
4770 // parseGridTrackSize iterated over the repeat arguments, move to the next v alue. 4784 // parseGridTrackSize iterated over the repeat arguments, move to the next v alue.
4771 m_valueList->next(); 4785 m_valueList->next();
4772 return true; 4786 return true;
(...skipping 5392 matching lines...) Expand 10 before | Expand all | Expand 10 after
10165 { 10179 {
10166 // The tokenizer checks for the construct of an+b. 10180 // The tokenizer checks for the construct of an+b.
10167 // However, since the {ident} rule precedes the {nth} rule, some of those 10181 // However, since the {ident} rule precedes the {nth} rule, some of those
10168 // tokens are identified as string literal. Furthermore we need to accept 10182 // tokens are identified as string literal. Furthermore we need to accept
10169 // "odd" and "even" which does not match to an+b. 10183 // "odd" and "even" which does not match to an+b.
10170 return equalIgnoringCase(token, "odd") || equalIgnoringCase(token, "even") 10184 return equalIgnoringCase(token, "odd") || equalIgnoringCase(token, "even")
10171 || equalIgnoringCase(token, "n") || equalIgnoringCase(token, "-n"); 10185 || equalIgnoringCase(token, "n") || equalIgnoringCase(token, "-n");
10172 } 10186 }
10173 10187
10174 } 10188 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698