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