| 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 23 matching lines...) Expand all Loading... |
| 34 #include "core/css/CSSAspectRatioValue.h" | 34 #include "core/css/CSSAspectRatioValue.h" |
| 35 #include "core/css/CSSBasicShapes.h" | 35 #include "core/css/CSSBasicShapes.h" |
| 36 #include "core/css/CSSBorderImage.h" | 36 #include "core/css/CSSBorderImage.h" |
| 37 #include "core/css/CSSCanvasValue.h" | 37 #include "core/css/CSSCanvasValue.h" |
| 38 #include "core/css/CSSCrossfadeValue.h" | 38 #include "core/css/CSSCrossfadeValue.h" |
| 39 #include "core/css/CSSCursorImageValue.h" | 39 #include "core/css/CSSCursorImageValue.h" |
| 40 #include "core/css/CSSFontFaceSrcValue.h" | 40 #include "core/css/CSSFontFaceSrcValue.h" |
| 41 #include "core/css/CSSFontFeatureValue.h" | 41 #include "core/css/CSSFontFeatureValue.h" |
| 42 #include "core/css/CSSFunctionValue.h" | 42 #include "core/css/CSSFunctionValue.h" |
| 43 #include "core/css/CSSGradientValue.h" | 43 #include "core/css/CSSGradientValue.h" |
| 44 #include "core/css/CSSGridLineNamesValue.h" |
| 44 #include "core/css/CSSGridTemplateValue.h" | 45 #include "core/css/CSSGridTemplateValue.h" |
| 45 #include "core/css/CSSImageSetValue.h" | 46 #include "core/css/CSSImageSetValue.h" |
| 46 #include "core/css/CSSImageValue.h" | 47 #include "core/css/CSSImageValue.h" |
| 47 #include "core/css/CSSInheritedValue.h" | 48 #include "core/css/CSSInheritedValue.h" |
| 48 #include "core/css/CSSInitialValue.h" | 49 #include "core/css/CSSInitialValue.h" |
| 49 #include "core/css/CSSKeyframeRule.h" | 50 #include "core/css/CSSKeyframeRule.h" |
| 50 #include "core/css/CSSKeyframesRule.h" | 51 #include "core/css/CSSKeyframesRule.h" |
| 51 #include "core/css/CSSLineBoxContainValue.h" | 52 #include "core/css/CSSLineBoxContainValue.h" |
| 52 #include "core/css/CSSMixFunctionValue.h" | 53 #include "core/css/CSSMixFunctionValue.h" |
| 53 #include "core/css/CSSPrimitiveValue.h" | 54 #include "core/css/CSSPrimitiveValue.h" |
| (...skipping 4750 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4804 if (!isForwardSlashOperator(m_valueList->current())) | 4805 if (!isForwardSlashOperator(m_valueList->current())) |
| 4805 return false; | 4806 return false; |
| 4806 | 4807 |
| 4807 if (!m_valueList->next()) | 4808 if (!m_valueList->next()) |
| 4808 return false; | 4809 return false; |
| 4809 | 4810 |
| 4810 property = parseGridPosition(); | 4811 property = parseGridPosition(); |
| 4811 return true; | 4812 return true; |
| 4812 } | 4813 } |
| 4813 | 4814 |
| 4815 void CSSParser::parseGridLineNames(CSSParserValueList* parserValueList, CSSValue
List& valueList) |
| 4816 { |
| 4817 ASSERT(parserValueList->current() && parserValueList->current()->unit == CSS
ParserValue::ValueList); |
| 4818 |
| 4819 CSSParserValueList* identList = parserValueList->current()->valueList; |
| 4820 if (!identList->size()) { |
| 4821 parserValueList->next(); |
| 4822 return; |
| 4823 } |
| 4824 |
| 4825 RefPtr<CSSGridLineNamesValue> lineNames = CSSGridLineNamesValue::create(); |
| 4826 while (CSSParserValue* identValue = identList->current()) { |
| 4827 ASSERT(identValue->unit == CSSPrimitiveValue::CSS_IDENT); |
| 4828 RefPtr<CSSPrimitiveValue> lineName = createPrimitiveStringValue(identVal
ue); |
| 4829 lineNames->append(lineName.release()); |
| 4830 identList->next(); |
| 4831 } |
| 4832 valueList.append(lineNames.release()); |
| 4833 |
| 4834 parserValueList->next(); |
| 4835 } |
| 4836 |
| 4814 bool CSSParser::parseGridTrackList(CSSPropertyID propId, bool important) | 4837 bool CSSParser::parseGridTrackList(CSSPropertyID propId, bool important) |
| 4815 { | 4838 { |
| 4816 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled()); | 4839 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled()); |
| 4817 | 4840 |
| 4818 CSSParserValue* value = m_valueList->current(); | 4841 CSSParserValue* value = m_valueList->current(); |
| 4819 if (value->id == CSSValueNone) { | 4842 if (value->id == CSSValueNone) { |
| 4820 if (m_valueList->next()) | 4843 if (m_valueList->next()) |
| 4821 return false; | 4844 return false; |
| 4822 | 4845 |
| 4823 addProperty(propId, cssValuePool().createIdentifierValue(value->id), imp
ortant); | 4846 addProperty(propId, cssValuePool().createIdentifierValue(value->id), imp
ortant); |
| 4824 return true; | 4847 return true; |
| 4825 } | 4848 } |
| 4826 | 4849 |
| 4827 RefPtr<CSSValueList> values = CSSValueList::createSpaceSeparated(); | 4850 RefPtr<CSSValueList> values = CSSValueList::createSpaceSeparated(); |
| 4828 // Handle leading <string>*. | 4851 // Handle leading <ident>*. |
| 4829 while (m_valueList->current() && m_valueList->current()->unit == CSSPrimitiv
eValue::CSS_STRING) { | 4852 value = m_valueList->current(); |
| 4830 RefPtr<CSSPrimitiveValue> name = createPrimitiveStringValue(m_valueList-
>current()); | 4853 if (value && value->unit == CSSParserValue::ValueList) |
| 4831 values->append(name); | 4854 parseGridLineNames(m_valueList.get(), *values); |
| 4832 m_valueList->next(); | |
| 4833 } | |
| 4834 | 4855 |
| 4835 bool seenTrackSizeOrRepeatFunction = false; | 4856 bool seenTrackSizeOrRepeatFunction = false; |
| 4836 while (CSSParserValue* currentValue = m_valueList->current()) { | 4857 while (CSSParserValue* currentValue = m_valueList->current()) { |
| 4837 if (currentValue->unit == CSSParserValue::Function && equalIgnoringCase(
currentValue->function->name, "repeat(")) { | 4858 if (currentValue->unit == CSSParserValue::Function && equalIgnoringCase(
currentValue->function->name, "repeat(")) { |
| 4838 if (!parseGridTrackRepeatFunction(*values)) | 4859 if (!parseGridTrackRepeatFunction(*values)) |
| 4839 return false; | 4860 return false; |
| 4840 seenTrackSizeOrRepeatFunction = true; | 4861 seenTrackSizeOrRepeatFunction = true; |
| 4841 } else { | 4862 } else { |
| 4842 RefPtr<CSSValue> value = parseGridTrackSize(*m_valueList); | 4863 RefPtr<CSSValue> value = parseGridTrackSize(*m_valueList); |
| 4843 if (!value) | 4864 if (!value) |
| 4844 return false; | 4865 return false; |
| 4845 values->append(value); | 4866 values->append(value); |
| 4846 seenTrackSizeOrRepeatFunction = true; | 4867 seenTrackSizeOrRepeatFunction = true; |
| 4847 } | 4868 } |
| 4848 | 4869 // This will handle the trailing <ident>* in the grammar. |
| 4849 // This will handle the trailing <string>* in the grammar. | 4870 value = m_valueList->current(); |
| 4850 while (m_valueList->current() && m_valueList->current()->unit == CSSPrim
itiveValue::CSS_STRING) { | 4871 if (value && value->unit == CSSParserValue::ValueList) |
| 4851 RefPtr<CSSPrimitiveValue> name = createPrimitiveStringValue(m_valueL
ist->current()); | 4872 parseGridLineNames(m_valueList.get(), *values); |
| 4852 values->append(name); | |
| 4853 m_valueList->next(); | |
| 4854 } | |
| 4855 } | 4873 } |
| 4856 | 4874 |
| 4857 // We should have found a <track-size> or else it is not a valid <track-list
> | 4875 // We should have found a <track-size> or else it is not a valid <track-list
> |
| 4858 if (!seenTrackSizeOrRepeatFunction) | 4876 if (!seenTrackSizeOrRepeatFunction) |
| 4859 return false; | 4877 return false; |
| 4860 | 4878 |
| 4861 addProperty(propId, values.release(), important); | 4879 addProperty(propId, values.release(), important); |
| 4862 return true; | 4880 return true; |
| 4863 } | 4881 } |
| 4864 | 4882 |
| 4865 bool CSSParser::parseGridTrackRepeatFunction(CSSValueList& list) | 4883 bool CSSParser::parseGridTrackRepeatFunction(CSSValueList& list) |
| 4866 { | 4884 { |
| 4867 CSSParserValueList* arguments = m_valueList->current()->function->args.get()
; | 4885 CSSParserValueList* arguments = m_valueList->current()->function->args.get()
; |
| 4868 if (!arguments || arguments->size() < 3 || !validUnit(arguments->valueAt(0),
FPositiveInteger) || !isComma(arguments->valueAt(1))) | 4886 if (!arguments || arguments->size() < 3 || !validUnit(arguments->valueAt(0),
FPositiveInteger) || !isComma(arguments->valueAt(1))) |
| 4869 return false; | 4887 return false; |
| 4870 | 4888 |
| 4871 ASSERT_WITH_SECURITY_IMPLICATION(arguments->valueAt(0)->fValue > 0); | 4889 ASSERT_WITH_SECURITY_IMPLICATION(arguments->valueAt(0)->fValue > 0); |
| 4872 size_t repetitions = arguments->valueAt(0)->fValue; | 4890 size_t repetitions = arguments->valueAt(0)->fValue; |
| 4873 RefPtr<CSSValueList> repeatedValues = CSSValueList::createSpaceSeparated(); | 4891 RefPtr<CSSValueList> repeatedValues = CSSValueList::createSpaceSeparated(); |
| 4874 arguments->next(); // Skip the repetition count. | 4892 arguments->next(); // Skip the repetition count. |
| 4875 arguments->next(); // Skip the comma. | 4893 arguments->next(); // Skip the comma. |
| 4876 | 4894 |
| 4877 // Handle leading <string>*. | 4895 // Handle leading <ident>*. |
| 4878 while (arguments->current() && arguments->current()->unit == CSSPrimitiveVal
ue::CSS_STRING) { | 4896 CSSParserValue* currentValue = arguments->current(); |
| 4879 RefPtr<CSSPrimitiveValue> name = createPrimitiveStringValue(arguments->c
urrent()); | 4897 if (currentValue && currentValue->unit == CSSParserValue::ValueList) |
| 4880 repeatedValues->append(name); | 4898 parseGridLineNames(arguments, *repeatedValues); |
| 4881 arguments->next(); | |
| 4882 } | |
| 4883 | 4899 |
| 4884 while (arguments->current()) { | 4900 while (arguments->current()) { |
| 4885 RefPtr<CSSValue> trackSize = parseGridTrackSize(*arguments); | 4901 RefPtr<CSSValue> trackSize = parseGridTrackSize(*arguments); |
| 4886 if (!trackSize) | 4902 if (!trackSize) |
| 4887 return false; | 4903 return false; |
| 4888 | 4904 |
| 4889 repeatedValues->append(trackSize); | 4905 repeatedValues->append(trackSize); |
| 4890 | 4906 |
| 4891 // This takes care of any trailing <string>* in the grammar. | 4907 // This takes care of any trailing <ident>* in the grammar. |
| 4892 while (arguments->current() && arguments->current()->unit == CSSPrimitiv
eValue::CSS_STRING) { | 4908 currentValue = arguments->current(); |
| 4893 RefPtr<CSSPrimitiveValue> name = createPrimitiveStringValue(argument
s->current()); | 4909 if (currentValue && currentValue->unit == CSSParserValue::ValueList) |
| 4894 repeatedValues->append(name); | 4910 parseGridLineNames(arguments, *repeatedValues); |
| 4895 arguments->next(); | |
| 4896 } | |
| 4897 } | 4911 } |
| 4898 | 4912 |
| 4899 for (size_t i = 0; i < repetitions; ++i) { | 4913 for (size_t i = 0; i < repetitions; ++i) { |
| 4900 for (size_t j = 0; j < repeatedValues->length(); ++j) | 4914 for (size_t j = 0; j < repeatedValues->length(); ++j) |
| 4901 list.append(repeatedValues->itemWithoutBoundsCheck(j)); | 4915 list.append(repeatedValues->itemWithoutBoundsCheck(j)); |
| 4902 } | 4916 } |
| 4903 | 4917 |
| 4904 // parseGridTrackSize iterated over the repeat arguments, move to the next v
alue. | 4918 // parseGridTrackSize iterated over the repeat arguments, move to the next v
alue. |
| 4905 m_valueList->next(); | 4919 m_valueList->next(); |
| 4906 return true; | 4920 return true; |
| (...skipping 7046 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11953 { | 11967 { |
| 11954 // The tokenizer checks for the construct of an+b. | 11968 // The tokenizer checks for the construct of an+b. |
| 11955 // However, since the {ident} rule precedes the {nth} rule, some of those | 11969 // However, since the {ident} rule precedes the {nth} rule, some of those |
| 11956 // tokens are identified as string literal. Furthermore we need to accept | 11970 // tokens are identified as string literal. Furthermore we need to accept |
| 11957 // "odd" and "even" which does not match to an+b. | 11971 // "odd" and "even" which does not match to an+b. |
| 11958 return equalIgnoringCase(token, "odd") || equalIgnoringCase(token, "even") | 11972 return equalIgnoringCase(token, "odd") || equalIgnoringCase(token, "even") |
| 11959 || equalIgnoringCase(token, "n") || equalIgnoringCase(token, "-n"); | 11973 || equalIgnoringCase(token, "n") || equalIgnoringCase(token, "-n"); |
| 11960 } | 11974 } |
| 11961 | 11975 |
| 11962 } | 11976 } |
| OLD | NEW |