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 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 { | 116 { |
117 ASSERT(value->unit == CSSPrimitiveValue::CSS_IDENT || value->unit == CSSPrim
itiveValue::CSS_STRING); | 117 ASSERT(value->unit == CSSPrimitiveValue::CSS_IDENT || value->unit == CSSPrim
itiveValue::CSS_STRING); |
118 return equalIgnoringCase(value->string, b); | 118 return equalIgnoringCase(value->string, b); |
119 } | 119 } |
120 | 120 |
121 static PassRefPtrWillBeRawPtr<CSSPrimitiveValue> createPrimitiveValuePair(PassRe
fPtrWillBeRawPtr<CSSPrimitiveValue> first, PassRefPtrWillBeRawPtr<CSSPrimitiveVa
lue> second, Pair::IdenticalValuesPolicy identicalValuesPolicy = Pair::DropIdent
icalValues) | 121 static PassRefPtrWillBeRawPtr<CSSPrimitiveValue> createPrimitiveValuePair(PassRe
fPtrWillBeRawPtr<CSSPrimitiveValue> first, PassRefPtrWillBeRawPtr<CSSPrimitiveVa
lue> second, Pair::IdenticalValuesPolicy identicalValuesPolicy = Pair::DropIdent
icalValues) |
122 { | 122 { |
123 return cssValuePool().createValue(Pair::create(first, second, identicalValue
sPolicy)); | 123 return cssValuePool().createValue(Pair::create(first, second, identicalValue
sPolicy)); |
124 } | 124 } |
125 | 125 |
126 class AnimationParseContext { | |
127 public: | |
128 AnimationParseContext() | |
129 : m_animationPropertyKeywordAllowed(true) | |
130 , m_firstAnimationCommitted(false) | |
131 { | |
132 } | |
133 | |
134 void commitFirstAnimation() | |
135 { | |
136 m_firstAnimationCommitted = true; | |
137 } | |
138 | |
139 bool hasCommittedFirstAnimation() const | |
140 { | |
141 return m_firstAnimationCommitted; | |
142 } | |
143 | |
144 void commitAnimationPropertyKeyword() | |
145 { | |
146 m_animationPropertyKeywordAllowed = false; | |
147 } | |
148 | |
149 bool animationPropertyKeywordAllowed() const | |
150 { | |
151 return m_animationPropertyKeywordAllowed; | |
152 } | |
153 | |
154 private: | |
155 bool m_animationPropertyKeywordAllowed; | |
156 bool m_firstAnimationCommitted; | |
157 }; | |
158 | |
159 CSSPropertyParser::CSSPropertyParser(OwnPtr<CSSParserValueList>& valueList, | 126 CSSPropertyParser::CSSPropertyParser(OwnPtr<CSSParserValueList>& valueList, |
160 const CSSParserContext& context, bool inViewport, bool savedImportant, | 127 const CSSParserContext& context, bool inViewport, bool savedImportant, |
161 WillBeHeapVector<CSSProperty, 256>& parsedProperties, | 128 WillBeHeapVector<CSSProperty, 256>& parsedProperties, |
162 CSSRuleSourceData::Type ruleType) | 129 CSSRuleSourceData::Type ruleType) |
163 : m_valueList(valueList) | 130 : m_valueList(valueList) |
164 , m_context(context) | 131 , m_context(context) |
165 , m_inViewport(inViewport) | 132 , m_inViewport(inViewport) |
166 , m_important(savedImportant) // See comment in header, should be removed. | 133 , m_important(savedImportant) // See comment in header, should be removed. |
167 , m_parsedProperties(parsedProperties) | 134 , m_parsedProperties(parsedProperties) |
168 , m_ruleType(ruleType) | 135 , m_ruleType(ruleType) |
(...skipping 1045 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1214 case CSSPropertyWebkitAnimationIterationCount: | 1181 case CSSPropertyWebkitAnimationIterationCount: |
1215 case CSSPropertyWebkitAnimationTimingFunction: | 1182 case CSSPropertyWebkitAnimationTimingFunction: |
1216 case CSSPropertyTransitionDelay: | 1183 case CSSPropertyTransitionDelay: |
1217 case CSSPropertyTransitionDuration: | 1184 case CSSPropertyTransitionDuration: |
1218 case CSSPropertyTransitionTimingFunction: | 1185 case CSSPropertyTransitionTimingFunction: |
1219 case CSSPropertyTransitionProperty: | 1186 case CSSPropertyTransitionProperty: |
1220 case CSSPropertyWebkitTransitionDelay: | 1187 case CSSPropertyWebkitTransitionDelay: |
1221 case CSSPropertyWebkitTransitionDuration: | 1188 case CSSPropertyWebkitTransitionDuration: |
1222 case CSSPropertyWebkitTransitionTimingFunction: | 1189 case CSSPropertyWebkitTransitionTimingFunction: |
1223 case CSSPropertyWebkitTransitionProperty: { | 1190 case CSSPropertyWebkitTransitionProperty: { |
1224 RefPtrWillBeRawPtr<CSSValue> val = nullptr; | 1191 if (RefPtrWillBeRawPtr<CSSValueList> val = parseAnimationPropertyList(pr
opId)) { |
1225 AnimationParseContext context; | |
1226 if (parseAnimationProperty(propId, val, context)) { | |
1227 addPropertyWithPrefixingVariant(propId, val.release(), important); | 1192 addPropertyWithPrefixingVariant(propId, val.release(), important); |
1228 return true; | 1193 return true; |
1229 } | 1194 } |
1230 return false; | 1195 return false; |
1231 } | 1196 } |
1232 | 1197 |
1233 case CSSPropertyJustifySelf: | 1198 case CSSPropertyJustifySelf: |
1234 if (!RuntimeEnabledFeatures::cssGridLayoutEnabled()) | 1199 if (!RuntimeEnabledFeatures::cssGridLayoutEnabled()) |
1235 return false; | 1200 return false; |
1236 | 1201 |
(...skipping 603 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1840 if (properties[i] == CSSPropertyBackgroundOrigin && !foundClip) | 1805 if (properties[i] == CSSPropertyBackgroundOrigin && !foundClip) |
1841 addProperty(CSSPropertyBackgroundClip, clipValue.release(), importan
t); | 1806 addProperty(CSSPropertyBackgroundClip, clipValue.release(), importan
t); |
1842 else if (properties[i] == CSSPropertyWebkitMaskOrigin && !foundClip) | 1807 else if (properties[i] == CSSPropertyWebkitMaskOrigin && !foundClip) |
1843 addProperty(CSSPropertyWebkitMaskClip, clipValue.release(), importan
t); | 1808 addProperty(CSSPropertyWebkitMaskClip, clipValue.release(), importan
t); |
1844 } | 1809 } |
1845 | 1810 |
1846 m_implicitShorthand = false; | 1811 m_implicitShorthand = false; |
1847 return true; | 1812 return true; |
1848 } | 1813 } |
1849 | 1814 |
1850 void CSSPropertyParser::addAnimationValue(RefPtrWillBeRawPtr<CSSValue>& lval, Pa
ssRefPtrWillBeRawPtr<CSSValue> rval) | 1815 static bool isValidTransitionPropertyList(CSSValueList* value) |
1851 { | 1816 { |
1852 if (lval) { | 1817 if (value->length() < 2) |
1853 if (lval->isValueList()) | 1818 return true; |
1854 toCSSValueList(lval.get())->append(rval); | 1819 for (CSSValueListIterator i = value; i.hasMore(); i.advance()) { |
1855 else { | 1820 // FIXME: Shorthand parsing shouldn't add initial to the list since it w
on't round-trip |
1856 PassRefPtrWillBeRawPtr<CSSValue> oldVal(lval.release()); | 1821 if (i.value()->isInitialValue()) |
1857 PassRefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createComm
aSeparated(); | 1822 continue; |
1858 list->append(oldVal); | 1823 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(i.value()); |
1859 list->append(rval); | 1824 if (primitiveValue->isValueID() && primitiveValue->getValueID() == CSSVa
lueNone) |
1860 lval = list; | 1825 return false; |
1861 } | |
1862 } | 1826 } |
1863 else | 1827 return true; |
1864 lval = rval; | |
1865 } | 1828 } |
1866 | 1829 |
1867 bool CSSPropertyParser::parseAnimationShorthand(CSSPropertyID propId, bool impor
tant) | 1830 bool CSSPropertyParser::parseAnimationShorthand(CSSPropertyID propId, bool impor
tant) |
1868 { | 1831 { |
1869 const StylePropertyShorthand& animationProperties = parsingShorthandForPrope
rty(propId); | 1832 const StylePropertyShorthand& animationProperties = parsingShorthandForPrope
rty(propId); |
1870 const unsigned numProperties = 8; | 1833 const unsigned numProperties = 8; |
1871 | 1834 |
1872 // The list of properties in the shorthand should be the same | 1835 // The list of properties in the shorthand should be the same |
1873 // length as the list with animation name in last position, even though they
are | 1836 // length as the list with animation name in last position, even though they
are |
1874 // in a different order. | 1837 // in a different order. |
1875 ASSERT(numProperties == animationProperties.length()); | 1838 ASSERT(numProperties == animationProperties.length()); |
1876 ASSERT(numProperties == shorthandForProperty(propId).length()); | 1839 ASSERT(numProperties == shorthandForProperty(propId).length()); |
1877 | 1840 |
1878 ShorthandScope scope(this, propId); | 1841 ShorthandScope scope(this, propId); |
1879 | 1842 |
1880 bool parsedProperty[numProperties] = { false }; | 1843 bool parsedProperty[numProperties] = { false }; |
1881 AnimationParseContext context; | 1844 RefPtrWillBeRawPtr<CSSValueList> values[numProperties]; |
1882 RefPtrWillBeRawPtr<CSSValue> values[numProperties]; | 1845 for (size_t i = 0; i < numProperties; ++i) |
1883 #if ENABLE(OILPAN) | 1846 values[i] = CSSValueList::createCommaSeparated(); |
1884 // Zero initialize the array of raw pointers. | |
1885 memset(&values, 0, sizeof(values)); | |
1886 #endif | |
1887 | 1847 |
1888 unsigned i; | |
1889 while (m_valueList->current()) { | 1848 while (m_valueList->current()) { |
1890 CSSParserValue* val = m_valueList->current(); | 1849 CSSParserValue* val = m_valueList->current(); |
1891 if (val->unit == CSSParserValue::Operator && val->iValue == ',') { | 1850 if (val->unit == CSSParserValue::Operator && val->iValue == ',') { |
1892 // We hit the end. Fill in all remaining values with the initial va
lue. | 1851 // We hit the end. Fill in all remaining values with the initial val
ue. |
1893 m_valueList->next(); | 1852 m_valueList->next(); |
1894 for (i = 0; i < numProperties; ++i) { | 1853 for (size_t i = 0; i < numProperties; ++i) { |
1895 if (!parsedProperty[i]) | 1854 if (!parsedProperty[i]) |
1896 addAnimationValue(values[i], cssValuePool().createImplicitIn
itialValue()); | 1855 values[i]->append(cssValuePool().createImplicitInitialValue(
)); |
1897 parsedProperty[i] = false; | 1856 parsedProperty[i] = false; |
1898 } | 1857 } |
1899 if (!m_valueList->current()) | 1858 if (!m_valueList->current()) |
1900 break; | 1859 break; |
1901 context.commitFirstAnimation(); | |
1902 } | 1860 } |
1903 | 1861 |
1904 bool found = false; | 1862 bool found = false; |
1905 for (i = 0; i < numProperties; ++i) { | 1863 for (size_t i = 0; i < numProperties; ++i) { |
1906 if (!parsedProperty[i]) { | 1864 if (parsedProperty[i]) |
1907 RefPtrWillBeRawPtr<CSSValue> val = nullptr; | 1865 continue; |
1908 if (parseAnimationProperty(animationProperties.properties()[i],
val, context)) { | 1866 if (RefPtrWillBeRawPtr<CSSValue> val = parseAnimationProperty(animat
ionProperties.properties()[i])) { |
1909 parsedProperty[i] = found = true; | 1867 parsedProperty[i] = found = true; |
1910 addAnimationValue(values[i], val.release()); | 1868 values[i]->append(val.release()); |
1911 break; | 1869 break; |
1912 } | |
1913 } | 1870 } |
1914 } | 1871 } |
1915 | 1872 |
1916 // if we didn't find at least one match, this is an | 1873 // if we didn't find at least one match, this is an |
1917 // invalid shorthand and we have to ignore it | 1874 // invalid shorthand and we have to ignore it |
1918 if (!found) | 1875 if (!found) |
1919 return false; | 1876 return false; |
1920 } | 1877 } |
1921 | 1878 |
1922 for (i = 0; i < numProperties; ++i) { | 1879 for (size_t i = 0; i < numProperties; ++i) { |
1923 // If we didn't find the property, set an intial value. | 1880 // If we didn't find the property, set an intial value. |
1924 if (!parsedProperty[i]) | 1881 if (!parsedProperty[i]) |
1925 addAnimationValue(values[i], cssValuePool().createImplicitInitialVal
ue()); | 1882 values[i]->append(cssValuePool().createImplicitInitialValue()); |
1926 | 1883 |
1927 if (RuntimeEnabledFeatures::cssAnimationUnprefixedEnabled()) | 1884 if (RuntimeEnabledFeatures::cssAnimationUnprefixedEnabled()) |
1928 addPropertyWithPrefixingVariant(animationProperties.properties()[i],
values[i].release(), important); | 1885 addPropertyWithPrefixingVariant(animationProperties.properties()[i],
values[i].release(), important); |
1929 else | 1886 else |
1930 addProperty(animationProperties.properties()[i], values[i].release()
, important); | 1887 addProperty(animationProperties.properties()[i], values[i].release()
, important); |
1931 } | 1888 } |
1932 | 1889 |
1933 return true; | 1890 return true; |
1934 } | 1891 } |
1935 | 1892 |
1936 bool CSSPropertyParser::parseTransitionShorthand(CSSPropertyID propId, bool impo
rtant) | 1893 bool CSSPropertyParser::parseTransitionShorthand(CSSPropertyID propId, bool impo
rtant) |
1937 { | 1894 { |
1938 const unsigned numProperties = 4; | 1895 const unsigned numProperties = 4; |
1939 const StylePropertyShorthand& shorthand = shorthandForProperty(propId); | 1896 const StylePropertyShorthand& shorthand = shorthandForProperty(propId); |
1940 ASSERT(numProperties == shorthand.length()); | 1897 ASSERT(numProperties == shorthand.length()); |
1941 | 1898 |
1942 ShorthandScope scope(this, propId); | 1899 ShorthandScope scope(this, propId); |
1943 | 1900 |
1944 bool parsedProperty[numProperties] = { false }; | 1901 bool parsedProperty[numProperties] = { false }; |
1945 AnimationParseContext context; | 1902 RefPtrWillBeRawPtr<CSSValueList> values[numProperties]; |
1946 RefPtrWillBeRawPtr<CSSValue> values[numProperties]; | 1903 for (size_t i = 0; i < numProperties; ++i) |
1947 #if ENABLE(OILPAN) | 1904 values[i] = CSSValueList::createCommaSeparated(); |
1948 // Zero initialize the array of raw pointers. | |
1949 memset(&values, 0, sizeof(values)); | |
1950 #endif | |
1951 | 1905 |
1952 unsigned i; | |
1953 while (m_valueList->current()) { | 1906 while (m_valueList->current()) { |
1954 CSSParserValue* val = m_valueList->current(); | 1907 CSSParserValue* val = m_valueList->current(); |
1955 if (val->unit == CSSParserValue::Operator && val->iValue == ',') { | 1908 if (val->unit == CSSParserValue::Operator && val->iValue == ',') { |
1956 // We hit the end. Fill in all remaining values with the initial val
ue. | 1909 // We hit the end. Fill in all remaining values with the initial val
ue. |
1957 m_valueList->next(); | 1910 m_valueList->next(); |
1958 for (i = 0; i < numProperties; ++i) { | 1911 for (size_t i = 0; i < numProperties; ++i) { |
1959 if (!parsedProperty[i]) | 1912 if (!parsedProperty[i]) |
1960 addAnimationValue(values[i], cssValuePool().createImplicitIn
itialValue()); | 1913 values[i]->append(cssValuePool().createImplicitInitialValue(
)); |
1961 parsedProperty[i] = false; | 1914 parsedProperty[i] = false; |
1962 } | 1915 } |
1963 if (!m_valueList->current()) | 1916 if (!m_valueList->current()) |
1964 break; | 1917 break; |
1965 context.commitFirstAnimation(); | |
1966 } | 1918 } |
1967 | 1919 |
1968 bool found = false; | 1920 bool found = false; |
1969 for (i = 0; !found && i < numProperties; ++i) { | 1921 for (size_t i = 0; i < numProperties; ++i) { |
1970 if (!parsedProperty[i]) { | 1922 if (parsedProperty[i]) |
1971 RefPtrWillBeRawPtr<CSSValue> val = nullptr; | 1923 continue; |
1972 if (parseAnimationProperty(shorthand.properties()[i], val, conte
xt)) { | 1924 if (RefPtrWillBeRawPtr<CSSValue> val = parseAnimationProperty(shorth
and.properties()[i])) { |
1973 parsedProperty[i] = found = true; | 1925 parsedProperty[i] = found = true; |
1974 addAnimationValue(values[i], val.release()); | 1926 values[i]->append(val.release()); |
1975 } | 1927 break; |
1976 | |
1977 // There are more values to process but 'none' or 'all' were alr
eady defined as the animation property, the declaration becomes invalid. | |
1978 if (!context.animationPropertyKeywordAllowed() && context.hasCom
mittedFirstAnimation()) | |
1979 return false; | |
1980 } | 1928 } |
1981 } | 1929 } |
1982 | 1930 |
1983 // if we didn't find at least one match, this is an | 1931 // if we didn't find at least one match, this is an |
1984 // invalid shorthand and we have to ignore it | 1932 // invalid shorthand and we have to ignore it |
1985 if (!found) | 1933 if (!found) |
1986 return false; | 1934 return false; |
1987 } | 1935 } |
1988 | 1936 |
1989 // Fill in any remaining properties with the initial value. | 1937 ASSERT(shorthand.properties()[0] == CSSPropertyTransitionProperty || shortha
nd.properties()[0] == CSSPropertyWebkitTransitionProperty); |
1990 for (i = 0; i < numProperties; ++i) { | 1938 if (!isValidTransitionPropertyList(values[0].get())) |
| 1939 return false; |
| 1940 |
| 1941 // Fill in any remaining properties with the initial value and add |
| 1942 for (size_t i = 0; i < numProperties; ++i) { |
1991 if (!parsedProperty[i]) | 1943 if (!parsedProperty[i]) |
1992 addAnimationValue(values[i], cssValuePool().createImplicitInitialVal
ue()); | 1944 values[i]->append(cssValuePool().createImplicitInitialValue()); |
| 1945 addPropertyWithPrefixingVariant(shorthand.properties()[i], values[i].rel
ease(), important); |
1993 } | 1946 } |
1994 | 1947 |
1995 // Now add all of the properties we found. | |
1996 for (i = 0; i < numProperties; i++) | |
1997 addPropertyWithPrefixingVariant(shorthand.properties()[i], values[i].rel
ease(), important); | |
1998 | |
1999 return true; | 1948 return true; |
2000 } | 1949 } |
2001 | 1950 |
2002 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseColumnWidth() | 1951 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseColumnWidth() |
2003 { | 1952 { |
2004 CSSParserValue* value = m_valueList->current(); | 1953 CSSParserValue* value = m_valueList->current(); |
2005 // Always parse lengths in strict mode here, since it would be ambiguous oth
erwise when used in | 1954 // Always parse lengths in strict mode here, since it would be ambiguous oth
erwise when used in |
2006 // the 'columns' shorthand property. | 1955 // the 'columns' shorthand property. |
2007 if (value->id == CSSValueAuto | 1956 if (value->id == CSSValueAuto |
2008 || (validUnit(value, FLength | FNonNeg, HTMLStandardMode) && value->fVal
ue)) { | 1957 || (validUnit(value, FLength | FNonNeg, HTMLStandardMode) && value->fVal
ue)) { |
(...skipping 1103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3112 } | 3061 } |
3113 | 3062 |
3114 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseAnimationPlayState() | 3063 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseAnimationPlayState() |
3115 { | 3064 { |
3116 CSSParserValue* value = m_valueList->current(); | 3065 CSSParserValue* value = m_valueList->current(); |
3117 if (value->id == CSSValueRunning || value->id == CSSValuePaused) | 3066 if (value->id == CSSValueRunning || value->id == CSSValuePaused) |
3118 return cssValuePool().createIdentifierValue(value->id); | 3067 return cssValuePool().createIdentifierValue(value->id); |
3119 return nullptr; | 3068 return nullptr; |
3120 } | 3069 } |
3121 | 3070 |
3122 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseAnimationProperty(Anima
tionParseContext& context) | 3071 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseAnimationProperty() |
3123 { | 3072 { |
3124 CSSParserValue* value = m_valueList->current(); | 3073 CSSParserValue* value = m_valueList->current(); |
3125 if (value->unit != CSSPrimitiveValue::CSS_IDENT) | 3074 if (value->unit != CSSPrimitiveValue::CSS_IDENT) |
3126 return nullptr; | 3075 return nullptr; |
3127 CSSPropertyID result = cssPropertyID(value->string); | 3076 CSSPropertyID result = cssPropertyID(value->string); |
3128 if (result && RuntimeCSSEnabled::isCSSPropertyEnabled(result)) | 3077 if (result && RuntimeCSSEnabled::isCSSPropertyEnabled(result)) |
3129 return cssValuePool().createIdentifierValue(result); | 3078 return cssValuePool().createIdentifierValue(result); |
3130 if (equalIgnoringCase(value, "all")) | 3079 if (equalIgnoringCase(value, "all")) |
3131 return cssValuePool().createIdentifierValue(CSSValueAll); | 3080 return cssValuePool().createIdentifierValue(CSSValueAll); |
3132 if (equalIgnoringCase(value, "none")) { | 3081 if (equalIgnoringCase(value, "none")) |
3133 context.commitAnimationPropertyKeyword(); | |
3134 return cssValuePool().createIdentifierValue(CSSValueNone); | 3082 return cssValuePool().createIdentifierValue(CSSValueNone); |
3135 } | |
3136 return nullptr; | 3083 return nullptr; |
3137 } | 3084 } |
3138 | 3085 |
3139 bool CSSPropertyParser::parseWebkitTransformOriginShorthand(RefPtrWillBeRawPtr<C
SSValue>& value1, RefPtrWillBeRawPtr<CSSValue>& value2, RefPtrWillBeRawPtr<CSSVa
lue>& value3) | 3086 bool CSSPropertyParser::parseWebkitTransformOriginShorthand(RefPtrWillBeRawPtr<C
SSValue>& value1, RefPtrWillBeRawPtr<CSSValue>& value2, RefPtrWillBeRawPtr<CSSVa
lue>& value3) |
3140 { | 3087 { |
3141 parse2ValuesFillPosition(m_valueList.get(), value1, value2); | 3088 parse2ValuesFillPosition(m_valueList.get(), value1, value2); |
3142 | 3089 |
3143 // now get z | 3090 // now get z |
3144 if (m_valueList->current()) { | 3091 if (m_valueList->current()) { |
3145 if (validUnit(m_valueList->current(), FLength)) { | 3092 if (validUnit(m_valueList->current(), FLength)) { |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3245 return nullptr; | 3192 return nullptr; |
3246 if (!parseCubicBezierTimingFunctionValue(args, y2)) | 3193 if (!parseCubicBezierTimingFunctionValue(args, y2)) |
3247 return nullptr; | 3194 return nullptr; |
3248 | 3195 |
3249 return CSSCubicBezierTimingFunctionValue::create(x1, y1, x2, y2); | 3196 return CSSCubicBezierTimingFunctionValue::create(x1, y1, x2, y2); |
3250 } | 3197 } |
3251 | 3198 |
3252 return nullptr; | 3199 return nullptr; |
3253 } | 3200 } |
3254 | 3201 |
3255 bool CSSPropertyParser::parseAnimationProperty(CSSPropertyID propId, RefPtrWillB
eRawPtr<CSSValue>& result, AnimationParseContext& context) | 3202 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseAnimationProperty(CSSPr
opertyID propId) |
3256 { | 3203 { |
3257 RefPtrWillBeRawPtr<CSSValueList> values = nullptr; | |
3258 CSSParserValue* val; | |
3259 RefPtrWillBeRawPtr<CSSValue> value = nullptr; | 3204 RefPtrWillBeRawPtr<CSSValue> value = nullptr; |
3260 bool allowComma = false; | 3205 switch (propId) { |
3261 | 3206 case CSSPropertyAnimationDelay: |
3262 result = nullptr; | 3207 case CSSPropertyWebkitAnimationDelay: |
3263 | 3208 case CSSPropertyTransitionDelay: |
3264 while ((val = m_valueList->current())) { | 3209 case CSSPropertyWebkitTransitionDelay: |
3265 RefPtrWillBeRawPtr<CSSValue> currValue = nullptr; | 3210 value = parseAnimationDelay(); |
3266 if (allowComma) { | 3211 break; |
3267 if (!isComma(val)) | 3212 case CSSPropertyAnimationDirection: |
3268 return false; | 3213 case CSSPropertyWebkitAnimationDirection: |
3269 m_valueList->next(); | 3214 value = parseAnimationDirection(); |
3270 allowComma = false; | 3215 break; |
3271 } | 3216 case CSSPropertyAnimationDuration: |
3272 else { | 3217 case CSSPropertyWebkitAnimationDuration: |
3273 switch (propId) { | 3218 case CSSPropertyTransitionDuration: |
3274 case CSSPropertyAnimationDelay: | 3219 case CSSPropertyWebkitTransitionDuration: |
3275 case CSSPropertyWebkitAnimationDelay: | 3220 value = parseAnimationDuration(); |
3276 case CSSPropertyTransitionDelay: | 3221 break; |
3277 case CSSPropertyWebkitTransitionDelay: | 3222 case CSSPropertyAnimationFillMode: |
3278 currValue = parseAnimationDelay(); | 3223 case CSSPropertyWebkitAnimationFillMode: |
3279 if (currValue) | 3224 value = parseAnimationFillMode(); |
3280 m_valueList->next(); | 3225 break; |
3281 break; | 3226 case CSSPropertyAnimationIterationCount: |
3282 case CSSPropertyAnimationDirection: | 3227 case CSSPropertyWebkitAnimationIterationCount: |
3283 case CSSPropertyWebkitAnimationDirection: | 3228 value = parseAnimationIterationCount(); |
3284 currValue = parseAnimationDirection(); | 3229 break; |
3285 if (currValue) | 3230 case CSSPropertyAnimationName: |
3286 m_valueList->next(); | 3231 case CSSPropertyWebkitAnimationName: |
3287 break; | 3232 value = parseAnimationName(); |
3288 case CSSPropertyAnimationDuration: | 3233 break; |
3289 case CSSPropertyWebkitAnimationDuration: | 3234 case CSSPropertyAnimationPlayState: |
3290 case CSSPropertyTransitionDuration: | 3235 case CSSPropertyWebkitAnimationPlayState: |
3291 case CSSPropertyWebkitTransitionDuration: | 3236 value = parseAnimationPlayState(); |
3292 currValue = parseAnimationDuration(); | 3237 break; |
3293 if (currValue) | 3238 case CSSPropertyTransitionProperty: |
3294 m_valueList->next(); | 3239 case CSSPropertyWebkitTransitionProperty: |
3295 break; | 3240 value = parseAnimationProperty(); |
3296 case CSSPropertyAnimationFillMode: | 3241 break; |
3297 case CSSPropertyWebkitAnimationFillMode: | 3242 case CSSPropertyAnimationTimingFunction: |
3298 currValue = parseAnimationFillMode(); | 3243 case CSSPropertyWebkitAnimationTimingFunction: |
3299 if (currValue) | 3244 case CSSPropertyTransitionTimingFunction: |
3300 m_valueList->next(); | 3245 case CSSPropertyWebkitTransitionTimingFunction: |
3301 break; | 3246 value = parseAnimationTimingFunction(); |
3302 case CSSPropertyAnimationIterationCount: | 3247 break; |
3303 case CSSPropertyWebkitAnimationIterationCount: | 3248 default: |
3304 currValue = parseAnimationIterationCount(); | 3249 ASSERT_NOT_REACHED(); |
3305 if (currValue) | 3250 return nullptr; |
3306 m_valueList->next(); | |
3307 break; | |
3308 case CSSPropertyAnimationName: | |
3309 case CSSPropertyWebkitAnimationName: | |
3310 currValue = parseAnimationName(); | |
3311 if (currValue) | |
3312 m_valueList->next(); | |
3313 break; | |
3314 case CSSPropertyAnimationPlayState: | |
3315 case CSSPropertyWebkitAnimationPlayState: | |
3316 currValue = parseAnimationPlayState(); | |
3317 if (currValue) | |
3318 m_valueList->next(); | |
3319 break; | |
3320 case CSSPropertyTransitionProperty: | |
3321 case CSSPropertyWebkitTransitionProperty: | |
3322 currValue = parseAnimationProperty(context); | |
3323 if (value && !context.animationPropertyKeywordAllowed()) | |
3324 return false; | |
3325 if (currValue) | |
3326 m_valueList->next(); | |
3327 break; | |
3328 case CSSPropertyAnimationTimingFunction: | |
3329 case CSSPropertyWebkitAnimationTimingFunction: | |
3330 case CSSPropertyTransitionTimingFunction: | |
3331 case CSSPropertyWebkitTransitionTimingFunction: | |
3332 currValue = parseAnimationTimingFunction(); | |
3333 if (currValue) | |
3334 m_valueList->next(); | |
3335 break; | |
3336 default: | |
3337 ASSERT_NOT_REACHED(); | |
3338 return false; | |
3339 } | |
3340 | |
3341 if (!currValue) | |
3342 return false; | |
3343 | |
3344 if (value && !values) { | |
3345 values = CSSValueList::createCommaSeparated(); | |
3346 values->append(value.release()); | |
3347 } | |
3348 | |
3349 if (values) | |
3350 values->append(currValue.release()); | |
3351 else | |
3352 value = currValue.release(); | |
3353 | |
3354 allowComma = true; | |
3355 } | |
3356 | |
3357 // When parsing the 'transition' shorthand property, we let it handle bu
ilding up the lists for all | |
3358 // properties. | |
3359 if (inShorthand()) | |
3360 break; | |
3361 } | 3251 } |
3362 | 3252 |
3363 if (values && values->length()) { | 3253 if (value) |
3364 result = values.release(); | 3254 m_valueList->next(); |
3365 return true; | 3255 return value.release(); |
| 3256 } |
| 3257 |
| 3258 PassRefPtrWillBeRawPtr<CSSValueList> CSSPropertyParser::parseAnimationPropertyLi
st(CSSPropertyID propId) |
| 3259 { |
| 3260 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createCommaSeparated()
; |
| 3261 while (m_valueList->current()) { |
| 3262 RefPtrWillBeRawPtr<CSSValue> value = parseAnimationProperty(propId); |
| 3263 if (!value) |
| 3264 return nullptr; |
| 3265 list->append(value.release()); |
| 3266 if (CSSParserValue* parserValue = m_valueList->current()) { |
| 3267 if (!isComma(parserValue)) |
| 3268 return nullptr; |
| 3269 m_valueList->next(); |
| 3270 ASSERT(m_valueList->current()); |
| 3271 } |
3366 } | 3272 } |
3367 if (value) { | 3273 if ((propId == CSSPropertyTransitionProperty || propId == CSSPropertyWebkitT
ransitionProperty) && !isValidTransitionPropertyList(list.get())) |
3368 result = value.release(); | 3274 return nullptr; |
3369 return true; | 3275 ASSERT(list->length()); |
3370 } | 3276 return list.release(); |
3371 return false; | |
3372 } | 3277 } |
3373 | 3278 |
3374 static inline bool isCSSWideKeyword(CSSParserValue& value) | 3279 static inline bool isCSSWideKeyword(CSSParserValue& value) |
3375 { | 3280 { |
3376 return value.id == CSSValueInitial || value.id == CSSValueInherit || value.i
d == CSSValueDefault; | 3281 return value.id == CSSValueInitial || value.id == CSSValueInherit || value.i
d == CSSValueDefault; |
3377 } | 3282 } |
3378 | 3283 |
3379 static inline bool isValidCustomIdentForGridPositions(CSSParserValue& value) | 3284 static inline bool isValidCustomIdentForGridPositions(CSSParserValue& value) |
3380 { | 3285 { |
3381 // FIXME: we need a more general solution for <custom-ident> in all properti
es. | 3286 // FIXME: we need a more general solution for <custom-ident> in all properti
es. |
(...skipping 5131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8513 parsedValues->append(CSSPrimitiveValue::createIdentifier(CSSValueFill)); | 8418 parsedValues->append(CSSPrimitiveValue::createIdentifier(CSSValueFill)); |
8514 if (!seenStroke) | 8419 if (!seenStroke) |
8515 parsedValues->append(CSSPrimitiveValue::createIdentifier(CSSValueStroke)
); | 8420 parsedValues->append(CSSPrimitiveValue::createIdentifier(CSSValueStroke)
); |
8516 if (!seenMarkers) | 8421 if (!seenMarkers) |
8517 parsedValues->append(CSSPrimitiveValue::createIdentifier(CSSValueMarkers
)); | 8422 parsedValues->append(CSSPrimitiveValue::createIdentifier(CSSValueMarkers
)); |
8518 | 8423 |
8519 return parsedValues.release(); | 8424 return parsedValues.release(); |
8520 } | 8425 } |
8521 | 8426 |
8522 } // namespace WebCore | 8427 } // namespace WebCore |
OLD | NEW |