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 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
234 m_logErrors = logErrors && sheet->singleOwnerDocument() && !sheet->baseURL()
.isEmpty() && sheet->singleOwnerDocument()->frameHost(); | 234 m_logErrors = logErrors && sheet->singleOwnerDocument() && !sheet->baseURL()
.isEmpty() && sheet->singleOwnerDocument()->frameHost(); |
235 m_ignoreErrors = false; | 235 m_ignoreErrors = false; |
236 m_tokenizer.m_lineNumber = 0; | 236 m_tokenizer.m_lineNumber = 0; |
237 m_startPosition = startPosition; | 237 m_startPosition = startPosition; |
238 m_source = &string; | 238 m_source = &string; |
239 m_tokenizer.m_internal = false; | 239 m_tokenizer.m_internal = false; |
240 setupParser("", string, ""); | 240 setupParser("", string, ""); |
241 cssyyparse(this); | 241 cssyyparse(this); |
242 sheet->shrinkToFit(); | 242 sheet->shrinkToFit(); |
243 m_source = 0; | 243 m_source = 0; |
244 m_rule = 0; | 244 m_rule = nullptr; |
245 m_lineEndings.clear(); | 245 m_lineEndings.clear(); |
246 m_ignoreErrors = false; | 246 m_ignoreErrors = false; |
247 m_logErrors = false; | 247 m_logErrors = false; |
248 m_tokenizer.m_internal = true; | 248 m_tokenizer.m_internal = true; |
249 } | 249 } |
250 | 250 |
251 PassRefPtr<StyleRuleBase> BisonCSSParser::parseRule(StyleSheetContents* sheet, c
onst String& string) | 251 PassRefPtr<StyleRuleBase> BisonCSSParser::parseRule(StyleSheetContents* sheet, c
onst String& string) |
252 { | 252 { |
253 setStyleSheet(sheet); | 253 setStyleSheet(sheet); |
254 m_allowNamespaceDeclarations = false; | 254 m_allowNamespaceDeclarations = false; |
(...skipping 719 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
974 } | 974 } |
975 return true; | 975 return true; |
976 } | 976 } |
977 | 977 |
978 template <typename CharType> | 978 template <typename CharType> |
979 static PassRefPtrWillBeRawPtr<CSSTransformValue> parseTranslateTransformValue(Ch
arType*& pos, CharType* end) | 979 static PassRefPtrWillBeRawPtr<CSSTransformValue> parseTranslateTransformValue(Ch
arType*& pos, CharType* end) |
980 { | 980 { |
981 static const int shortestValidTransformStringLength = 12; | 981 static const int shortestValidTransformStringLength = 12; |
982 | 982 |
983 if (end - pos < shortestValidTransformStringLength) | 983 if (end - pos < shortestValidTransformStringLength) |
984 return 0; | 984 return nullptr; |
985 | 985 |
986 if ((pos[0] != 't' && pos[0] != 'T') | 986 if ((pos[0] != 't' && pos[0] != 'T') |
987 || (pos[1] != 'r' && pos[1] != 'R') | 987 || (pos[1] != 'r' && pos[1] != 'R') |
988 || (pos[2] != 'a' && pos[2] != 'A') | 988 || (pos[2] != 'a' && pos[2] != 'A') |
989 || (pos[3] != 'n' && pos[3] != 'N') | 989 || (pos[3] != 'n' && pos[3] != 'N') |
990 || (pos[4] != 's' && pos[4] != 'S') | 990 || (pos[4] != 's' && pos[4] != 'S') |
991 || (pos[5] != 'l' && pos[5] != 'L') | 991 || (pos[5] != 'l' && pos[5] != 'L') |
992 || (pos[6] != 'a' && pos[6] != 'A') | 992 || (pos[6] != 'a' && pos[6] != 'A') |
993 || (pos[7] != 't' && pos[7] != 'T') | 993 || (pos[7] != 't' && pos[7] != 'T') |
994 || (pos[8] != 'e' && pos[8] != 'E')) | 994 || (pos[8] != 'e' && pos[8] != 'E')) |
995 return 0; | 995 return nullptr; |
996 | 996 |
997 CSSTransformValue::TransformOperationType transformType; | 997 CSSTransformValue::TransformOperationType transformType; |
998 unsigned expectedArgumentCount = 1; | 998 unsigned expectedArgumentCount = 1; |
999 unsigned argumentStart = 11; | 999 unsigned argumentStart = 11; |
1000 if ((pos[9] == 'x' || pos[9] == 'X') && pos[10] == '(') { | 1000 if ((pos[9] == 'x' || pos[9] == 'X') && pos[10] == '(') { |
1001 transformType = CSSTransformValue::TranslateXTransformOperation; | 1001 transformType = CSSTransformValue::TranslateXTransformOperation; |
1002 } else if ((pos[9] == 'y' || pos[9] == 'Y') && pos[10] == '(') { | 1002 } else if ((pos[9] == 'y' || pos[9] == 'Y') && pos[10] == '(') { |
1003 transformType = CSSTransformValue::TranslateYTransformOperation; | 1003 transformType = CSSTransformValue::TranslateYTransformOperation; |
1004 } else if ((pos[9] == 'z' || pos[9] == 'Z') && pos[10] == '(') { | 1004 } else if ((pos[9] == 'z' || pos[9] == 'Z') && pos[10] == '(') { |
1005 transformType = CSSTransformValue::TranslateZTransformOperation; | 1005 transformType = CSSTransformValue::TranslateZTransformOperation; |
1006 } else if (pos[9] == '(') { | 1006 } else if (pos[9] == '(') { |
1007 transformType = CSSTransformValue::TranslateTransformOperation; | 1007 transformType = CSSTransformValue::TranslateTransformOperation; |
1008 expectedArgumentCount = 2; | 1008 expectedArgumentCount = 2; |
1009 argumentStart = 10; | 1009 argumentStart = 10; |
1010 } else if (pos[9] == '3' && (pos[10] == 'd' || pos[10] == 'D') && pos[11] ==
'(') { | 1010 } else if (pos[9] == '3' && (pos[10] == 'd' || pos[10] == 'D') && pos[11] ==
'(') { |
1011 transformType = CSSTransformValue::Translate3DTransformOperation; | 1011 transformType = CSSTransformValue::Translate3DTransformOperation; |
1012 expectedArgumentCount = 3; | 1012 expectedArgumentCount = 3; |
1013 argumentStart = 12; | 1013 argumentStart = 12; |
1014 } else { | 1014 } else { |
1015 return 0; | 1015 return nullptr; |
1016 } | 1016 } |
1017 pos += argumentStart; | 1017 pos += argumentStart; |
1018 | 1018 |
1019 RefPtrWillBeRawPtr<CSSTransformValue> transformValue = CSSTransformValue::cr
eate(transformType); | 1019 RefPtrWillBeRawPtr<CSSTransformValue> transformValue = CSSTransformValue::cr
eate(transformType); |
1020 if (!parseTransformTranslateArguments(pos, end, expectedArgumentCount, trans
formValue.get())) | 1020 if (!parseTransformTranslateArguments(pos, end, expectedArgumentCount, trans
formValue.get())) |
1021 return 0; | 1021 return nullptr; |
1022 return transformValue.release(); | 1022 return transformValue.release(); |
1023 } | 1023 } |
1024 | 1024 |
1025 template <typename CharType> | 1025 template <typename CharType> |
1026 static PassRefPtrWillBeRawPtr<CSSValueList> parseTranslateTransformList(CharType
*& pos, CharType* end) | 1026 static PassRefPtrWillBeRawPtr<CSSValueList> parseTranslateTransformList(CharType
*& pos, CharType* end) |
1027 { | 1027 { |
1028 RefPtrWillBeRawPtr<CSSValueList> transformList; | 1028 RefPtrWillBeRawPtr<CSSValueList> transformList; |
1029 while (pos < end) { | 1029 while (pos < end) { |
1030 while (pos < end && isCSSSpace(*pos)) | 1030 while (pos < end && isCSSSpace(*pos)) |
1031 ++pos; | 1031 ++pos; |
1032 RefPtrWillBeRawPtr<CSSTransformValue> transformValue = parseTranslateTra
nsformValue(pos, end); | 1032 RefPtrWillBeRawPtr<CSSTransformValue> transformValue = parseTranslateTra
nsformValue(pos, end); |
1033 if (!transformValue) | 1033 if (!transformValue) |
1034 return 0; | 1034 return nullptr; |
1035 if (!transformList) | 1035 if (!transformList) |
1036 transformList = CSSValueList::createSpaceSeparated(); | 1036 transformList = CSSValueList::createSpaceSeparated(); |
1037 transformList->append(transformValue.release()); | 1037 transformList->append(transformValue.release()); |
1038 if (pos < end) { | 1038 if (pos < end) { |
1039 if (isCSSSpace(*pos)) | 1039 if (isCSSSpace(*pos)) |
1040 return 0; | 1040 return nullptr; |
1041 } | 1041 } |
1042 } | 1042 } |
1043 return transformList.release(); | 1043 return transformList.release(); |
1044 } | 1044 } |
1045 | 1045 |
1046 static bool parseTranslateTransform(MutableStylePropertySet* properties, CSSProp
ertyID propertyID, const String& string, bool important) | 1046 static bool parseTranslateTransform(MutableStylePropertySet* properties, CSSProp
ertyID propertyID, const String& string, bool important) |
1047 { | 1047 { |
1048 if (propertyID != CSSPropertyWebkitTransform) | 1048 if (propertyID != CSSPropertyWebkitTransform) |
1049 return false; | 1049 return false; |
1050 if (string.isEmpty()) | 1050 if (string.isEmpty()) |
(...skipping 12 matching lines...) Expand all Loading... |
1063 if (!transformList) | 1063 if (!transformList) |
1064 return false; | 1064 return false; |
1065 } | 1065 } |
1066 properties->addParsedProperty(CSSProperty(CSSPropertyWebkitTransform, transf
ormList.release(), important)); | 1066 properties->addParsedProperty(CSSProperty(CSSPropertyWebkitTransform, transf
ormList.release(), important)); |
1067 return true; | 1067 return true; |
1068 } | 1068 } |
1069 | 1069 |
1070 PassRefPtrWillBeRawPtr<CSSValueList> BisonCSSParser::parseFontFaceValue(const At
omicString& string) | 1070 PassRefPtrWillBeRawPtr<CSSValueList> BisonCSSParser::parseFontFaceValue(const At
omicString& string) |
1071 { | 1071 { |
1072 if (string.isEmpty()) | 1072 if (string.isEmpty()) |
1073 return 0; | 1073 return nullptr; |
1074 RefPtr<MutableStylePropertySet> dummyStyle = MutableStylePropertySet::create
(); | 1074 RefPtr<MutableStylePropertySet> dummyStyle = MutableStylePropertySet::create
(); |
1075 if (!parseValue(dummyStyle.get(), CSSPropertyFontFamily, string, false, HTML
QuirksMode, 0)) | 1075 if (!parseValue(dummyStyle.get(), CSSPropertyFontFamily, string, false, HTML
QuirksMode, 0)) |
1076 return 0; | 1076 return nullptr; |
1077 | 1077 |
1078 RefPtrWillBeRawPtr<CSSValue> fontFamily = dummyStyle->getPropertyCSSValue(CS
SPropertyFontFamily); | 1078 RefPtrWillBeRawPtr<CSSValue> fontFamily = dummyStyle->getPropertyCSSValue(CS
SPropertyFontFamily); |
1079 if (!fontFamily->isValueList()) | 1079 if (!fontFamily->isValueList()) |
1080 return 0; | 1080 return nullptr; |
1081 | 1081 |
1082 return toCSSValueList(dummyStyle->getPropertyCSSValue(CSSPropertyFontFamily)
.get()); | 1082 return toCSSValueList(dummyStyle->getPropertyCSSValue(CSSPropertyFontFamily)
.get()); |
1083 } | 1083 } |
1084 | 1084 |
1085 PassRefPtrWillBeRawPtr<CSSValue> BisonCSSParser::parseAnimationTimingFunctionVal
ue(const String& string) | 1085 PassRefPtrWillBeRawPtr<CSSValue> BisonCSSParser::parseAnimationTimingFunctionVal
ue(const String& string) |
1086 { | 1086 { |
1087 if (string.isEmpty()) | 1087 if (string.isEmpty()) |
1088 return 0; | 1088 return nullptr; |
1089 RefPtr<MutableStylePropertySet> style = MutableStylePropertySet::create(); | 1089 RefPtr<MutableStylePropertySet> style = MutableStylePropertySet::create(); |
1090 if (!parseValue(style.get(), CSSPropertyAnimationTimingFunction, string, fal
se, HTMLStandardMode, 0)) | 1090 if (!parseValue(style.get(), CSSPropertyAnimationTimingFunction, string, fal
se, HTMLStandardMode, 0)) |
1091 return 0; | 1091 return nullptr; |
1092 | 1092 |
1093 return style->getPropertyCSSValue(CSSPropertyAnimationTimingFunction); | 1093 return style->getPropertyCSSValue(CSSPropertyAnimationTimingFunction); |
1094 } | 1094 } |
1095 | 1095 |
1096 bool BisonCSSParser::parseValue(MutableStylePropertySet* declaration, CSSPropert
yID propertyID, const String& string, bool important, const Document& document) | 1096 bool BisonCSSParser::parseValue(MutableStylePropertySet* declaration, CSSPropert
yID propertyID, const String& string, bool important, const Document& document) |
1097 { | 1097 { |
1098 ASSERT(!string.isEmpty()); | 1098 ASSERT(!string.isEmpty()); |
1099 | 1099 |
1100 CSSParserContext context(document, UseCounter::getFrom(&document)); | 1100 CSSParserContext context(document, UseCounter::getFrom(&document)); |
1101 | 1101 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1145 setupParser("@-internal-value ", string, ""); | 1145 setupParser("@-internal-value ", string, ""); |
1146 | 1146 |
1147 m_id = propertyID; | 1147 m_id = propertyID; |
1148 m_important = important; | 1148 m_important = important; |
1149 | 1149 |
1150 { | 1150 { |
1151 StyleDeclarationScope scope(this, declaration); | 1151 StyleDeclarationScope scope(this, declaration); |
1152 cssyyparse(this); | 1152 cssyyparse(this); |
1153 } | 1153 } |
1154 | 1154 |
1155 m_rule = 0; | 1155 m_rule = nullptr; |
1156 m_id = CSSPropertyInvalid; | 1156 m_id = CSSPropertyInvalid; |
1157 | 1157 |
1158 bool ok = false; | 1158 bool ok = false; |
1159 if (m_hasFontFaceOnlyValues) | 1159 if (m_hasFontFaceOnlyValues) |
1160 deleteFontFaceOnlyValues(); | 1160 deleteFontFaceOnlyValues(); |
1161 if (!m_parsedProperties.isEmpty()) { | 1161 if (!m_parsedProperties.isEmpty()) { |
1162 ok = true; | 1162 ok = true; |
1163 declaration->addParsedProperties(m_parsedProperties); | 1163 declaration->addParsedProperties(m_parsedProperties); |
1164 clearProperties(); | 1164 clearProperties(); |
1165 } | 1165 } |
(...skipping 24 matching lines...) Expand all Loading... |
1190 return false; | 1190 return false; |
1191 | 1191 |
1192 color = primitiveValue->getRGBA32Value(); | 1192 color = primitiveValue->getRGBA32Value(); |
1193 return true; | 1193 return true; |
1194 } | 1194 } |
1195 | 1195 |
1196 bool BisonCSSParser::parseColor(const String& string) | 1196 bool BisonCSSParser::parseColor(const String& string) |
1197 { | 1197 { |
1198 setupParser("@-internal-decls color:", string, ""); | 1198 setupParser("@-internal-decls color:", string, ""); |
1199 cssyyparse(this); | 1199 cssyyparse(this); |
1200 m_rule = 0; | 1200 m_rule = nullptr; |
1201 | 1201 |
1202 return !m_parsedProperties.isEmpty() && m_parsedProperties.first().id() == C
SSPropertyColor; | 1202 return !m_parsedProperties.isEmpty() && m_parsedProperties.first().id() == C
SSPropertyColor; |
1203 } | 1203 } |
1204 | 1204 |
1205 // FIXME: This is copied from SVGCSSParser.cpp | 1205 // FIXME: This is copied from SVGCSSParser.cpp |
1206 static bool isSystemColor(int id) | 1206 static bool isSystemColor(int id) |
1207 { | 1207 { |
1208 return (id >= CSSValueActiveborder && id <= CSSValueWindowtext) || id == CSS
ValueMenu; | 1208 return (id >= CSSValueActiveborder && id <= CSSValueWindowtext) || id == CSS
ValueMenu; |
1209 } | 1209 } |
1210 | 1210 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1242 context.setMode((element->isHTMLElement() && !document.inQuirksMode()) ? HTM
LStandardMode : HTMLQuirksMode); | 1242 context.setMode((element->isHTMLElement() && !document.inQuirksMode()) ? HTM
LStandardMode : HTMLQuirksMode); |
1243 return BisonCSSParser(context).parseDeclaration(string, document.elementShee
t()->contents()); | 1243 return BisonCSSParser(context).parseDeclaration(string, document.elementShee
t()->contents()); |
1244 } | 1244 } |
1245 | 1245 |
1246 PassRefPtr<ImmutableStylePropertySet> BisonCSSParser::parseDeclaration(const Str
ing& string, StyleSheetContents* contextStyleSheet) | 1246 PassRefPtr<ImmutableStylePropertySet> BisonCSSParser::parseDeclaration(const Str
ing& string, StyleSheetContents* contextStyleSheet) |
1247 { | 1247 { |
1248 setStyleSheet(contextStyleSheet); | 1248 setStyleSheet(contextStyleSheet); |
1249 | 1249 |
1250 setupParser("@-internal-decls ", string, ""); | 1250 setupParser("@-internal-decls ", string, ""); |
1251 cssyyparse(this); | 1251 cssyyparse(this); |
1252 m_rule = 0; | 1252 m_rule = nullptr; |
1253 | 1253 |
1254 if (m_hasFontFaceOnlyValues) | 1254 if (m_hasFontFaceOnlyValues) |
1255 deleteFontFaceOnlyValues(); | 1255 deleteFontFaceOnlyValues(); |
1256 | 1256 |
1257 RefPtr<ImmutableStylePropertySet> style = createStylePropertySet(); | 1257 RefPtr<ImmutableStylePropertySet> style = createStylePropertySet(); |
1258 clearProperties(); | 1258 clearProperties(); |
1259 return style.release(); | 1259 return style.release(); |
1260 } | 1260 } |
1261 | 1261 |
1262 | 1262 |
1263 bool BisonCSSParser::parseDeclaration(MutableStylePropertySet* declaration, cons
t String& string, CSSParserObserver* observer, StyleSheetContents* contextStyleS
heet) | 1263 bool BisonCSSParser::parseDeclaration(MutableStylePropertySet* declaration, cons
t String& string, CSSParserObserver* observer, StyleSheetContents* contextStyleS
heet) |
1264 { | 1264 { |
1265 setStyleSheet(contextStyleSheet); | 1265 setStyleSheet(contextStyleSheet); |
1266 | 1266 |
1267 TemporaryChange<CSSParserObserver*> scopedObsever(m_observer, observer); | 1267 TemporaryChange<CSSParserObserver*> scopedObsever(m_observer, observer); |
1268 | 1268 |
1269 setupParser("@-internal-decls ", string, ""); | 1269 setupParser("@-internal-decls ", string, ""); |
1270 if (m_observer) { | 1270 if (m_observer) { |
1271 m_observer->startRuleHeader(CSSRuleSourceData::STYLE_RULE, 0); | 1271 m_observer->startRuleHeader(CSSRuleSourceData::STYLE_RULE, 0); |
1272 m_observer->endRuleHeader(1); | 1272 m_observer->endRuleHeader(1); |
1273 m_observer->startRuleBody(0); | 1273 m_observer->startRuleBody(0); |
1274 } | 1274 } |
1275 | 1275 |
1276 { | 1276 { |
1277 StyleDeclarationScope scope(this, declaration); | 1277 StyleDeclarationScope scope(this, declaration); |
1278 cssyyparse(this); | 1278 cssyyparse(this); |
1279 } | 1279 } |
1280 | 1280 |
1281 m_rule = 0; | 1281 m_rule = nullptr; |
1282 | 1282 |
1283 bool ok = false; | 1283 bool ok = false; |
1284 if (m_hasFontFaceOnlyValues) | 1284 if (m_hasFontFaceOnlyValues) |
1285 deleteFontFaceOnlyValues(); | 1285 deleteFontFaceOnlyValues(); |
1286 if (!m_parsedProperties.isEmpty()) { | 1286 if (!m_parsedProperties.isEmpty()) { |
1287 ok = true; | 1287 ok = true; |
1288 declaration->addParsedProperties(m_parsedProperties); | 1288 declaration->addParsedProperties(m_parsedProperties); |
1289 clearProperties(); | 1289 clearProperties(); |
1290 } | 1290 } |
1291 | 1291 |
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1580 return createPrimitiveNumericValue(value); | 1580 return createPrimitiveNumericValue(value); |
1581 if (value->unit >= CSSPrimitiveValue::CSS_VW && value->unit <= CSSPrimitiveV
alue::CSS_VMAX) | 1581 if (value->unit >= CSSPrimitiveValue::CSS_VW && value->unit <= CSSPrimitiveV
alue::CSS_VMAX) |
1582 return createPrimitiveNumericValue(value); | 1582 return createPrimitiveNumericValue(value); |
1583 if (value->unit >= CSSPrimitiveValue::CSS_DPPX && value->unit <= CSSPrimitiv
eValue::CSS_DPCM) | 1583 if (value->unit >= CSSPrimitiveValue::CSS_DPPX && value->unit <= CSSPrimitiv
eValue::CSS_DPCM) |
1584 return createPrimitiveNumericValue(value); | 1584 return createPrimitiveNumericValue(value); |
1585 if (value->unit >= CSSParserValue::Q_EMS) | 1585 if (value->unit >= CSSParserValue::Q_EMS) |
1586 return CSSPrimitiveValue::createAllowingMarginQuirk(value->fValue, CSSPr
imitiveValue::CSS_EMS); | 1586 return CSSPrimitiveValue::createAllowingMarginQuirk(value->fValue, CSSPr
imitiveValue::CSS_EMS); |
1587 if (isCalculation(value)) | 1587 if (isCalculation(value)) |
1588 return CSSPrimitiveValue::create(m_parsedCalculation.release()); | 1588 return CSSPrimitiveValue::create(m_parsedCalculation.release()); |
1589 | 1589 |
1590 return 0; | 1590 return nullptr; |
1591 } | 1591 } |
1592 | 1592 |
1593 void CSSPropertyParser::addExpandedPropertyForValue(CSSPropertyID propId, PassRe
fPtrWillBeRawPtr<CSSValue> prpValue, bool important) | 1593 void CSSPropertyParser::addExpandedPropertyForValue(CSSPropertyID propId, PassRe
fPtrWillBeRawPtr<CSSValue> prpValue, bool important) |
1594 { | 1594 { |
1595 const StylePropertyShorthand& shorthand = shorthandForProperty(propId); | 1595 const StylePropertyShorthand& shorthand = shorthandForProperty(propId); |
1596 unsigned shorthandLength = shorthand.length(); | 1596 unsigned shorthandLength = shorthand.length(); |
1597 if (!shorthandLength) { | 1597 if (!shorthandLength) { |
1598 addProperty(propId, prpValue, important); | 1598 addProperty(propId, prpValue, important); |
1599 return; | 1599 return; |
1600 } | 1600 } |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1804 case CSSPropertyCursor: { | 1804 case CSSPropertyCursor: { |
1805 // Grammar defined by CSS3 UI and modified by CSS4 images: | 1805 // Grammar defined by CSS3 UI and modified by CSS4 images: |
1806 // [ [<image> [<x> <y>]?,]* | 1806 // [ [<image> [<x> <y>]?,]* |
1807 // [ auto | crosshair | default | pointer | progress | move | e-resize |
ne-resize | | 1807 // [ auto | crosshair | default | pointer | progress | move | e-resize |
ne-resize | |
1808 // nw-resize | n-resize | se-resize | sw-resize | s-resize | w-resize |
ew-resize | | 1808 // nw-resize | n-resize | se-resize | sw-resize | s-resize | w-resize |
ew-resize | |
1809 // ns-resize | nesw-resize | nwse-resize | col-resize | row-resize | tex
t | wait | help | | 1809 // ns-resize | nesw-resize | nwse-resize | col-resize | row-resize | tex
t | wait | help | |
1810 // vertical-text | cell | context-menu | alias | copy | no-drop | not-al
lowed | -webkit-zoom-in | 1810 // vertical-text | cell | context-menu | alias | copy | no-drop | not-al
lowed | -webkit-zoom-in |
1811 // -webkit-zoom-out | all-scroll | -webkit-grab | -webkit-grabbing ] ] |
inherit | 1811 // -webkit-zoom-out | all-scroll | -webkit-grab | -webkit-grabbing ] ] |
inherit |
1812 RefPtrWillBeRawPtr<CSSValueList> list; | 1812 RefPtrWillBeRawPtr<CSSValueList> list; |
1813 while (value) { | 1813 while (value) { |
1814 RefPtrWillBeRawPtr<CSSValue> image = 0; | 1814 RefPtrWillBeRawPtr<CSSValue> image = nullptr; |
1815 if (value->unit == CSSPrimitiveValue::CSS_URI) { | 1815 if (value->unit == CSSPrimitiveValue::CSS_URI) { |
1816 String uri = value->string; | 1816 String uri = value->string; |
1817 if (!uri.isNull()) | 1817 if (!uri.isNull()) |
1818 image = CSSImageValue::create(completeURL(uri)); | 1818 image = CSSImageValue::create(completeURL(uri)); |
1819 } else if (value->unit == CSSParserValue::Function && equalIgnoringC
ase(value->function->name, "-webkit-image-set(")) { | 1819 } else if (value->unit == CSSParserValue::Function && equalIgnoringC
ase(value->function->name, "-webkit-image-set(")) { |
1820 image = parseImageSet(m_valueList.get()); | 1820 image = parseImageSet(m_valueList.get()); |
1821 if (!image) | 1821 if (!image) |
1822 break; | 1822 break; |
1823 } else | 1823 } else |
1824 break; | 1824 break; |
(...skipping 1308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3133 { | 3133 { |
3134 CSSParserValue* value = m_valueList->current(); | 3134 CSSParserValue* value = m_valueList->current(); |
3135 // Always parse lengths in strict mode here, since it would be ambiguous oth
erwise when used in | 3135 // Always parse lengths in strict mode here, since it would be ambiguous oth
erwise when used in |
3136 // the 'columns' shorthand property. | 3136 // the 'columns' shorthand property. |
3137 if (value->id == CSSValueAuto | 3137 if (value->id == CSSValueAuto |
3138 || (validUnit(value, FLength | FNonNeg, HTMLStandardMode) && value->fVal
ue)) { | 3138 || (validUnit(value, FLength | FNonNeg, HTMLStandardMode) && value->fVal
ue)) { |
3139 RefPtrWillBeRawPtr<CSSValue> parsedValue = parseValidPrimitive(value->id
, value); | 3139 RefPtrWillBeRawPtr<CSSValue> parsedValue = parseValidPrimitive(value->id
, value); |
3140 m_valueList->next(); | 3140 m_valueList->next(); |
3141 return parsedValue; | 3141 return parsedValue; |
3142 } | 3142 } |
3143 return 0; | 3143 return nullptr; |
3144 } | 3144 } |
3145 | 3145 |
3146 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseColumnCount() | 3146 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseColumnCount() |
3147 { | 3147 { |
3148 CSSParserValue* value = m_valueList->current(); | 3148 CSSParserValue* value = m_valueList->current(); |
3149 if (value->id == CSSValueAuto | 3149 if (value->id == CSSValueAuto |
3150 || (!value->id && validUnit(value, FPositiveInteger, HTMLQuirksMode))) { | 3150 || (!value->id && validUnit(value, FPositiveInteger, HTMLQuirksMode))) { |
3151 RefPtrWillBeRawPtr<CSSValue> parsedValue = parseValidPrimitive(value->id
, value); | 3151 RefPtrWillBeRawPtr<CSSValue> parsedValue = parseValidPrimitive(value->id
, value); |
3152 m_valueList->next(); | 3152 m_valueList->next(); |
3153 return parsedValue; | 3153 return parsedValue; |
3154 } | 3154 } |
3155 return 0; | 3155 return nullptr; |
3156 } | 3156 } |
3157 | 3157 |
3158 bool CSSPropertyParser::parseColumnsShorthand(bool important) | 3158 bool CSSPropertyParser::parseColumnsShorthand(bool important) |
3159 { | 3159 { |
3160 RefPtrWillBeRawPtr<CSSValue> columnWidth; | 3160 RefPtrWillBeRawPtr<CSSValue> columnWidth; |
3161 RefPtrWillBeRawPtr<CSSValue> columnCount; | 3161 RefPtrWillBeRawPtr<CSSValue> columnCount; |
3162 bool hasPendingExplicitAuto = false; | 3162 bool hasPendingExplicitAuto = false; |
3163 | 3163 |
3164 for (unsigned propertiesParsed = 0; CSSParserValue* value = m_valueList->cur
rent(); propertiesParsed++) { | 3164 for (unsigned propertiesParsed = 0; CSSParserValue* value = m_valueList->cur
rent(); propertiesParsed++) { |
3165 if (propertiesParsed >= 2) | 3165 if (propertiesParsed >= 2) |
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3504 m_valueList->next(); | 3504 m_valueList->next(); |
3505 return true; | 3505 return true; |
3506 } | 3506 } |
3507 | 3507 |
3508 return false; | 3508 return false; |
3509 } | 3509 } |
3510 | 3510 |
3511 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseAttr(CSSParserValueList
* args) | 3511 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseAttr(CSSParserValueList
* args) |
3512 { | 3512 { |
3513 if (args->size() != 1) | 3513 if (args->size() != 1) |
3514 return 0; | 3514 return nullptr; |
3515 | 3515 |
3516 CSSParserValue* a = args->current(); | 3516 CSSParserValue* a = args->current(); |
3517 | 3517 |
3518 if (a->unit != CSSPrimitiveValue::CSS_IDENT) | 3518 if (a->unit != CSSPrimitiveValue::CSS_IDENT) |
3519 return 0; | 3519 return nullptr; |
3520 | 3520 |
3521 String attrName = a->string; | 3521 String attrName = a->string; |
3522 // CSS allows identifiers with "-" at the start, like "-webkit-mask-image". | 3522 // CSS allows identifiers with "-" at the start, like "-webkit-mask-image". |
3523 // But HTML attribute names can't have those characters, and we should not | 3523 // But HTML attribute names can't have those characters, and we should not |
3524 // even parse them inside attr(). | 3524 // even parse them inside attr(). |
3525 if (attrName[0] == '-') | 3525 if (attrName[0] == '-') |
3526 return 0; | 3526 return nullptr; |
3527 | 3527 |
3528 if (m_context.isHTMLDocument()) | 3528 if (m_context.isHTMLDocument()) |
3529 attrName = attrName.lower(); | 3529 attrName = attrName.lower(); |
3530 | 3530 |
3531 return cssValuePool().createValue(attrName, CSSPrimitiveValue::CSS_ATTR); | 3531 return cssValuePool().createValue(attrName, CSSPrimitiveValue::CSS_ATTR); |
3532 } | 3532 } |
3533 | 3533 |
3534 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseBackgroundColor() | 3534 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseBackgroundColor() |
3535 { | 3535 { |
3536 CSSValueID id = m_valueList->current()->id; | 3536 CSSValueID id = m_valueList->current()->id; |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3569 if (id == CSSValueLeft || id == CSSValueRight || id == CSSValueCenter) { | 3569 if (id == CSSValueLeft || id == CSSValueRight || id == CSSValueCenter) { |
3570 int percent = 0; | 3570 int percent = 0; |
3571 if (id == CSSValueRight) | 3571 if (id == CSSValueRight) |
3572 percent = 100; | 3572 percent = 100; |
3573 else if (id == CSSValueCenter) | 3573 else if (id == CSSValueCenter) |
3574 percent = 50; | 3574 percent = 50; |
3575 return cssValuePool().createValue(percent, CSSPrimitiveValue::CSS_PERCEN
TAGE); | 3575 return cssValuePool().createValue(percent, CSSPrimitiveValue::CSS_PERCEN
TAGE); |
3576 } | 3576 } |
3577 if (validUnit(valueList->current(), FPercent | FLength)) | 3577 if (validUnit(valueList->current(), FPercent | FLength)) |
3578 return createPrimitiveNumericValue(valueList->current()); | 3578 return createPrimitiveNumericValue(valueList->current()); |
3579 return 0; | 3579 return nullptr; |
3580 } | 3580 } |
3581 | 3581 |
3582 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseFillPositionY(CSSParser
ValueList* valueList) | 3582 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseFillPositionY(CSSParser
ValueList* valueList) |
3583 { | 3583 { |
3584 int id = valueList->current()->id; | 3584 int id = valueList->current()->id; |
3585 if (id == CSSValueTop || id == CSSValueBottom || id == CSSValueCenter) { | 3585 if (id == CSSValueTop || id == CSSValueBottom || id == CSSValueCenter) { |
3586 int percent = 0; | 3586 int percent = 0; |
3587 if (id == CSSValueBottom) | 3587 if (id == CSSValueBottom) |
3588 percent = 100; | 3588 percent = 100; |
3589 else if (id == CSSValueCenter) | 3589 else if (id == CSSValueCenter) |
3590 percent = 50; | 3590 percent = 50; |
3591 return cssValuePool().createValue(percent, CSSPrimitiveValue::CSS_PERCEN
TAGE); | 3591 return cssValuePool().createValue(percent, CSSPrimitiveValue::CSS_PERCEN
TAGE); |
3592 } | 3592 } |
3593 if (validUnit(valueList->current(), FPercent | FLength)) | 3593 if (validUnit(valueList->current(), FPercent | FLength)) |
3594 return createPrimitiveNumericValue(valueList->current()); | 3594 return createPrimitiveNumericValue(valueList->current()); |
3595 return 0; | 3595 return nullptr; |
3596 } | 3596 } |
3597 | 3597 |
3598 PassRefPtrWillBeRawPtr<CSSPrimitiveValue> CSSPropertyParser::parseFillPositionCo
mponent(CSSParserValueList* valueList, unsigned& cumulativeFlags, FillPositionFl
ag& individualFlag, FillPositionParsingMode parsingMode) | 3598 PassRefPtrWillBeRawPtr<CSSPrimitiveValue> CSSPropertyParser::parseFillPositionCo
mponent(CSSParserValueList* valueList, unsigned& cumulativeFlags, FillPositionFl
ag& individualFlag, FillPositionParsingMode parsingMode) |
3599 { | 3599 { |
3600 CSSValueID id = valueList->current()->id; | 3600 CSSValueID id = valueList->current()->id; |
3601 if (id == CSSValueLeft || id == CSSValueTop || id == CSSValueRight || id ==
CSSValueBottom || id == CSSValueCenter) { | 3601 if (id == CSSValueLeft || id == CSSValueTop || id == CSSValueRight || id ==
CSSValueBottom || id == CSSValueCenter) { |
3602 int percent = 0; | 3602 int percent = 0; |
3603 if (id == CSSValueLeft || id == CSSValueRight) { | 3603 if (id == CSSValueLeft || id == CSSValueRight) { |
3604 if (cumulativeFlags & XFillPosition) | 3604 if (cumulativeFlags & XFillPosition) |
3605 return 0; | 3605 return nullptr; |
3606 cumulativeFlags |= XFillPosition; | 3606 cumulativeFlags |= XFillPosition; |
3607 individualFlag = XFillPosition; | 3607 individualFlag = XFillPosition; |
3608 if (id == CSSValueRight) | 3608 if (id == CSSValueRight) |
3609 percent = 100; | 3609 percent = 100; |
3610 } | 3610 } |
3611 else if (id == CSSValueTop || id == CSSValueBottom) { | 3611 else if (id == CSSValueTop || id == CSSValueBottom) { |
3612 if (cumulativeFlags & YFillPosition) | 3612 if (cumulativeFlags & YFillPosition) |
3613 return 0; | 3613 return nullptr; |
3614 cumulativeFlags |= YFillPosition; | 3614 cumulativeFlags |= YFillPosition; |
3615 individualFlag = YFillPosition; | 3615 individualFlag = YFillPosition; |
3616 if (id == CSSValueBottom) | 3616 if (id == CSSValueBottom) |
3617 percent = 100; | 3617 percent = 100; |
3618 } else if (id == CSSValueCenter) { | 3618 } else if (id == CSSValueCenter) { |
3619 // Center is ambiguous, so we're not sure which position we've found
yet, an x or a y. | 3619 // Center is ambiguous, so we're not sure which position we've found
yet, an x or a y. |
3620 percent = 50; | 3620 percent = 50; |
3621 cumulativeFlags |= AmbiguousFillPosition; | 3621 cumulativeFlags |= AmbiguousFillPosition; |
3622 individualFlag = AmbiguousFillPosition; | 3622 individualFlag = AmbiguousFillPosition; |
3623 } | 3623 } |
3624 | 3624 |
3625 if (parsingMode == ResolveValuesAsKeyword) | 3625 if (parsingMode == ResolveValuesAsKeyword) |
3626 return cssValuePool().createIdentifierValue(id); | 3626 return cssValuePool().createIdentifierValue(id); |
3627 | 3627 |
3628 return cssValuePool().createValue(percent, CSSPrimitiveValue::CSS_PERCEN
TAGE); | 3628 return cssValuePool().createValue(percent, CSSPrimitiveValue::CSS_PERCEN
TAGE); |
3629 } | 3629 } |
3630 if (validUnit(valueList->current(), FPercent | FLength)) { | 3630 if (validUnit(valueList->current(), FPercent | FLength)) { |
3631 if (!cumulativeFlags) { | 3631 if (!cumulativeFlags) { |
3632 cumulativeFlags |= XFillPosition; | 3632 cumulativeFlags |= XFillPosition; |
3633 individualFlag = XFillPosition; | 3633 individualFlag = XFillPosition; |
3634 } else if (cumulativeFlags & (XFillPosition | AmbiguousFillPosition)) { | 3634 } else if (cumulativeFlags & (XFillPosition | AmbiguousFillPosition)) { |
3635 cumulativeFlags |= YFillPosition; | 3635 cumulativeFlags |= YFillPosition; |
3636 individualFlag = YFillPosition; | 3636 individualFlag = YFillPosition; |
3637 } else { | 3637 } else { |
3638 if (m_parsedCalculation) | 3638 if (m_parsedCalculation) |
3639 m_parsedCalculation.release(); | 3639 m_parsedCalculation.release(); |
3640 return 0; | 3640 return nullptr; |
3641 } | 3641 } |
3642 return createPrimitiveNumericValue(valueList->current()); | 3642 return createPrimitiveNumericValue(valueList->current()); |
3643 } | 3643 } |
3644 return 0; | 3644 return nullptr; |
3645 } | 3645 } |
3646 | 3646 |
3647 static bool isValueConflictingWithCurrentEdge(int value1, int value2) | 3647 static bool isValueConflictingWithCurrentEdge(int value1, int value2) |
3648 { | 3648 { |
3649 if ((value1 == CSSValueLeft || value1 == CSSValueRight) && (value2 == CSSVal
ueLeft || value2 == CSSValueRight)) | 3649 if ((value1 == CSSValueLeft || value1 == CSSValueRight) && (value2 == CSSVal
ueLeft || value2 == CSSValueRight)) |
3650 return true; | 3650 return true; |
3651 | 3651 |
3652 if ((value1 == CSSValueTop || value1 == CSSValueBottom) && (value2 == CSSVal
ueTop || value2 == CSSValueBottom)) | 3652 if ((value1 == CSSValueTop || value1 == CSSValueBottom) && (value2 == CSSVal
ueTop || value2 == CSSValueBottom)) |
3653 return true; | 3653 return true; |
3654 | 3654 |
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3924 if (id == CSSValueRepeatY) { | 3924 if (id == CSSValueRepeatY) { |
3925 m_implicitShorthand = true; | 3925 m_implicitShorthand = true; |
3926 value1 = cssValuePool().createIdentifierValue(CSSValueNoRepeat); | 3926 value1 = cssValuePool().createIdentifierValue(CSSValueNoRepeat); |
3927 value2 = cssValuePool().createIdentifierValue(CSSValueRepeat); | 3927 value2 = cssValuePool().createIdentifierValue(CSSValueRepeat); |
3928 m_valueList->next(); | 3928 m_valueList->next(); |
3929 return; | 3929 return; |
3930 } | 3930 } |
3931 if (id == CSSValueRepeat || id == CSSValueNoRepeat || id == CSSValueRound ||
id == CSSValueSpace) | 3931 if (id == CSSValueRepeat || id == CSSValueNoRepeat || id == CSSValueRound ||
id == CSSValueSpace) |
3932 value1 = cssValuePool().createIdentifierValue(id); | 3932 value1 = cssValuePool().createIdentifierValue(id); |
3933 else { | 3933 else { |
3934 value1 = 0; | 3934 value1 = nullptr; |
3935 return; | 3935 return; |
3936 } | 3936 } |
3937 | 3937 |
3938 CSSParserValue* value = m_valueList->next(); | 3938 CSSParserValue* value = m_valueList->next(); |
3939 | 3939 |
3940 // Parse the second value if one is available | 3940 // Parse the second value if one is available |
3941 if (value && !isComma(value)) { | 3941 if (value && !isComma(value)) { |
3942 id = value->id; | 3942 id = value->id; |
3943 if (id == CSSValueRepeat || id == CSSValueNoRepeat || id == CSSValueRoun
d || id == CSSValueSpace) { | 3943 if (id == CSSValueRepeat || id == CSSValueNoRepeat || id == CSSValueRoun
d || id == CSSValueSpace) { |
3944 value2 = cssValuePool().createIdentifierValue(id); | 3944 value2 = cssValuePool().createIdentifierValue(id); |
(...skipping 14 matching lines...) Expand all Loading... |
3959 | 3959 |
3960 if (value->id == CSSValueContain || value->id == CSSValueCover) | 3960 if (value->id == CSSValueContain || value->id == CSSValueCover) |
3961 return cssValuePool().createIdentifierValue(value->id); | 3961 return cssValuePool().createIdentifierValue(value->id); |
3962 | 3962 |
3963 RefPtrWillBeRawPtr<CSSPrimitiveValue> parsedValue1; | 3963 RefPtrWillBeRawPtr<CSSPrimitiveValue> parsedValue1; |
3964 | 3964 |
3965 if (value->id == CSSValueAuto) | 3965 if (value->id == CSSValueAuto) |
3966 parsedValue1 = cssValuePool().createIdentifierValue(CSSValueAuto); | 3966 parsedValue1 = cssValuePool().createIdentifierValue(CSSValueAuto); |
3967 else { | 3967 else { |
3968 if (!validUnit(value, FLength | FPercent)) | 3968 if (!validUnit(value, FLength | FPercent)) |
3969 return 0; | 3969 return nullptr; |
3970 parsedValue1 = createPrimitiveNumericValue(value); | 3970 parsedValue1 = createPrimitiveNumericValue(value); |
3971 } | 3971 } |
3972 | 3972 |
3973 RefPtrWillBeRawPtr<CSSPrimitiveValue> parsedValue2; | 3973 RefPtrWillBeRawPtr<CSSPrimitiveValue> parsedValue2; |
3974 if ((value = m_valueList->next())) { | 3974 if ((value = m_valueList->next())) { |
3975 if (value->unit == CSSParserValue::Operator && value->iValue == ',') | 3975 if (value->unit == CSSParserValue::Operator && value->iValue == ',') |
3976 allowComma = false; | 3976 allowComma = false; |
3977 else if (value->id != CSSValueAuto) { | 3977 else if (value->id != CSSValueAuto) { |
3978 if (!validUnit(value, FLength | FPercent)) { | 3978 if (!validUnit(value, FLength | FPercent)) { |
3979 if (!inShorthand()) | 3979 if (!inShorthand()) |
3980 return 0; | 3980 return nullptr; |
3981 // We need to rewind the value list, so that when it is advanced
we'll end up back at this value. | 3981 // We need to rewind the value list, so that when it is advanced
we'll end up back at this value. |
3982 m_valueList->previous(); | 3982 m_valueList->previous(); |
3983 } else | 3983 } else |
3984 parsedValue2 = createPrimitiveNumericValue(value); | 3984 parsedValue2 = createPrimitiveNumericValue(value); |
3985 } | 3985 } |
3986 } else if (!parsedValue2 && propId == CSSPropertyWebkitBackgroundSize) { | 3986 } else if (!parsedValue2 && propId == CSSPropertyWebkitBackgroundSize) { |
3987 // For backwards compatibility we set the second value to the first if i
t is omitted. | 3987 // For backwards compatibility we set the second value to the first if i
t is omitted. |
3988 // We only need to do this for -webkit-background-size. It should be saf
e to let masks match | 3988 // We only need to do this for -webkit-background-size. It should be saf
e to let masks match |
3989 // the real property. | 3989 // the real property. |
3990 parsedValue2 = parsedValue1; | 3990 parsedValue2 = parsedValue1; |
3991 } | 3991 } |
3992 | 3992 |
3993 if (!parsedValue2) | 3993 if (!parsedValue2) |
3994 return parsedValue1; | 3994 return parsedValue1; |
3995 return createPrimitiveValuePair(parsedValue1.release(), parsedValue2.release
()); | 3995 return createPrimitiveValuePair(parsedValue1.release(), parsedValue2.release
()); |
3996 } | 3996 } |
3997 | 3997 |
3998 bool CSSPropertyParser::parseFillProperty(CSSPropertyID propId, CSSPropertyID& p
ropId1, CSSPropertyID& propId2, | 3998 bool CSSPropertyParser::parseFillProperty(CSSPropertyID propId, CSSPropertyID& p
ropId1, CSSPropertyID& propId2, |
3999 RefPtrWillBeRawPtr<CSSValue>& retValue1, RefPtrWillBeRawPtr<CSSValue>& retVa
lue2) | 3999 RefPtrWillBeRawPtr<CSSValue>& retValue1, RefPtrWillBeRawPtr<CSSValue>& retVa
lue2) |
4000 { | 4000 { |
4001 RefPtrWillBeRawPtr<CSSValueList> values; | 4001 RefPtrWillBeRawPtr<CSSValueList> values; |
4002 RefPtrWillBeRawPtr<CSSValueList> values2; | 4002 RefPtrWillBeRawPtr<CSSValueList> values2; |
4003 CSSParserValue* val; | 4003 CSSParserValue* val; |
4004 RefPtrWillBeRawPtr<CSSValue> value; | 4004 RefPtrWillBeRawPtr<CSSValue> value; |
4005 RefPtrWillBeRawPtr<CSSValue> value2; | 4005 RefPtrWillBeRawPtr<CSSValue> value2; |
4006 | 4006 |
4007 bool allowComma = false; | 4007 bool allowComma = false; |
4008 | 4008 |
4009 retValue1 = retValue2 = 0; | 4009 retValue1 = retValue2 = nullptr; |
4010 propId1 = propId; | 4010 propId1 = propId; |
4011 propId2 = propId; | 4011 propId2 = propId; |
4012 if (propId == CSSPropertyBackgroundPosition) { | 4012 if (propId == CSSPropertyBackgroundPosition) { |
4013 propId1 = CSSPropertyBackgroundPositionX; | 4013 propId1 = CSSPropertyBackgroundPositionX; |
4014 propId2 = CSSPropertyBackgroundPositionY; | 4014 propId2 = CSSPropertyBackgroundPositionY; |
4015 } else if (propId == CSSPropertyWebkitMaskPosition) { | 4015 } else if (propId == CSSPropertyWebkitMaskPosition) { |
4016 propId1 = CSSPropertyWebkitMaskPositionX; | 4016 propId1 = CSSPropertyWebkitMaskPositionX; |
4017 propId2 = CSSPropertyWebkitMaskPositionY; | 4017 propId2 = CSSPropertyWebkitMaskPositionY; |
4018 } else if (propId == CSSPropertyBackgroundRepeat) { | 4018 } else if (propId == CSSPropertyBackgroundRepeat) { |
4019 propId1 = CSSPropertyBackgroundRepeatX; | 4019 propId1 = CSSPropertyBackgroundRepeatX; |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4124 if (currValue) | 4124 if (currValue) |
4125 m_valueList->next(); | 4125 m_valueList->next(); |
4126 break; | 4126 break; |
4127 } | 4127 } |
4128 case CSSPropertyMaskSourceType: { | 4128 case CSSPropertyMaskSourceType: { |
4129 if (RuntimeEnabledFeatures::cssMaskSourceTypeEnabled()) { | 4129 if (RuntimeEnabledFeatures::cssMaskSourceTypeEnabled()) { |
4130 if (val->id == CSSValueAuto || val->id == CSSValueAlpha
|| val->id == CSSValueLuminance) { | 4130 if (val->id == CSSValueAuto || val->id == CSSValueAlpha
|| val->id == CSSValueLuminance) { |
4131 currValue = cssValuePool().createIdentifierValue(val
->id); | 4131 currValue = cssValuePool().createIdentifierValue(val
->id); |
4132 m_valueList->next(); | 4132 m_valueList->next(); |
4133 } else { | 4133 } else { |
4134 currValue = 0; | 4134 currValue = nullptr; |
4135 } | 4135 } |
4136 } | 4136 } |
4137 break; | 4137 break; |
4138 } | 4138 } |
4139 default: | 4139 default: |
4140 break; | 4140 break; |
4141 } | 4141 } |
4142 if (!currValue) | 4142 if (!currValue) |
4143 return false; | 4143 return false; |
4144 | 4144 |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4182 return true; | 4182 return true; |
4183 } | 4183 } |
4184 return false; | 4184 return false; |
4185 } | 4185 } |
4186 | 4186 |
4187 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseAnimationDelay() | 4187 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseAnimationDelay() |
4188 { | 4188 { |
4189 CSSParserValue* value = m_valueList->current(); | 4189 CSSParserValue* value = m_valueList->current(); |
4190 if (validUnit(value, FTime)) | 4190 if (validUnit(value, FTime)) |
4191 return createPrimitiveNumericValue(value); | 4191 return createPrimitiveNumericValue(value); |
4192 return 0; | 4192 return nullptr; |
4193 } | 4193 } |
4194 | 4194 |
4195 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseAnimationDirection() | 4195 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseAnimationDirection() |
4196 { | 4196 { |
4197 CSSParserValue* value = m_valueList->current(); | 4197 CSSParserValue* value = m_valueList->current(); |
4198 if (value->id == CSSValueNormal || value->id == CSSValueAlternate || value->
id == CSSValueReverse || value->id == CSSValueAlternateReverse) | 4198 if (value->id == CSSValueNormal || value->id == CSSValueAlternate || value->
id == CSSValueReverse || value->id == CSSValueAlternateReverse) |
4199 return cssValuePool().createIdentifierValue(value->id); | 4199 return cssValuePool().createIdentifierValue(value->id); |
4200 return 0; | 4200 return nullptr; |
4201 } | 4201 } |
4202 | 4202 |
4203 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseAnimationDuration() | 4203 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseAnimationDuration() |
4204 { | 4204 { |
4205 CSSParserValue* value = m_valueList->current(); | 4205 CSSParserValue* value = m_valueList->current(); |
4206 if (validUnit(value, FTime | FNonNeg)) | 4206 if (validUnit(value, FTime | FNonNeg)) |
4207 return createPrimitiveNumericValue(value); | 4207 return createPrimitiveNumericValue(value); |
4208 return 0; | 4208 return nullptr; |
4209 } | 4209 } |
4210 | 4210 |
4211 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseAnimationFillMode() | 4211 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseAnimationFillMode() |
4212 { | 4212 { |
4213 CSSParserValue* value = m_valueList->current(); | 4213 CSSParserValue* value = m_valueList->current(); |
4214 if (value->id == CSSValueNone || value->id == CSSValueForwards || value->id
== CSSValueBackwards || value->id == CSSValueBoth) | 4214 if (value->id == CSSValueNone || value->id == CSSValueForwards || value->id
== CSSValueBackwards || value->id == CSSValueBoth) |
4215 return cssValuePool().createIdentifierValue(value->id); | 4215 return cssValuePool().createIdentifierValue(value->id); |
4216 return 0; | 4216 return nullptr; |
4217 } | 4217 } |
4218 | 4218 |
4219 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseAnimationIterationCount
() | 4219 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseAnimationIterationCount
() |
4220 { | 4220 { |
4221 CSSParserValue* value = m_valueList->current(); | 4221 CSSParserValue* value = m_valueList->current(); |
4222 if (value->id == CSSValueInfinite) | 4222 if (value->id == CSSValueInfinite) |
4223 return cssValuePool().createIdentifierValue(value->id); | 4223 return cssValuePool().createIdentifierValue(value->id); |
4224 if (validUnit(value, FNumber | FNonNeg)) | 4224 if (validUnit(value, FNumber | FNonNeg)) |
4225 return createPrimitiveNumericValue(value); | 4225 return createPrimitiveNumericValue(value); |
4226 return 0; | 4226 return nullptr; |
4227 } | 4227 } |
4228 | 4228 |
4229 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseAnimationName() | 4229 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseAnimationName() |
4230 { | 4230 { |
4231 CSSParserValue* value = m_valueList->current(); | 4231 CSSParserValue* value = m_valueList->current(); |
4232 if (value->unit == CSSPrimitiveValue::CSS_STRING || value->unit == CSSPrimit
iveValue::CSS_IDENT) { | 4232 if (value->unit == CSSPrimitiveValue::CSS_STRING || value->unit == CSSPrimit
iveValue::CSS_IDENT) { |
4233 if (value->id == CSSValueNone || (value->unit == CSSPrimitiveValue::CSS_
STRING && equalIgnoringCase(value, "none"))) { | 4233 if (value->id == CSSValueNone || (value->unit == CSSPrimitiveValue::CSS_
STRING && equalIgnoringCase(value, "none"))) { |
4234 return cssValuePool().createIdentifierValue(CSSValueNone); | 4234 return cssValuePool().createIdentifierValue(CSSValueNone); |
4235 } else { | 4235 } else { |
4236 return createPrimitiveStringValue(value); | 4236 return createPrimitiveStringValue(value); |
4237 } | 4237 } |
4238 } | 4238 } |
4239 return 0; | 4239 return nullptr; |
4240 } | 4240 } |
4241 | 4241 |
4242 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseAnimationPlayState() | 4242 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseAnimationPlayState() |
4243 { | 4243 { |
4244 CSSParserValue* value = m_valueList->current(); | 4244 CSSParserValue* value = m_valueList->current(); |
4245 if (value->id == CSSValueRunning || value->id == CSSValuePaused) | 4245 if (value->id == CSSValueRunning || value->id == CSSValuePaused) |
4246 return cssValuePool().createIdentifierValue(value->id); | 4246 return cssValuePool().createIdentifierValue(value->id); |
4247 return 0; | 4247 return nullptr; |
4248 } | 4248 } |
4249 | 4249 |
4250 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseAnimationProperty(Anima
tionParseContext& context) | 4250 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseAnimationProperty(Anima
tionParseContext& context) |
4251 { | 4251 { |
4252 CSSParserValue* value = m_valueList->current(); | 4252 CSSParserValue* value = m_valueList->current(); |
4253 if (value->unit != CSSPrimitiveValue::CSS_IDENT) | 4253 if (value->unit != CSSPrimitiveValue::CSS_IDENT) |
4254 return 0; | 4254 return nullptr; |
4255 CSSPropertyID result = cssPropertyID(value->string); | 4255 CSSPropertyID result = cssPropertyID(value->string); |
4256 if (result) | 4256 if (result) |
4257 return cssValuePool().createIdentifierValue(result); | 4257 return cssValuePool().createIdentifierValue(result); |
4258 if (equalIgnoringCase(value, "all")) { | 4258 if (equalIgnoringCase(value, "all")) { |
4259 context.sawAnimationPropertyKeyword(); | 4259 context.sawAnimationPropertyKeyword(); |
4260 return cssValuePool().createIdentifierValue(CSSValueAll); | 4260 return cssValuePool().createIdentifierValue(CSSValueAll); |
4261 } | 4261 } |
4262 if (equalIgnoringCase(value, "none")) { | 4262 if (equalIgnoringCase(value, "none")) { |
4263 context.commitAnimationPropertyKeyword(); | 4263 context.commitAnimationPropertyKeyword(); |
4264 context.sawAnimationPropertyKeyword(); | 4264 context.sawAnimationPropertyKeyword(); |
4265 return cssValuePool().createIdentifierValue(CSSValueNone); | 4265 return cssValuePool().createIdentifierValue(CSSValueNone); |
4266 } | 4266 } |
4267 return 0; | 4267 return nullptr; |
4268 } | 4268 } |
4269 | 4269 |
4270 bool CSSPropertyParser::parseTransformOriginShorthand(RefPtrWillBeRawPtr<CSSValu
e>& value1, RefPtrWillBeRawPtr<CSSValue>& value2, RefPtrWillBeRawPtr<CSSValue>&
value3) | 4270 bool CSSPropertyParser::parseTransformOriginShorthand(RefPtrWillBeRawPtr<CSSValu
e>& value1, RefPtrWillBeRawPtr<CSSValue>& value2, RefPtrWillBeRawPtr<CSSValue>&
value3) |
4271 { | 4271 { |
4272 parse2ValuesFillPosition(m_valueList.get(), value1, value2); | 4272 parse2ValuesFillPosition(m_valueList.get(), value1, value2); |
4273 | 4273 |
4274 // now get z | 4274 // now get z |
4275 if (m_valueList->current()) { | 4275 if (m_valueList->current()) { |
4276 if (validUnit(m_valueList->current(), FLength)) { | 4276 if (validUnit(m_valueList->current(), FLength)) { |
4277 value3 = createPrimitiveNumericValue(m_valueList->current()); | 4277 value3 = createPrimitiveNumericValue(m_valueList->current()); |
(...skipping 24 matching lines...) Expand all Loading... |
4302 | 4302 |
4303 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseAnimationTimingFunction
() | 4303 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseAnimationTimingFunction
() |
4304 { | 4304 { |
4305 CSSParserValue* value = m_valueList->current(); | 4305 CSSParserValue* value = m_valueList->current(); |
4306 if (value->id == CSSValueEase || value->id == CSSValueLinear || value->id ==
CSSValueEaseIn || value->id == CSSValueEaseOut | 4306 if (value->id == CSSValueEase || value->id == CSSValueLinear || value->id ==
CSSValueEaseIn || value->id == CSSValueEaseOut |
4307 || value->id == CSSValueEaseInOut || value->id == CSSValueStepStart || v
alue->id == CSSValueStepEnd) | 4307 || value->id == CSSValueEaseInOut || value->id == CSSValueStepStart || v
alue->id == CSSValueStepEnd) |
4308 return cssValuePool().createIdentifierValue(value->id); | 4308 return cssValuePool().createIdentifierValue(value->id); |
4309 | 4309 |
4310 // We must be a function. | 4310 // We must be a function. |
4311 if (value->unit != CSSParserValue::Function) | 4311 if (value->unit != CSSParserValue::Function) |
4312 return 0; | 4312 return nullptr; |
4313 | 4313 |
4314 CSSParserValueList* args = value->function->args.get(); | 4314 CSSParserValueList* args = value->function->args.get(); |
4315 | 4315 |
4316 if (equalIgnoringCase(value->function->name, "steps(")) { | 4316 if (equalIgnoringCase(value->function->name, "steps(")) { |
4317 // For steps, 1 or 2 params must be specified (comma-separated) | 4317 // For steps, 1 or 2 params must be specified (comma-separated) |
4318 if (!args || (args->size() != 1 && args->size() != 3)) | 4318 if (!args || (args->size() != 1 && args->size() != 3)) |
4319 return 0; | 4319 return nullptr; |
4320 | 4320 |
4321 // There are two values. | 4321 // There are two values. |
4322 int numSteps; | 4322 int numSteps; |
4323 bool stepAtStart = false; | 4323 bool stepAtStart = false; |
4324 | 4324 |
4325 CSSParserValue* v = args->current(); | 4325 CSSParserValue* v = args->current(); |
4326 if (!validUnit(v, FInteger)) | 4326 if (!validUnit(v, FInteger)) |
4327 return 0; | 4327 return nullptr; |
4328 numSteps = clampToInteger(v->fValue); | 4328 numSteps = clampToInteger(v->fValue); |
4329 if (numSteps < 1) | 4329 if (numSteps < 1) |
4330 return 0; | 4330 return nullptr; |
4331 v = args->next(); | 4331 v = args->next(); |
4332 | 4332 |
4333 if (v) { | 4333 if (v) { |
4334 // There is a comma so we need to parse the second value | 4334 // There is a comma so we need to parse the second value |
4335 if (!isComma(v)) | 4335 if (!isComma(v)) |
4336 return 0; | 4336 return nullptr; |
4337 v = args->next(); | 4337 v = args->next(); |
4338 if (v->id != CSSValueStart && v->id != CSSValueEnd) | 4338 if (v->id != CSSValueStart && v->id != CSSValueEnd) |
4339 return 0; | 4339 return nullptr; |
4340 stepAtStart = v->id == CSSValueStart; | 4340 stepAtStart = v->id == CSSValueStart; |
4341 } | 4341 } |
4342 | 4342 |
4343 return CSSStepsTimingFunctionValue::create(numSteps, stepAtStart); | 4343 return CSSStepsTimingFunctionValue::create(numSteps, stepAtStart); |
4344 } | 4344 } |
4345 | 4345 |
4346 if (equalIgnoringCase(value->function->name, "cubic-bezier(")) { | 4346 if (equalIgnoringCase(value->function->name, "cubic-bezier(")) { |
4347 // For cubic bezier, 4 values must be specified. | 4347 // For cubic bezier, 4 values must be specified. |
4348 if (!args || args->size() != 7) | 4348 if (!args || args->size() != 7) |
4349 return 0; | 4349 return nullptr; |
4350 | 4350 |
4351 // There are two points specified. The x values must be between 0 and 1
but the y values can exceed this range. | 4351 // There are two points specified. The x values must be between 0 and 1
but the y values can exceed this range. |
4352 double x1, y1, x2, y2; | 4352 double x1, y1, x2, y2; |
4353 | 4353 |
4354 if (!parseCubicBezierTimingFunctionValue(args, x1)) | 4354 if (!parseCubicBezierTimingFunctionValue(args, x1)) |
4355 return 0; | 4355 return nullptr; |
4356 if (x1 < 0 || x1 > 1) | 4356 if (x1 < 0 || x1 > 1) |
4357 return 0; | 4357 return nullptr; |
4358 if (!parseCubicBezierTimingFunctionValue(args, y1)) | 4358 if (!parseCubicBezierTimingFunctionValue(args, y1)) |
4359 return 0; | 4359 return nullptr; |
4360 if (!parseCubicBezierTimingFunctionValue(args, x2)) | 4360 if (!parseCubicBezierTimingFunctionValue(args, x2)) |
4361 return 0; | 4361 return nullptr; |
4362 if (x2 < 0 || x2 > 1) | 4362 if (x2 < 0 || x2 > 1) |
4363 return 0; | 4363 return nullptr; |
4364 if (!parseCubicBezierTimingFunctionValue(args, y2)) | 4364 if (!parseCubicBezierTimingFunctionValue(args, y2)) |
4365 return 0; | 4365 return nullptr; |
4366 | 4366 |
4367 return CSSCubicBezierTimingFunctionValue::create(x1, y1, x2, y2); | 4367 return CSSCubicBezierTimingFunctionValue::create(x1, y1, x2, y2); |
4368 } | 4368 } |
4369 | 4369 |
4370 return 0; | 4370 return nullptr; |
4371 } | 4371 } |
4372 | 4372 |
4373 bool CSSPropertyParser::parseAnimationProperty(CSSPropertyID propId, RefPtrWillB
eRawPtr<CSSValue>& result, AnimationParseContext& context) | 4373 bool CSSPropertyParser::parseAnimationProperty(CSSPropertyID propId, RefPtrWillB
eRawPtr<CSSValue>& result, AnimationParseContext& context) |
4374 { | 4374 { |
4375 RefPtrWillBeRawPtr<CSSValueList> values; | 4375 RefPtrWillBeRawPtr<CSSValueList> values; |
4376 CSSParserValue* val; | 4376 CSSParserValue* val; |
4377 RefPtrWillBeRawPtr<CSSValue> value; | 4377 RefPtrWillBeRawPtr<CSSValue> value; |
4378 bool allowComma = false; | 4378 bool allowComma = false; |
4379 | 4379 |
4380 result = 0; | 4380 result = nullptr; |
4381 | 4381 |
4382 while ((val = m_valueList->current())) { | 4382 while ((val = m_valueList->current())) { |
4383 RefPtrWillBeRawPtr<CSSValue> currValue; | 4383 RefPtrWillBeRawPtr<CSSValue> currValue; |
4384 if (allowComma) { | 4384 if (allowComma) { |
4385 if (!isComma(val)) | 4385 if (!isComma(val)) |
4386 return false; | 4386 return false; |
4387 m_valueList->next(); | 4387 m_valueList->next(); |
4388 allowComma = false; | 4388 allowComma = false; |
4389 } | 4389 } |
4390 else { | 4390 else { |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4543 } | 4543 } |
4544 } else if (value->id == CSSValueSpan) { | 4544 } else if (value->id == CSSValueSpan) { |
4545 hasSeenSpanKeyword = true; | 4545 hasSeenSpanKeyword = true; |
4546 if (m_valueList->next()) | 4546 if (m_valueList->next()) |
4547 parseIntegerOrStringFromGridPosition(numericValue, gridLineName); | 4547 parseIntegerOrStringFromGridPosition(numericValue, gridLineName); |
4548 } | 4548 } |
4549 | 4549 |
4550 // Check that we have consumed all the value list. For shorthands, the parse
r will pass | 4550 // Check that we have consumed all the value list. For shorthands, the parse
r will pass |
4551 // the whole value list (including the opposite position). | 4551 // the whole value list (including the opposite position). |
4552 if (m_valueList->current() && !isForwardSlashOperator(m_valueList->current()
)) | 4552 if (m_valueList->current() && !isForwardSlashOperator(m_valueList->current()
)) |
4553 return 0; | 4553 return nullptr; |
4554 | 4554 |
4555 // If we didn't parse anything, this is not a valid grid position. | 4555 // If we didn't parse anything, this is not a valid grid position. |
4556 if (!hasSeenSpanKeyword && !gridLineName && !numericValue) | 4556 if (!hasSeenSpanKeyword && !gridLineName && !numericValue) |
4557 return 0; | 4557 return nullptr; |
4558 | 4558 |
4559 // Negative numbers are not allowed for span (but are for <integer>). | 4559 // Negative numbers are not allowed for span (but are for <integer>). |
4560 if (hasSeenSpanKeyword && numericValue && numericValue->getIntValue() < 0) | 4560 if (hasSeenSpanKeyword && numericValue && numericValue->getIntValue() < 0) |
4561 return 0; | 4561 return nullptr; |
4562 | 4562 |
4563 RefPtrWillBeRawPtr<CSSValueList> values = CSSValueList::createSpaceSeparated
(); | 4563 RefPtrWillBeRawPtr<CSSValueList> values = CSSValueList::createSpaceSeparated
(); |
4564 if (hasSeenSpanKeyword) | 4564 if (hasSeenSpanKeyword) |
4565 values->append(cssValuePool().createIdentifierValue(CSSValueSpan)); | 4565 values->append(cssValuePool().createIdentifierValue(CSSValueSpan)); |
4566 if (numericValue) | 4566 if (numericValue) |
4567 values->append(numericValue.release()); | 4567 values->append(numericValue.release()); |
4568 if (gridLineName) | 4568 if (gridLineName) |
4569 values->append(gridLineName.release()); | 4569 values->append(gridLineName.release()); |
4570 ASSERT(values->length()); | 4570 ASSERT(values->length()); |
4571 return values.release(); | 4571 return values.release(); |
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4780 CSSParserValue* currentValue = inputList.current(); | 4780 CSSParserValue* currentValue = inputList.current(); |
4781 inputList.next(); | 4781 inputList.next(); |
4782 | 4782 |
4783 if (currentValue->id == CSSValueAuto) | 4783 if (currentValue->id == CSSValueAuto) |
4784 return cssValuePool().createIdentifierValue(CSSValueAuto); | 4784 return cssValuePool().createIdentifierValue(CSSValueAuto); |
4785 | 4785 |
4786 if (currentValue->unit == CSSParserValue::Function && equalIgnoringCase(curr
entValue->function->name, "minmax(")) { | 4786 if (currentValue->unit == CSSParserValue::Function && equalIgnoringCase(curr
entValue->function->name, "minmax(")) { |
4787 // The spec defines the following grammar: minmax( <track-breadth> , <tr
ack-breadth> ) | 4787 // The spec defines the following grammar: minmax( <track-breadth> , <tr
ack-breadth> ) |
4788 CSSParserValueList* arguments = currentValue->function->args.get(); | 4788 CSSParserValueList* arguments = currentValue->function->args.get(); |
4789 if (!arguments || arguments->size() != 3 || !isComma(arguments->valueAt(
1))) | 4789 if (!arguments || arguments->size() != 3 || !isComma(arguments->valueAt(
1))) |
4790 return 0; | 4790 return nullptr; |
4791 | 4791 |
4792 RefPtrWillBeRawPtr<CSSPrimitiveValue> minTrackBreadth = parseGridBreadth
(arguments->valueAt(0)); | 4792 RefPtrWillBeRawPtr<CSSPrimitiveValue> minTrackBreadth = parseGridBreadth
(arguments->valueAt(0)); |
4793 if (!minTrackBreadth) | 4793 if (!minTrackBreadth) |
4794 return 0; | 4794 return nullptr; |
4795 | 4795 |
4796 RefPtrWillBeRawPtr<CSSPrimitiveValue> maxTrackBreadth = parseGridBreadth
(arguments->valueAt(2)); | 4796 RefPtrWillBeRawPtr<CSSPrimitiveValue> maxTrackBreadth = parseGridBreadth
(arguments->valueAt(2)); |
4797 if (!maxTrackBreadth) | 4797 if (!maxTrackBreadth) |
4798 return 0; | 4798 return nullptr; |
4799 | 4799 |
4800 RefPtrWillBeRawPtr<CSSValueList> parsedArguments = CSSValueList::createC
ommaSeparated(); | 4800 RefPtrWillBeRawPtr<CSSValueList> parsedArguments = CSSValueList::createC
ommaSeparated(); |
4801 parsedArguments->append(minTrackBreadth); | 4801 parsedArguments->append(minTrackBreadth); |
4802 parsedArguments->append(maxTrackBreadth); | 4802 parsedArguments->append(maxTrackBreadth); |
4803 return CSSFunctionValue::create("minmax(", parsedArguments); | 4803 return CSSFunctionValue::create("minmax(", parsedArguments); |
4804 } | 4804 } |
4805 | 4805 |
4806 return parseGridBreadth(currentValue); | 4806 return parseGridBreadth(currentValue); |
4807 } | 4807 } |
4808 | 4808 |
4809 PassRefPtrWillBeRawPtr<CSSPrimitiveValue> CSSPropertyParser::parseGridBreadth(CS
SParserValue* currentValue) | 4809 PassRefPtrWillBeRawPtr<CSSPrimitiveValue> CSSPropertyParser::parseGridBreadth(CS
SParserValue* currentValue) |
4810 { | 4810 { |
4811 if (currentValue->id == CSSValueMinContent || currentValue->id == CSSValueMa
xContent) | 4811 if (currentValue->id == CSSValueMinContent || currentValue->id == CSSValueMa
xContent) |
4812 return cssValuePool().createIdentifierValue(currentValue->id); | 4812 return cssValuePool().createIdentifierValue(currentValue->id); |
4813 | 4813 |
4814 if (currentValue->unit == CSSPrimitiveValue::CSS_FR) { | 4814 if (currentValue->unit == CSSPrimitiveValue::CSS_FR) { |
4815 double flexValue = currentValue->fValue; | 4815 double flexValue = currentValue->fValue; |
4816 | 4816 |
4817 // Fractional unit is a non-negative dimension. | 4817 // Fractional unit is a non-negative dimension. |
4818 if (flexValue <= 0) | 4818 if (flexValue <= 0) |
4819 return 0; | 4819 return nullptr; |
4820 | 4820 |
4821 return cssValuePool().createValue(flexValue, CSSPrimitiveValue::CSS_FR); | 4821 return cssValuePool().createValue(flexValue, CSSPrimitiveValue::CSS_FR); |
4822 } | 4822 } |
4823 | 4823 |
4824 if (!validUnit(currentValue, FNonNeg | FLength | FPercent)) | 4824 if (!validUnit(currentValue, FNonNeg | FLength | FPercent)) |
4825 return 0; | 4825 return nullptr; |
4826 | 4826 |
4827 return createPrimitiveNumericValue(currentValue); | 4827 return createPrimitiveNumericValue(currentValue); |
4828 } | 4828 } |
4829 | 4829 |
4830 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseGridTemplateAreas() | 4830 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseGridTemplateAreas() |
4831 { | 4831 { |
4832 NamedGridAreaMap gridAreaMap; | 4832 NamedGridAreaMap gridAreaMap; |
4833 size_t rowCount = 0; | 4833 size_t rowCount = 0; |
4834 size_t columnCount = 0; | 4834 size_t columnCount = 0; |
4835 | 4835 |
4836 while (CSSParserValue* currentValue = m_valueList->current()) { | 4836 while (CSSParserValue* currentValue = m_valueList->current()) { |
4837 if (currentValue->unit != CSSPrimitiveValue::CSS_STRING) | 4837 if (currentValue->unit != CSSPrimitiveValue::CSS_STRING) |
4838 return 0; | 4838 return nullptr; |
4839 | 4839 |
4840 String gridRowNames = currentValue->string; | 4840 String gridRowNames = currentValue->string; |
4841 if (!gridRowNames.length()) | 4841 if (!gridRowNames.length()) |
4842 return 0; | 4842 return nullptr; |
4843 | 4843 |
4844 Vector<String> columnNames; | 4844 Vector<String> columnNames; |
4845 gridRowNames.split(' ', columnNames); | 4845 gridRowNames.split(' ', columnNames); |
4846 | 4846 |
4847 if (!columnCount) { | 4847 if (!columnCount) { |
4848 columnCount = columnNames.size(); | 4848 columnCount = columnNames.size(); |
4849 ASSERT(columnCount); | 4849 ASSERT(columnCount); |
4850 } else if (columnCount != columnNames.size()) { | 4850 } else if (columnCount != columnNames.size()) { |
4851 // The declaration is invalid is all the rows don't have the number
of columns. | 4851 // The declaration is invalid is all the rows don't have the number
of columns. |
4852 return 0; | 4852 return nullptr; |
4853 } | 4853 } |
4854 | 4854 |
4855 for (size_t currentCol = 0; currentCol < columnCount; ++currentCol) { | 4855 for (size_t currentCol = 0; currentCol < columnCount; ++currentCol) { |
4856 const String& gridAreaName = columnNames[currentCol]; | 4856 const String& gridAreaName = columnNames[currentCol]; |
4857 | 4857 |
4858 // Unamed areas are always valid (we consider them to be 1x1). | 4858 // Unamed areas are always valid (we consider them to be 1x1). |
4859 if (gridAreaName == ".") | 4859 if (gridAreaName == ".") |
4860 continue; | 4860 continue; |
4861 | 4861 |
4862 // We handle several grid areas with the same name at once to simpli
fy the validation code. | 4862 // We handle several grid areas with the same name at once to simpli
fy the validation code. |
4863 size_t lookAheadCol; | 4863 size_t lookAheadCol; |
4864 for (lookAheadCol = currentCol; lookAheadCol < (columnCount - 1); ++
lookAheadCol) { | 4864 for (lookAheadCol = currentCol; lookAheadCol < (columnCount - 1); ++
lookAheadCol) { |
4865 if (columnNames[lookAheadCol + 1] != gridAreaName) | 4865 if (columnNames[lookAheadCol + 1] != gridAreaName) |
4866 break; | 4866 break; |
4867 } | 4867 } |
4868 | 4868 |
4869 NamedGridAreaMap::iterator gridAreaIt = gridAreaMap.find(gridAreaNam
e); | 4869 NamedGridAreaMap::iterator gridAreaIt = gridAreaMap.find(gridAreaNam
e); |
4870 if (gridAreaIt == gridAreaMap.end()) { | 4870 if (gridAreaIt == gridAreaMap.end()) { |
4871 gridAreaMap.add(gridAreaName, GridCoordinate(GridSpan(rowCount,
rowCount), GridSpan(currentCol, lookAheadCol))); | 4871 gridAreaMap.add(gridAreaName, GridCoordinate(GridSpan(rowCount,
rowCount), GridSpan(currentCol, lookAheadCol))); |
4872 } else { | 4872 } else { |
4873 GridCoordinate& gridCoordinate = gridAreaIt->value; | 4873 GridCoordinate& gridCoordinate = gridAreaIt->value; |
4874 | 4874 |
4875 // The following checks test that the grid area is a single fill
ed-in rectangle. | 4875 // The following checks test that the grid area is a single fill
ed-in rectangle. |
4876 // 1. The new row is adjacent to the previously parsed row. | 4876 // 1. The new row is adjacent to the previously parsed row. |
4877 if (rowCount != gridCoordinate.rows.initialPositionIndex + 1) | 4877 if (rowCount != gridCoordinate.rows.initialPositionIndex + 1) |
4878 return 0; | 4878 return nullptr; |
4879 | 4879 |
4880 // 2. The new area starts at the same position as the previously
parsed area. | 4880 // 2. The new area starts at the same position as the previously
parsed area. |
4881 if (currentCol != gridCoordinate.columns.initialPositionIndex) | 4881 if (currentCol != gridCoordinate.columns.initialPositionIndex) |
4882 return 0; | 4882 return nullptr; |
4883 | 4883 |
4884 // 3. The new area ends at the same position as the previously p
arsed area. | 4884 // 3. The new area ends at the same position as the previously p
arsed area. |
4885 if (lookAheadCol != gridCoordinate.columns.finalPositionIndex) | 4885 if (lookAheadCol != gridCoordinate.columns.finalPositionIndex) |
4886 return 0; | 4886 return nullptr; |
4887 | 4887 |
4888 ++gridCoordinate.rows.finalPositionIndex; | 4888 ++gridCoordinate.rows.finalPositionIndex; |
4889 } | 4889 } |
4890 currentCol = lookAheadCol; | 4890 currentCol = lookAheadCol; |
4891 } | 4891 } |
4892 | 4892 |
4893 ++rowCount; | 4893 ++rowCount; |
4894 m_valueList->next(); | 4894 m_valueList->next(); |
4895 } | 4895 } |
4896 | 4896 |
4897 if (!rowCount || !columnCount) | 4897 if (!rowCount || !columnCount) |
4898 return 0; | 4898 return nullptr; |
4899 | 4899 |
4900 return CSSGridTemplateAreasValue::create(gridAreaMap, rowCount, columnCount)
; | 4900 return CSSGridTemplateAreasValue::create(gridAreaMap, rowCount, columnCount)
; |
4901 } | 4901 } |
4902 | 4902 |
4903 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseCounterContent(CSSParse
rValueList* args, bool counters) | 4903 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseCounterContent(CSSParse
rValueList* args, bool counters) |
4904 { | 4904 { |
4905 unsigned numArgs = args->size(); | 4905 unsigned numArgs = args->size(); |
4906 if (counters && numArgs != 3 && numArgs != 5) | 4906 if (counters && numArgs != 3 && numArgs != 5) |
4907 return 0; | 4907 return nullptr; |
4908 if (!counters && numArgs != 1 && numArgs != 3) | 4908 if (!counters && numArgs != 1 && numArgs != 3) |
4909 return 0; | 4909 return nullptr; |
4910 | 4910 |
4911 CSSParserValue* i = args->current(); | 4911 CSSParserValue* i = args->current(); |
4912 if (i->unit != CSSPrimitiveValue::CSS_IDENT) | 4912 if (i->unit != CSSPrimitiveValue::CSS_IDENT) |
4913 return 0; | 4913 return nullptr; |
4914 RefPtrWillBeRawPtr<CSSPrimitiveValue> identifier = createPrimitiveStringValu
e(i); | 4914 RefPtrWillBeRawPtr<CSSPrimitiveValue> identifier = createPrimitiveStringValu
e(i); |
4915 | 4915 |
4916 RefPtrWillBeRawPtr<CSSPrimitiveValue> separator; | 4916 RefPtrWillBeRawPtr<CSSPrimitiveValue> separator; |
4917 if (!counters) | 4917 if (!counters) |
4918 separator = cssValuePool().createValue(String(), CSSPrimitiveValue::CSS_
STRING); | 4918 separator = cssValuePool().createValue(String(), CSSPrimitiveValue::CSS_
STRING); |
4919 else { | 4919 else { |
4920 i = args->next(); | 4920 i = args->next(); |
4921 if (i->unit != CSSParserValue::Operator || i->iValue != ',') | 4921 if (i->unit != CSSParserValue::Operator || i->iValue != ',') |
4922 return 0; | 4922 return nullptr; |
4923 | 4923 |
4924 i = args->next(); | 4924 i = args->next(); |
4925 if (i->unit != CSSPrimitiveValue::CSS_STRING) | 4925 if (i->unit != CSSPrimitiveValue::CSS_STRING) |
4926 return 0; | 4926 return nullptr; |
4927 | 4927 |
4928 separator = createPrimitiveStringValue(i); | 4928 separator = createPrimitiveStringValue(i); |
4929 } | 4929 } |
4930 | 4930 |
4931 RefPtrWillBeRawPtr<CSSPrimitiveValue> listStyle; | 4931 RefPtrWillBeRawPtr<CSSPrimitiveValue> listStyle; |
4932 i = args->next(); | 4932 i = args->next(); |
4933 if (!i) // Make the list style default decimal | 4933 if (!i) // Make the list style default decimal |
4934 listStyle = cssValuePool().createIdentifierValue(CSSValueDecimal); | 4934 listStyle = cssValuePool().createIdentifierValue(CSSValueDecimal); |
4935 else { | 4935 else { |
4936 if (i->unit != CSSParserValue::Operator || i->iValue != ',') | 4936 if (i->unit != CSSParserValue::Operator || i->iValue != ',') |
4937 return 0; | 4937 return nullptr; |
4938 | 4938 |
4939 i = args->next(); | 4939 i = args->next(); |
4940 if (i->unit != CSSPrimitiveValue::CSS_IDENT) | 4940 if (i->unit != CSSPrimitiveValue::CSS_IDENT) |
4941 return 0; | 4941 return nullptr; |
4942 | 4942 |
4943 CSSValueID listStyleID = CSSValueInvalid; | 4943 CSSValueID listStyleID = CSSValueInvalid; |
4944 if (i->id == CSSValueNone || (i->id >= CSSValueDisc && i->id <= CSSValue
KatakanaIroha)) | 4944 if (i->id == CSSValueNone || (i->id >= CSSValueDisc && i->id <= CSSValue
KatakanaIroha)) |
4945 listStyleID = i->id; | 4945 listStyleID = i->id; |
4946 else | 4946 else |
4947 return 0; | 4947 return nullptr; |
4948 | 4948 |
4949 listStyle = cssValuePool().createIdentifierValue(listStyleID); | 4949 listStyle = cssValuePool().createIdentifierValue(listStyleID); |
4950 } | 4950 } |
4951 | 4951 |
4952 return cssValuePool().createValue(Counter::create(identifier.release(), list
Style.release(), separator.release())); | 4952 return cssValuePool().createValue(Counter::create(identifier.release(), list
Style.release(), separator.release())); |
4953 } | 4953 } |
4954 | 4954 |
4955 bool CSSPropertyParser::parseClipShape(CSSPropertyID propId, bool important) | 4955 bool CSSPropertyParser::parseClipShape(CSSPropertyID propId, bool important) |
4956 { | 4956 { |
4957 CSSParserValue* value = m_valueList->current(); | 4957 CSSParserValue* value = m_valueList->current(); |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5013 radii[3] = radii[1]; | 5013 radii[3] = radii[1]; |
5014 } | 5014 } |
5015 | 5015 |
5016 // FIXME: This should be refactored with CSSParser::parseBorderRadius. | 5016 // FIXME: This should be refactored with CSSParser::parseBorderRadius. |
5017 // CSSParser::parseBorderRadius contains support for some legacy radius construc
tion. | 5017 // CSSParser::parseBorderRadius contains support for some legacy radius construc
tion. |
5018 PassRefPtrWillBeRawPtr<CSSBasicShape> CSSPropertyParser::parseInsetRoundedCorner
s(PassRefPtrWillBeRawPtr<CSSBasicShapeInset> shape, CSSParserValueList* args) | 5018 PassRefPtrWillBeRawPtr<CSSBasicShape> CSSPropertyParser::parseInsetRoundedCorner
s(PassRefPtrWillBeRawPtr<CSSBasicShapeInset> shape, CSSParserValueList* args) |
5019 { | 5019 { |
5020 CSSParserValue* argument = args->next(); | 5020 CSSParserValue* argument = args->next(); |
5021 | 5021 |
5022 if (!argument) | 5022 if (!argument) |
5023 return 0; | 5023 return nullptr; |
5024 | 5024 |
5025 CSSParserValueList radiusArguments; | 5025 CSSParserValueList radiusArguments; |
5026 while (argument) { | 5026 while (argument) { |
5027 radiusArguments.addValue(*argument); | 5027 radiusArguments.addValue(*argument); |
5028 argument = args->next(); | 5028 argument = args->next(); |
5029 } | 5029 } |
5030 | 5030 |
5031 unsigned num = radiusArguments.size(); | 5031 unsigned num = radiusArguments.size(); |
5032 if (!num || num > 9) | 5032 if (!num || num > 9) |
5033 return 0; | 5033 return nullptr; |
5034 | 5034 |
5035 // FIXME: Refactor completeBorderRadii and the array | 5035 // FIXME: Refactor completeBorderRadii and the array |
5036 RefPtrWillBeRawPtr<CSSPrimitiveValue> radii[2][4]; | 5036 RefPtrWillBeRawPtr<CSSPrimitiveValue> radii[2][4]; |
5037 | 5037 |
5038 unsigned indexAfterSlash = 0; | 5038 unsigned indexAfterSlash = 0; |
5039 for (unsigned i = 0; i < num; ++i) { | 5039 for (unsigned i = 0; i < num; ++i) { |
5040 CSSParserValue* value = radiusArguments.valueAt(i); | 5040 CSSParserValue* value = radiusArguments.valueAt(i); |
5041 if (value->unit == CSSParserValue::Operator) { | 5041 if (value->unit == CSSParserValue::Operator) { |
5042 if (value->iValue != '/') | 5042 if (value->iValue != '/') |
5043 return 0; | 5043 return nullptr; |
5044 | 5044 |
5045 if (!i || indexAfterSlash || i + 1 == num) | 5045 if (!i || indexAfterSlash || i + 1 == num) |
5046 return 0; | 5046 return nullptr; |
5047 | 5047 |
5048 indexAfterSlash = i + 1; | 5048 indexAfterSlash = i + 1; |
5049 completeBorderRadii(radii[0]); | 5049 completeBorderRadii(radii[0]); |
5050 continue; | 5050 continue; |
5051 } | 5051 } |
5052 | 5052 |
5053 if (i - indexAfterSlash >= 4) | 5053 if (i - indexAfterSlash >= 4) |
5054 return 0; | 5054 return nullptr; |
5055 | 5055 |
5056 if (!validUnit(value, FLength | FPercent | FNonNeg)) | 5056 if (!validUnit(value, FLength | FPercent | FNonNeg)) |
5057 return 0; | 5057 return nullptr; |
5058 | 5058 |
5059 RefPtrWillBeRawPtr<CSSPrimitiveValue> radius = createPrimitiveNumericVal
ue(value); | 5059 RefPtrWillBeRawPtr<CSSPrimitiveValue> radius = createPrimitiveNumericVal
ue(value); |
5060 | 5060 |
5061 if (!indexAfterSlash) | 5061 if (!indexAfterSlash) |
5062 radii[0][i] = radius; | 5062 radii[0][i] = radius; |
5063 else | 5063 else |
5064 radii[1][i - indexAfterSlash] = radius.release(); | 5064 radii[1][i - indexAfterSlash] = radius.release(); |
5065 } | 5065 } |
5066 | 5066 |
5067 if (!indexAfterSlash) { | 5067 if (!indexAfterSlash) { |
(...skipping 22 matching lines...) Expand all Loading... |
5090 bool hasRoundedInset = false; | 5090 bool hasRoundedInset = false; |
5091 | 5091 |
5092 while (argument) { | 5092 while (argument) { |
5093 if (argument->unit == CSSPrimitiveValue::CSS_IDENT && equalIgnoringCase(
argument->string, "round")) { | 5093 if (argument->unit == CSSPrimitiveValue::CSS_IDENT && equalIgnoringCase(
argument->string, "round")) { |
5094 hasRoundedInset = true; | 5094 hasRoundedInset = true; |
5095 break; | 5095 break; |
5096 } | 5096 } |
5097 | 5097 |
5098 Units unitFlags = FLength | FPercent; | 5098 Units unitFlags = FLength | FPercent; |
5099 if (!validUnit(argument, unitFlags) || widthArguments.size() > 4) | 5099 if (!validUnit(argument, unitFlags) || widthArguments.size() > 4) |
5100 return 0; | 5100 return nullptr; |
5101 | 5101 |
5102 widthArguments.append(createPrimitiveNumericValue(argument)); | 5102 widthArguments.append(createPrimitiveNumericValue(argument)); |
5103 argument = args->next(); | 5103 argument = args->next(); |
5104 } | 5104 } |
5105 | 5105 |
5106 switch (widthArguments.size()) { | 5106 switch (widthArguments.size()) { |
5107 case 1: { | 5107 case 1: { |
5108 shape->updateShapeSize1Value(widthArguments[0].get()); | 5108 shape->updateShapeSize1Value(widthArguments[0].get()); |
5109 break; | 5109 break; |
5110 } | 5110 } |
5111 case 2: { | 5111 case 2: { |
5112 shape->updateShapeSize2Values(widthArguments[0].get(), widthArguments[1]
.get()); | 5112 shape->updateShapeSize2Values(widthArguments[0].get(), widthArguments[1]
.get()); |
5113 break; | 5113 break; |
5114 } | 5114 } |
5115 case 3: { | 5115 case 3: { |
5116 shape->updateShapeSize3Values(widthArguments[0].get(), widthArguments[1]
.get(), widthArguments[2].get()); | 5116 shape->updateShapeSize3Values(widthArguments[0].get(), widthArguments[1]
.get(), widthArguments[2].get()); |
5117 break; | 5117 break; |
5118 } | 5118 } |
5119 case 4: { | 5119 case 4: { |
5120 shape->updateShapeSize4Values(widthArguments[0].get(), widthArguments[1]
.get(), widthArguments[2].get(), widthArguments[3].get()); | 5120 shape->updateShapeSize4Values(widthArguments[0].get(), widthArguments[1]
.get(), widthArguments[2].get(), widthArguments[3].get()); |
5121 break; | 5121 break; |
5122 } | 5122 } |
5123 default: | 5123 default: |
5124 return 0; | 5124 return nullptr; |
5125 } | 5125 } |
5126 | 5126 |
5127 if (hasRoundedInset) | 5127 if (hasRoundedInset) |
5128 return parseInsetRoundedCorners(shape, args); | 5128 return parseInsetRoundedCorners(shape, args); |
5129 return shape; | 5129 return shape; |
5130 } | 5130 } |
5131 | 5131 |
5132 static bool isItemPositionKeyword(CSSValueID id) | 5132 static bool isItemPositionKeyword(CSSValueID id) |
5133 { | 5133 { |
5134 return id == CSSValueStart || id == CSSValueEnd || id == CSSValueCenter | 5134 return id == CSSValueStart || id == CSSValueEnd || id == CSSValueCenter |
(...skipping 10 matching lines...) Expand all Loading... |
5145 CSSParserValue* value = m_valueList->current(); | 5145 CSSParserValue* value = m_valueList->current(); |
5146 | 5146 |
5147 if (value->id == CSSValueAuto || value->id == CSSValueBaseline || value->id
== CSSValueStretch) { | 5147 if (value->id == CSSValueAuto || value->id == CSSValueBaseline || value->id
== CSSValueStretch) { |
5148 if (m_valueList->next()) | 5148 if (m_valueList->next()) |
5149 return false; | 5149 return false; |
5150 | 5150 |
5151 addProperty(propId, cssValuePool().createIdentifierValue(value->id), imp
ortant); | 5151 addProperty(propId, cssValuePool().createIdentifierValue(value->id), imp
ortant); |
5152 return true; | 5152 return true; |
5153 } | 5153 } |
5154 | 5154 |
5155 RefPtrWillBeRawPtr<CSSPrimitiveValue> position = 0; | 5155 RefPtrWillBeRawPtr<CSSPrimitiveValue> position = nullptr; |
5156 RefPtrWillBeRawPtr<CSSPrimitiveValue> overflowAlignmentKeyword = 0; | 5156 RefPtrWillBeRawPtr<CSSPrimitiveValue> overflowAlignmentKeyword = nullptr; |
5157 if (isItemPositionKeyword(value->id)) { | 5157 if (isItemPositionKeyword(value->id)) { |
5158 position = cssValuePool().createIdentifierValue(value->id); | 5158 position = cssValuePool().createIdentifierValue(value->id); |
5159 value = m_valueList->next(); | 5159 value = m_valueList->next(); |
5160 if (value) { | 5160 if (value) { |
5161 if (value->id == CSSValueTrue || value->id == CSSValueSafe) | 5161 if (value->id == CSSValueTrue || value->id == CSSValueSafe) |
5162 overflowAlignmentKeyword = cssValuePool().createIdentifierValue(
value->id); | 5162 overflowAlignmentKeyword = cssValuePool().createIdentifierValue(
value->id); |
5163 else | 5163 else |
5164 return false; | 5164 return false; |
5165 } | 5165 } |
5166 } else if (value->id == CSSValueTrue || value->id == CSSValueSafe) { | 5166 } else if (value->id == CSSValueTrue || value->id == CSSValueSafe) { |
(...skipping 20 matching lines...) Expand all Loading... |
5187 | 5187 |
5188 return true; | 5188 return true; |
5189 } | 5189 } |
5190 | 5190 |
5191 PassRefPtrWillBeRawPtr<CSSBasicShape> CSSPropertyParser::parseBasicShapeRectangl
e(CSSParserValueList* args) | 5191 PassRefPtrWillBeRawPtr<CSSBasicShape> CSSPropertyParser::parseBasicShapeRectangl
e(CSSParserValueList* args) |
5192 { | 5192 { |
5193 ASSERT(args); | 5193 ASSERT(args); |
5194 | 5194 |
5195 // rect(x, y, width, height, [[rx], ry]) | 5195 // rect(x, y, width, height, [[rx], ry]) |
5196 if (args->size() != 7 && args->size() != 9 && args->size() != 11) | 5196 if (args->size() != 7 && args->size() != 9 && args->size() != 11) |
5197 return 0; | 5197 return nullptr; |
5198 | 5198 |
5199 RefPtrWillBeRawPtr<CSSBasicShapeRectangle> shape = CSSBasicShapeRectangle::c
reate(); | 5199 RefPtrWillBeRawPtr<CSSBasicShapeRectangle> shape = CSSBasicShapeRectangle::c
reate(); |
5200 | 5200 |
5201 unsigned argumentNumber = 0; | 5201 unsigned argumentNumber = 0; |
5202 CSSParserValue* argument = args->current(); | 5202 CSSParserValue* argument = args->current(); |
5203 while (argument) { | 5203 while (argument) { |
5204 Units unitFlags = FLength | FPercent; | 5204 Units unitFlags = FLength | FPercent; |
5205 if (argumentNumber > 1) { | 5205 if (argumentNumber > 1) { |
5206 // Arguments width, height, rx, and ry cannot be negative. | 5206 // Arguments width, height, rx, and ry cannot be negative. |
5207 unitFlags = unitFlags | FNonNeg; | 5207 unitFlags = unitFlags | FNonNeg; |
5208 } | 5208 } |
5209 if (!validUnit(argument, unitFlags)) | 5209 if (!validUnit(argument, unitFlags)) |
5210 return 0; | 5210 return nullptr; |
5211 | 5211 |
5212 RefPtrWillBeRawPtr<CSSPrimitiveValue> length = createPrimitiveNumericVal
ue(argument); | 5212 RefPtrWillBeRawPtr<CSSPrimitiveValue> length = createPrimitiveNumericVal
ue(argument); |
5213 ASSERT(argumentNumber < 6); | 5213 ASSERT(argumentNumber < 6); |
5214 switch (argumentNumber) { | 5214 switch (argumentNumber) { |
5215 case 0: | 5215 case 0: |
5216 shape->setX(length); | 5216 shape->setX(length); |
5217 break; | 5217 break; |
5218 case 1: | 5218 case 1: |
5219 shape->setY(length); | 5219 shape->setY(length); |
5220 break; | 5220 break; |
5221 case 2: | 5221 case 2: |
5222 shape->setWidth(length); | 5222 shape->setWidth(length); |
5223 break; | 5223 break; |
5224 case 3: | 5224 case 3: |
5225 shape->setHeight(length); | 5225 shape->setHeight(length); |
5226 break; | 5226 break; |
5227 case 4: | 5227 case 4: |
5228 shape->setRadiusX(length); | 5228 shape->setRadiusX(length); |
5229 break; | 5229 break; |
5230 case 5: | 5230 case 5: |
5231 shape->setRadiusY(length); | 5231 shape->setRadiusY(length); |
5232 break; | 5232 break; |
5233 } | 5233 } |
5234 argument = args->next(); | 5234 argument = args->next(); |
5235 if (argument) { | 5235 if (argument) { |
5236 if (!isComma(argument)) | 5236 if (!isComma(argument)) |
5237 return 0; | 5237 return nullptr; |
5238 | 5238 |
5239 argument = args->next(); | 5239 argument = args->next(); |
5240 } | 5240 } |
5241 argumentNumber++; | 5241 argumentNumber++; |
5242 } | 5242 } |
5243 | 5243 |
5244 if (argumentNumber < 4) | 5244 if (argumentNumber < 4) |
5245 return 0; | 5245 return nullptr; |
5246 return shape; | 5246 return shape; |
5247 } | 5247 } |
5248 | 5248 |
5249 PassRefPtrWillBeRawPtr<CSSBasicShape> CSSPropertyParser::parseBasicShapeInsetRec
tangle(CSSParserValueList* args) | 5249 PassRefPtrWillBeRawPtr<CSSBasicShape> CSSPropertyParser::parseBasicShapeInsetRec
tangle(CSSParserValueList* args) |
5250 { | 5250 { |
5251 ASSERT(args); | 5251 ASSERT(args); |
5252 | 5252 |
5253 // inset-rectangle(top, right, bottom, left, [[rx], ry]) | 5253 // inset-rectangle(top, right, bottom, left, [[rx], ry]) |
5254 if (args->size() != 7 && args->size() != 9 && args->size() != 11) | 5254 if (args->size() != 7 && args->size() != 9 && args->size() != 11) |
5255 return 0; | 5255 return nullptr; |
5256 | 5256 |
5257 RefPtrWillBeRawPtr<CSSBasicShapeInsetRectangle> shape = CSSBasicShapeInsetRe
ctangle::create(); | 5257 RefPtrWillBeRawPtr<CSSBasicShapeInsetRectangle> shape = CSSBasicShapeInsetRe
ctangle::create(); |
5258 | 5258 |
5259 unsigned argumentNumber = 0; | 5259 unsigned argumentNumber = 0; |
5260 CSSParserValue* argument = args->current(); | 5260 CSSParserValue* argument = args->current(); |
5261 while (argument) { | 5261 while (argument) { |
5262 Units unitFlags = FLength | FPercent | FNonNeg; | 5262 Units unitFlags = FLength | FPercent | FNonNeg; |
5263 if (!validUnit(argument, unitFlags)) | 5263 if (!validUnit(argument, unitFlags)) |
5264 return 0; | 5264 return nullptr; |
5265 | 5265 |
5266 RefPtrWillBeRawPtr<CSSPrimitiveValue> length = createPrimitiveNumericVal
ue(argument); | 5266 RefPtrWillBeRawPtr<CSSPrimitiveValue> length = createPrimitiveNumericVal
ue(argument); |
5267 ASSERT(argumentNumber < 6); | 5267 ASSERT(argumentNumber < 6); |
5268 switch (argumentNumber) { | 5268 switch (argumentNumber) { |
5269 case 0: | 5269 case 0: |
5270 shape->setTop(length); | 5270 shape->setTop(length); |
5271 break; | 5271 break; |
5272 case 1: | 5272 case 1: |
5273 shape->setRight(length); | 5273 shape->setRight(length); |
5274 break; | 5274 break; |
5275 case 2: | 5275 case 2: |
5276 shape->setBottom(length); | 5276 shape->setBottom(length); |
5277 break; | 5277 break; |
5278 case 3: | 5278 case 3: |
5279 shape->setLeft(length); | 5279 shape->setLeft(length); |
5280 break; | 5280 break; |
5281 case 4: | 5281 case 4: |
5282 shape->setRadiusX(length); | 5282 shape->setRadiusX(length); |
5283 break; | 5283 break; |
5284 case 5: | 5284 case 5: |
5285 shape->setRadiusY(length); | 5285 shape->setRadiusY(length); |
5286 break; | 5286 break; |
5287 } | 5287 } |
5288 argument = args->next(); | 5288 argument = args->next(); |
5289 if (argument) { | 5289 if (argument) { |
5290 if (!isComma(argument)) | 5290 if (!isComma(argument)) |
5291 return 0; | 5291 return nullptr; |
5292 | 5292 |
5293 argument = args->next(); | 5293 argument = args->next(); |
5294 } | 5294 } |
5295 argumentNumber++; | 5295 argumentNumber++; |
5296 } | 5296 } |
5297 | 5297 |
5298 if (argumentNumber < 4) | 5298 if (argumentNumber < 4) |
5299 return 0; | 5299 return nullptr; |
5300 return shape; | 5300 return shape; |
5301 } | 5301 } |
5302 | 5302 |
5303 PassRefPtrWillBeRawPtr<CSSPrimitiveValue> CSSPropertyParser::parseShapeRadius(CS
SParserValue* value) | 5303 PassRefPtrWillBeRawPtr<CSSPrimitiveValue> CSSPropertyParser::parseShapeRadius(CS
SParserValue* value) |
5304 { | 5304 { |
5305 if (value->id == CSSValueClosestSide || value->id == CSSValueFarthestSide) | 5305 if (value->id == CSSValueClosestSide || value->id == CSSValueFarthestSide) |
5306 return cssValuePool().createIdentifierValue(value->id); | 5306 return cssValuePool().createIdentifierValue(value->id); |
5307 | 5307 |
5308 if (!validUnit(value, FLength | FPercent | FNonNeg)) | 5308 if (!validUnit(value, FLength | FPercent | FNonNeg)) |
5309 return 0; | 5309 return nullptr; |
5310 | 5310 |
5311 return createPrimitiveNumericValue(value); | 5311 return createPrimitiveNumericValue(value); |
5312 } | 5312 } |
5313 | 5313 |
5314 PassRefPtrWillBeRawPtr<CSSBasicShape> CSSPropertyParser::parseBasicShapeCircle(C
SSParserValueList* args) | 5314 PassRefPtrWillBeRawPtr<CSSBasicShape> CSSPropertyParser::parseBasicShapeCircle(C
SSParserValueList* args) |
5315 { | 5315 { |
5316 ASSERT(args); | 5316 ASSERT(args); |
5317 | 5317 |
5318 // circle(radius) | 5318 // circle(radius) |
5319 // circle(radius at <position> | 5319 // circle(radius at <position> |
5320 // circle(at <position>) | 5320 // circle(at <position>) |
5321 // where position defines centerX and centerY using a CSS <position> data ty
pe. | 5321 // where position defines centerX and centerY using a CSS <position> data ty
pe. |
5322 RefPtrWillBeRawPtr<CSSBasicShapeCircle> shape = CSSBasicShapeCircle::create(
); | 5322 RefPtrWillBeRawPtr<CSSBasicShapeCircle> shape = CSSBasicShapeCircle::create(
); |
5323 | 5323 |
5324 for (CSSParserValue* argument = args->current(); argument; argument = args->
next()) { | 5324 for (CSSParserValue* argument = args->current(); argument; argument = args->
next()) { |
5325 // The call to parseFillPosition below should consume all of the | 5325 // The call to parseFillPosition below should consume all of the |
5326 // arguments except the first two. Thus, and index greater than one | 5326 // arguments except the first two. Thus, and index greater than one |
5327 // indicates an invalid production. | 5327 // indicates an invalid production. |
5328 if (args->currentIndex() > 1) | 5328 if (args->currentIndex() > 1) |
5329 return 0; | 5329 return nullptr; |
5330 | 5330 |
5331 if (!args->currentIndex() && argument->id != CSSValueAt) { | 5331 if (!args->currentIndex() && argument->id != CSSValueAt) { |
5332 if (RefPtrWillBeRawPtr<CSSPrimitiveValue> radius = parseShapeRadius(
argument)) { | 5332 if (RefPtrWillBeRawPtr<CSSPrimitiveValue> radius = parseShapeRadius(
argument)) { |
5333 shape->setRadius(radius); | 5333 shape->setRadius(radius); |
5334 continue; | 5334 continue; |
5335 } | 5335 } |
5336 | 5336 |
5337 return 0; | 5337 return nullptr; |
5338 } | 5338 } |
5339 | 5339 |
5340 if (argument->id == CSSValueAt) { | 5340 if (argument->id == CSSValueAt) { |
5341 RefPtrWillBeRawPtr<CSSValue> centerX; | 5341 RefPtrWillBeRawPtr<CSSValue> centerX; |
5342 RefPtrWillBeRawPtr<CSSValue> centerY; | 5342 RefPtrWillBeRawPtr<CSSValue> centerY; |
5343 args->next(); // set list to start of position center | 5343 args->next(); // set list to start of position center |
5344 parseFillPosition(args, centerX, centerY); | 5344 parseFillPosition(args, centerX, centerY); |
5345 if (centerX && centerY) { | 5345 if (centerX && centerY) { |
5346 ASSERT(centerX->isPrimitiveValue()); | 5346 ASSERT(centerX->isPrimitiveValue()); |
5347 ASSERT(centerY->isPrimitiveValue()); | 5347 ASSERT(centerY->isPrimitiveValue()); |
5348 shape->setCenterX(toCSSPrimitiveValue(centerX.get())); | 5348 shape->setCenterX(toCSSPrimitiveValue(centerX.get())); |
5349 shape->setCenterY(toCSSPrimitiveValue(centerY.get())); | 5349 shape->setCenterY(toCSSPrimitiveValue(centerY.get())); |
5350 } else { | 5350 } else { |
5351 return 0; | 5351 return nullptr; |
5352 } | 5352 } |
5353 } else { | 5353 } else { |
5354 return 0; | 5354 return nullptr; |
5355 } | 5355 } |
5356 } | 5356 } |
5357 | 5357 |
5358 return shape; | 5358 return shape; |
5359 } | 5359 } |
5360 | 5360 |
5361 PassRefPtrWillBeRawPtr<CSSBasicShape> CSSPropertyParser::parseDeprecatedBasicSha
peCircle(CSSParserValueList* args) | 5361 PassRefPtrWillBeRawPtr<CSSBasicShape> CSSPropertyParser::parseDeprecatedBasicSha
peCircle(CSSParserValueList* args) |
5362 { | 5362 { |
5363 ASSERT(args); | 5363 ASSERT(args); |
5364 | 5364 |
5365 // circle(centerX, centerY, radius) | 5365 // circle(centerX, centerY, radius) |
5366 if (args->size() != 5) | 5366 if (args->size() != 5) |
5367 return 0; | 5367 return nullptr; |
5368 | 5368 |
5369 RefPtrWillBeRawPtr<CSSDeprecatedBasicShapeCircle> shape = CSSDeprecatedBasic
ShapeCircle::create(); | 5369 RefPtrWillBeRawPtr<CSSDeprecatedBasicShapeCircle> shape = CSSDeprecatedBasic
ShapeCircle::create(); |
5370 | 5370 |
5371 unsigned argumentNumber = 0; | 5371 unsigned argumentNumber = 0; |
5372 CSSParserValue* argument = args->current(); | 5372 CSSParserValue* argument = args->current(); |
5373 while (argument) { | 5373 while (argument) { |
5374 Units unitFlags = FLength | FPercent; | 5374 Units unitFlags = FLength | FPercent; |
5375 if (argumentNumber == 2) { | 5375 if (argumentNumber == 2) { |
5376 // Argument radius cannot be negative. | 5376 // Argument radius cannot be negative. |
5377 unitFlags = unitFlags | FNonNeg; | 5377 unitFlags = unitFlags | FNonNeg; |
5378 } | 5378 } |
5379 | 5379 |
5380 if (!validUnit(argument, unitFlags)) | 5380 if (!validUnit(argument, unitFlags)) |
5381 return 0; | 5381 return nullptr; |
5382 | 5382 |
5383 RefPtrWillBeRawPtr<CSSPrimitiveValue> length = createPrimitiveNumericVal
ue(argument); | 5383 RefPtrWillBeRawPtr<CSSPrimitiveValue> length = createPrimitiveNumericVal
ue(argument); |
5384 ASSERT(argumentNumber < 3); | 5384 ASSERT(argumentNumber < 3); |
5385 switch (argumentNumber) { | 5385 switch (argumentNumber) { |
5386 case 0: | 5386 case 0: |
5387 shape->setCenterX(length); | 5387 shape->setCenterX(length); |
5388 break; | 5388 break; |
5389 case 1: | 5389 case 1: |
5390 shape->setCenterY(length); | 5390 shape->setCenterY(length); |
5391 break; | 5391 break; |
5392 case 2: | 5392 case 2: |
5393 shape->setRadius(length); | 5393 shape->setRadius(length); |
5394 break; | 5394 break; |
5395 } | 5395 } |
5396 | 5396 |
5397 argument = args->next(); | 5397 argument = args->next(); |
5398 if (argument) { | 5398 if (argument) { |
5399 if (!isComma(argument)) | 5399 if (!isComma(argument)) |
5400 return 0; | 5400 return nullptr; |
5401 argument = args->next(); | 5401 argument = args->next(); |
5402 } | 5402 } |
5403 argumentNumber++; | 5403 argumentNumber++; |
5404 } | 5404 } |
5405 | 5405 |
5406 if (argumentNumber < 3) | 5406 if (argumentNumber < 3) |
5407 return 0; | 5407 return nullptr; |
5408 return shape; | 5408 return shape; |
5409 } | 5409 } |
5410 | 5410 |
5411 PassRefPtrWillBeRawPtr<CSSBasicShape> CSSPropertyParser::parseBasicShapeEllipse(
CSSParserValueList* args) | 5411 PassRefPtrWillBeRawPtr<CSSBasicShape> CSSPropertyParser::parseBasicShapeEllipse(
CSSParserValueList* args) |
5412 { | 5412 { |
5413 ASSERT(args); | 5413 ASSERT(args); |
5414 | 5414 |
5415 // ellipse(radiusX) | 5415 // ellipse(radiusX) |
5416 // ellipse(radiusX at <position> | 5416 // ellipse(radiusX at <position> |
5417 // ellipse(radiusX radiusY) | 5417 // ellipse(radiusX radiusY) |
5418 // ellipse(radiusX radiusY at <position> | 5418 // ellipse(radiusX radiusY at <position> |
5419 // ellipse(at <position>) | 5419 // ellipse(at <position>) |
5420 // where position defines centerX and centerY using a CSS <position> data ty
pe. | 5420 // where position defines centerX and centerY using a CSS <position> data ty
pe. |
5421 RefPtrWillBeRawPtr<CSSBasicShapeEllipse> shape = CSSBasicShapeEllipse::creat
e(); | 5421 RefPtrWillBeRawPtr<CSSBasicShapeEllipse> shape = CSSBasicShapeEllipse::creat
e(); |
5422 | 5422 |
5423 for (CSSParserValue* argument = args->current(); argument; argument = args->
next()) { | 5423 for (CSSParserValue* argument = args->current(); argument; argument = args->
next()) { |
5424 // The call to parseFillPosition below should consume all of the | 5424 // The call to parseFillPosition below should consume all of the |
5425 // arguments except the first three. Thus, an index greater than two | 5425 // arguments except the first three. Thus, an index greater than two |
5426 // indicates an invalid production. | 5426 // indicates an invalid production. |
5427 if (args->currentIndex() > 2) | 5427 if (args->currentIndex() > 2) |
5428 return 0; | 5428 return nullptr; |
5429 | 5429 |
5430 if (args->currentIndex() < 2 && argument->id != CSSValueAt) { | 5430 if (args->currentIndex() < 2 && argument->id != CSSValueAt) { |
5431 if (RefPtrWillBeRawPtr<CSSPrimitiveValue> radius = parseShapeRadius(
argument)) { | 5431 if (RefPtrWillBeRawPtr<CSSPrimitiveValue> radius = parseShapeRadius(
argument)) { |
5432 if (!shape->radiusX()) | 5432 if (!shape->radiusX()) |
5433 shape->setRadiusX(radius); | 5433 shape->setRadiusX(radius); |
5434 else | 5434 else |
5435 shape->setRadiusY(radius); | 5435 shape->setRadiusY(radius); |
5436 continue; | 5436 continue; |
5437 } | 5437 } |
5438 | 5438 |
5439 return 0; | 5439 return nullptr; |
5440 } | 5440 } |
5441 | 5441 |
5442 if (argument->id != CSSValueAt) | 5442 if (argument->id != CSSValueAt) |
5443 return 0; | 5443 return nullptr; |
5444 RefPtrWillBeRawPtr<CSSValue> centerX; | 5444 RefPtrWillBeRawPtr<CSSValue> centerX; |
5445 RefPtrWillBeRawPtr<CSSValue> centerY; | 5445 RefPtrWillBeRawPtr<CSSValue> centerY; |
5446 args->next(); // set list to start of position center | 5446 args->next(); // set list to start of position center |
5447 parseFillPosition(args, centerX, centerY); | 5447 parseFillPosition(args, centerX, centerY); |
5448 if (!centerX || !centerY) | 5448 if (!centerX || !centerY) |
5449 return 0; | 5449 return nullptr; |
5450 | 5450 |
5451 ASSERT(centerX->isPrimitiveValue()); | 5451 ASSERT(centerX->isPrimitiveValue()); |
5452 ASSERT(centerY->isPrimitiveValue()); | 5452 ASSERT(centerY->isPrimitiveValue()); |
5453 shape->setCenterX(toCSSPrimitiveValue(centerX.get())); | 5453 shape->setCenterX(toCSSPrimitiveValue(centerX.get())); |
5454 shape->setCenterY(toCSSPrimitiveValue(centerY.get())); | 5454 shape->setCenterY(toCSSPrimitiveValue(centerY.get())); |
5455 } | 5455 } |
5456 | 5456 |
5457 return shape; | 5457 return shape; |
5458 } | 5458 } |
5459 | 5459 |
5460 PassRefPtrWillBeRawPtr<CSSBasicShape> CSSPropertyParser::parseDeprecatedBasicSha
peEllipse(CSSParserValueList* args) | 5460 PassRefPtrWillBeRawPtr<CSSBasicShape> CSSPropertyParser::parseDeprecatedBasicSha
peEllipse(CSSParserValueList* args) |
5461 { | 5461 { |
5462 ASSERT(args); | 5462 ASSERT(args); |
5463 | 5463 |
5464 // ellipse(centerX, centerY, radiusX, radiusY) | 5464 // ellipse(centerX, centerY, radiusX, radiusY) |
5465 if (args->size() != 7) | 5465 if (args->size() != 7) |
5466 return 0; | 5466 return nullptr; |
5467 | 5467 |
5468 RefPtrWillBeRawPtr<CSSDeprecatedBasicShapeEllipse> shape = CSSDeprecatedBasi
cShapeEllipse::create(); | 5468 RefPtrWillBeRawPtr<CSSDeprecatedBasicShapeEllipse> shape = CSSDeprecatedBasi
cShapeEllipse::create(); |
5469 unsigned argumentNumber = 0; | 5469 unsigned argumentNumber = 0; |
5470 CSSParserValue* argument = args->current(); | 5470 CSSParserValue* argument = args->current(); |
5471 while (argument) { | 5471 while (argument) { |
5472 Units unitFlags = FLength | FPercent; | 5472 Units unitFlags = FLength | FPercent; |
5473 if (argumentNumber > 1) { | 5473 if (argumentNumber > 1) { |
5474 // Arguments radiusX and radiusY cannot be negative. | 5474 // Arguments radiusX and radiusY cannot be negative. |
5475 unitFlags = unitFlags | FNonNeg; | 5475 unitFlags = unitFlags | FNonNeg; |
5476 } | 5476 } |
5477 if (!validUnit(argument, unitFlags)) | 5477 if (!validUnit(argument, unitFlags)) |
5478 return 0; | 5478 return nullptr; |
5479 | 5479 |
5480 RefPtrWillBeRawPtr<CSSPrimitiveValue> length = createPrimitiveNumericVal
ue(argument); | 5480 RefPtrWillBeRawPtr<CSSPrimitiveValue> length = createPrimitiveNumericVal
ue(argument); |
5481 ASSERT(argumentNumber < 4); | 5481 ASSERT(argumentNumber < 4); |
5482 switch (argumentNumber) { | 5482 switch (argumentNumber) { |
5483 case 0: | 5483 case 0: |
5484 shape->setCenterX(length); | 5484 shape->setCenterX(length); |
5485 break; | 5485 break; |
5486 case 1: | 5486 case 1: |
5487 shape->setCenterY(length); | 5487 shape->setCenterY(length); |
5488 break; | 5488 break; |
5489 case 2: | 5489 case 2: |
5490 shape->setRadiusX(length); | 5490 shape->setRadiusX(length); |
5491 break; | 5491 break; |
5492 case 3: | 5492 case 3: |
5493 shape->setRadiusY(length); | 5493 shape->setRadiusY(length); |
5494 break; | 5494 break; |
5495 } | 5495 } |
5496 | 5496 |
5497 argument = args->next(); | 5497 argument = args->next(); |
5498 if (argument) { | 5498 if (argument) { |
5499 if (!isComma(argument)) | 5499 if (!isComma(argument)) |
5500 return 0; | 5500 return nullptr; |
5501 argument = args->next(); | 5501 argument = args->next(); |
5502 } | 5502 } |
5503 argumentNumber++; | 5503 argumentNumber++; |
5504 } | 5504 } |
5505 | 5505 |
5506 if (argumentNumber < 4) | 5506 if (argumentNumber < 4) |
5507 return 0; | 5507 return nullptr; |
5508 return shape; | 5508 return shape; |
5509 } | 5509 } |
5510 | 5510 |
5511 PassRefPtrWillBeRawPtr<CSSBasicShape> CSSPropertyParser::parseBasicShapePolygon(
CSSParserValueList* args) | 5511 PassRefPtrWillBeRawPtr<CSSBasicShape> CSSPropertyParser::parseBasicShapePolygon(
CSSParserValueList* args) |
5512 { | 5512 { |
5513 ASSERT(args); | 5513 ASSERT(args); |
5514 | 5514 |
5515 unsigned size = args->size(); | 5515 unsigned size = args->size(); |
5516 if (!size) | 5516 if (!size) |
5517 return 0; | 5517 return nullptr; |
5518 | 5518 |
5519 RefPtrWillBeRawPtr<CSSBasicShapePolygon> shape = CSSBasicShapePolygon::creat
e(); | 5519 RefPtrWillBeRawPtr<CSSBasicShapePolygon> shape = CSSBasicShapePolygon::creat
e(); |
5520 | 5520 |
5521 CSSParserValue* argument = args->current(); | 5521 CSSParserValue* argument = args->current(); |
5522 if (argument->id == CSSValueEvenodd || argument->id == CSSValueNonzero) { | 5522 if (argument->id == CSSValueEvenodd || argument->id == CSSValueNonzero) { |
5523 shape->setWindRule(argument->id == CSSValueEvenodd ? RULE_EVENODD : RULE
_NONZERO); | 5523 shape->setWindRule(argument->id == CSSValueEvenodd ? RULE_EVENODD : RULE
_NONZERO); |
5524 | 5524 |
5525 if (!isComma(args->next())) | 5525 if (!isComma(args->next())) |
5526 return 0; | 5526 return nullptr; |
5527 | 5527 |
5528 argument = args->next(); | 5528 argument = args->next(); |
5529 size -= 2; | 5529 size -= 2; |
5530 } | 5530 } |
5531 | 5531 |
5532 // <length> <length>, ... <length> <length> -> each pair has 3 elements exce
pt the last one | 5532 // <length> <length>, ... <length> <length> -> each pair has 3 elements exce
pt the last one |
5533 if (!size || (size % 3) - 2) | 5533 if (!size || (size % 3) - 2) |
5534 return 0; | 5534 return nullptr; |
5535 | 5535 |
5536 CSSParserValue* argumentX = argument; | 5536 CSSParserValue* argumentX = argument; |
5537 while (argumentX) { | 5537 while (argumentX) { |
5538 if (!validUnit(argumentX, FLength | FPercent)) | 5538 if (!validUnit(argumentX, FLength | FPercent)) |
5539 return 0; | 5539 return nullptr; |
5540 | 5540 |
5541 CSSParserValue* argumentY = args->next(); | 5541 CSSParserValue* argumentY = args->next(); |
5542 if (!argumentY || !validUnit(argumentY, FLength | FPercent)) | 5542 if (!argumentY || !validUnit(argumentY, FLength | FPercent)) |
5543 return 0; | 5543 return nullptr; |
5544 | 5544 |
5545 RefPtrWillBeRawPtr<CSSPrimitiveValue> xLength = createPrimitiveNumericVa
lue(argumentX); | 5545 RefPtrWillBeRawPtr<CSSPrimitiveValue> xLength = createPrimitiveNumericVa
lue(argumentX); |
5546 RefPtrWillBeRawPtr<CSSPrimitiveValue> yLength = createPrimitiveNumericVa
lue(argumentY); | 5546 RefPtrWillBeRawPtr<CSSPrimitiveValue> yLength = createPrimitiveNumericVa
lue(argumentY); |
5547 | 5547 |
5548 shape->appendPoint(xLength.release(), yLength.release()); | 5548 shape->appendPoint(xLength.release(), yLength.release()); |
5549 | 5549 |
5550 CSSParserValue* commaOrNull = args->next(); | 5550 CSSParserValue* commaOrNull = args->next(); |
5551 if (!commaOrNull) | 5551 if (!commaOrNull) |
5552 argumentX = 0; | 5552 argumentX = 0; |
5553 else if (!isComma(commaOrNull)) | 5553 else if (!isComma(commaOrNull)) |
5554 return 0; | 5554 return nullptr; |
5555 else | 5555 else |
5556 argumentX = args->next(); | 5556 argumentX = args->next(); |
5557 } | 5557 } |
5558 | 5558 |
5559 return shape; | 5559 return shape; |
5560 } | 5560 } |
5561 | 5561 |
5562 static bool isBoxValue(CSSValueID valueId) | 5562 static bool isBoxValue(CSSValueID valueId) |
5563 { | 5563 { |
5564 switch (valueId) { | 5564 switch (valueId) { |
(...skipping 19 matching lines...) Expand all Loading... |
5584 if (isComma(value)) | 5584 if (isComma(value)) |
5585 return true; | 5585 return true; |
5586 } | 5586 } |
5587 | 5587 |
5588 return false; | 5588 return false; |
5589 } | 5589 } |
5590 | 5590 |
5591 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseShapeProperty(CSSProper
tyID propId) | 5591 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseShapeProperty(CSSProper
tyID propId) |
5592 { | 5592 { |
5593 if (!RuntimeEnabledFeatures::cssShapesEnabled()) | 5593 if (!RuntimeEnabledFeatures::cssShapesEnabled()) |
5594 return 0; | 5594 return nullptr; |
5595 | 5595 |
5596 CSSParserValue* value = m_valueList->current(); | 5596 CSSParserValue* value = m_valueList->current(); |
5597 CSSValueID valueId = value->id; | 5597 CSSValueID valueId = value->id; |
5598 RefPtrWillBeRawPtr<CSSPrimitiveValue> boxValue; | 5598 RefPtrWillBeRawPtr<CSSPrimitiveValue> boxValue; |
5599 RefPtrWillBeRawPtr<CSSPrimitiveValue> shapeValue; | 5599 RefPtrWillBeRawPtr<CSSPrimitiveValue> shapeValue; |
5600 | 5600 |
5601 if (valueId == CSSValueNone | 5601 if (valueId == CSSValueNone |
5602 || (valueId == CSSValueOutsideShape && propId == CSSPropertyShapeInside)
) { | 5602 || (valueId == CSSValueOutsideShape && propId == CSSPropertyShapeInside)
) { |
5603 RefPtrWillBeRawPtr<CSSPrimitiveValue> keywordValue = parseValidPrimitive
(valueId, value); | 5603 RefPtrWillBeRawPtr<CSSPrimitiveValue> keywordValue = parseValidPrimitive
(valueId, value); |
5604 m_valueList->next(); | 5604 m_valueList->next(); |
5605 return keywordValue.release(); | 5605 return keywordValue.release(); |
5606 } | 5606 } |
5607 | 5607 |
5608 RefPtrWillBeRawPtr<CSSValue> imageValue; | 5608 RefPtrWillBeRawPtr<CSSValue> imageValue; |
5609 if (valueId != CSSValueNone && parseFillImage(m_valueList.get(), imageValue)
) { | 5609 if (valueId != CSSValueNone && parseFillImage(m_valueList.get(), imageValue)
) { |
5610 m_valueList->next(); | 5610 m_valueList->next(); |
5611 return imageValue.release(); | 5611 return imageValue.release(); |
5612 } | 5612 } |
5613 | 5613 |
5614 if (value->unit == CSSParserValue::Function) { | 5614 if (value->unit == CSSParserValue::Function) { |
5615 shapeValue = parseBasicShape(); | 5615 shapeValue = parseBasicShape(); |
5616 if (!shapeValue) | 5616 if (!shapeValue) |
5617 return 0; | 5617 return nullptr; |
5618 } else if (isBoxValue(valueId)) { | 5618 } else if (isBoxValue(valueId)) { |
5619 boxValue = parseValidPrimitive(valueId, value); | 5619 boxValue = parseValidPrimitive(valueId, value); |
5620 m_valueList->next(); | 5620 m_valueList->next(); |
5621 } else { | 5621 } else { |
5622 return 0; | 5622 return nullptr; |
5623 } | 5623 } |
5624 | 5624 |
5625 ASSERT(shapeValue || boxValue); | 5625 ASSERT(shapeValue || boxValue); |
5626 value = m_valueList->current(); | 5626 value = m_valueList->current(); |
5627 | 5627 |
5628 if (value) { | 5628 if (value) { |
5629 valueId = value->id; | 5629 valueId = value->id; |
5630 if (boxValue && value->unit == CSSParserValue::Function) { | 5630 if (boxValue && value->unit == CSSParserValue::Function) { |
5631 shapeValue = parseBasicShape(); | 5631 shapeValue = parseBasicShape(); |
5632 if (!shapeValue) | 5632 if (!shapeValue) |
5633 return 0; | 5633 return nullptr; |
5634 } else if (shapeValue && isBoxValue(valueId)) { | 5634 } else if (shapeValue && isBoxValue(valueId)) { |
5635 boxValue = parseValidPrimitive(valueId, value); | 5635 boxValue = parseValidPrimitive(valueId, value); |
5636 m_valueList->next(); | 5636 m_valueList->next(); |
5637 } else { | 5637 } else { |
5638 return 0; | 5638 return nullptr; |
5639 } | 5639 } |
5640 | 5640 |
5641 ASSERT(shapeValue && boxValue); | 5641 ASSERT(shapeValue && boxValue); |
5642 shapeValue->getShapeValue()->setLayoutBox(boxValue.release()); | 5642 shapeValue->getShapeValue()->setLayoutBox(boxValue.release()); |
5643 } | 5643 } |
5644 | 5644 |
5645 if (shapeValue) | 5645 if (shapeValue) |
5646 return shapeValue.release(); | 5646 return shapeValue.release(); |
5647 return boxValue.release(); | 5647 return boxValue.release(); |
5648 } | 5648 } |
5649 | 5649 |
5650 PassRefPtrWillBeRawPtr<CSSPrimitiveValue> CSSPropertyParser::parseBasicShape() | 5650 PassRefPtrWillBeRawPtr<CSSPrimitiveValue> CSSPropertyParser::parseBasicShape() |
5651 { | 5651 { |
5652 CSSParserValue* value = m_valueList->current(); | 5652 CSSParserValue* value = m_valueList->current(); |
5653 ASSERT(value->unit == CSSParserValue::Function); | 5653 ASSERT(value->unit == CSSParserValue::Function); |
5654 CSSParserValueList* args = value->function->args.get(); | 5654 CSSParserValueList* args = value->function->args.get(); |
5655 | 5655 |
5656 if (!args) | 5656 if (!args) |
5657 return 0; | 5657 return nullptr; |
5658 | 5658 |
5659 RefPtrWillBeRawPtr<CSSBasicShape> shape; | 5659 RefPtrWillBeRawPtr<CSSBasicShape> shape; |
5660 if (equalIgnoringCase(value->function->name, "rectangle(")) | 5660 if (equalIgnoringCase(value->function->name, "rectangle(")) |
5661 shape = parseBasicShapeRectangle(args); | 5661 shape = parseBasicShapeRectangle(args); |
5662 else if (equalIgnoringCase(value->function->name, "circle(")) | 5662 else if (equalIgnoringCase(value->function->name, "circle(")) |
5663 if (isDeprecatedBasicShape(args)) | 5663 if (isDeprecatedBasicShape(args)) |
5664 shape = parseDeprecatedBasicShapeCircle(args); | 5664 shape = parseDeprecatedBasicShapeCircle(args); |
5665 else | 5665 else |
5666 shape = parseBasicShapeCircle(args); | 5666 shape = parseBasicShapeCircle(args); |
5667 else if (equalIgnoringCase(value->function->name, "ellipse(")) | 5667 else if (equalIgnoringCase(value->function->name, "ellipse(")) |
5668 if (isDeprecatedBasicShape(args)) | 5668 if (isDeprecatedBasicShape(args)) |
5669 shape = parseDeprecatedBasicShapeEllipse(args); | 5669 shape = parseDeprecatedBasicShapeEllipse(args); |
5670 else | 5670 else |
5671 shape = parseBasicShapeEllipse(args); | 5671 shape = parseBasicShapeEllipse(args); |
5672 else if (equalIgnoringCase(value->function->name, "polygon(")) | 5672 else if (equalIgnoringCase(value->function->name, "polygon(")) |
5673 shape = parseBasicShapePolygon(args); | 5673 shape = parseBasicShapePolygon(args); |
5674 else if (equalIgnoringCase(value->function->name, "inset-rectangle(")) | 5674 else if (equalIgnoringCase(value->function->name, "inset-rectangle(")) |
5675 shape = parseBasicShapeInsetRectangle(args); | 5675 shape = parseBasicShapeInsetRectangle(args); |
5676 else if (equalIgnoringCase(value->function->name, "inset(")) | 5676 else if (equalIgnoringCase(value->function->name, "inset(")) |
5677 shape = parseBasicShapeInset(args); | 5677 shape = parseBasicShapeInset(args); |
5678 | 5678 |
5679 if (!shape) | 5679 if (!shape) |
5680 return 0; | 5680 return nullptr; |
5681 | 5681 |
5682 m_valueList->next(); | 5682 m_valueList->next(); |
5683 return cssValuePool().createValue(shape.release()); | 5683 return cssValuePool().createValue(shape.release()); |
5684 } | 5684 } |
5685 | 5685 |
5686 // [ 'font-style' || 'font-variant' || 'font-weight' ]? 'font-size' [ / 'line-he
ight' ]? 'font-family' | 5686 // [ 'font-style' || 'font-variant' || 'font-weight' ]? 'font-size' [ / 'line-he
ight' ]? 'font-family' |
5687 bool CSSPropertyParser::parseFont(bool important) | 5687 bool CSSPropertyParser::parseFont(bool important) |
5688 { | 5688 { |
5689 // Let's check if there is an inherit or initial somewhere in the shorthand. | 5689 // Let's check if there is an inherit or initial somewhere in the shorthand. |
5690 for (unsigned i = 0; i < m_valueList->size(); ++i) { | 5690 for (unsigned i = 0; i < m_valueList->size(); ++i) { |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5855 inFamily = false; | 5855 inFamily = false; |
5856 } | 5856 } |
5857 else if (nextValIsFontName) | 5857 else if (nextValIsFontName) |
5858 value = nextValue; | 5858 value = nextValue; |
5859 else | 5859 else |
5860 break; | 5860 break; |
5861 } | 5861 } |
5862 familyBuilder.commit(); | 5862 familyBuilder.commit(); |
5863 | 5863 |
5864 if (!list->length()) | 5864 if (!list->length()) |
5865 list = 0; | 5865 list = nullptr; |
5866 return list.release(); | 5866 return list.release(); |
5867 } | 5867 } |
5868 | 5868 |
5869 bool CSSPropertyParser::parseLineHeight(bool important) | 5869 bool CSSPropertyParser::parseLineHeight(bool important) |
5870 { | 5870 { |
5871 CSSParserValue* value = m_valueList->current(); | 5871 CSSParserValue* value = m_valueList->current(); |
5872 CSSValueID id = value->id; | 5872 CSSValueID id = value->id; |
5873 bool validPrimitive = false; | 5873 bool validPrimitive = false; |
5874 // normal | <number> | <length> | <percentage> | inherit | 5874 // normal | <number> | <length> | <percentage> | inherit |
5875 if (id == CSSValueNormal) | 5875 if (id == CSSValueNormal) |
(...skipping 681 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6557 return false; | 6557 return false; |
6558 colorArray[3] = max(0.0, min(1.0, parsedDouble(v, ReleaseParsedCalcValue
))); | 6558 colorArray[3] = max(0.0, min(1.0, parsedDouble(v, ReleaseParsedCalcValue
))); |
6559 } | 6559 } |
6560 return true; | 6560 return true; |
6561 } | 6561 } |
6562 | 6562 |
6563 PassRefPtrWillBeRawPtr<CSSPrimitiveValue> CSSPropertyParser::parseColor(CSSParse
rValue* value) | 6563 PassRefPtrWillBeRawPtr<CSSPrimitiveValue> CSSPropertyParser::parseColor(CSSParse
rValue* value) |
6564 { | 6564 { |
6565 RGBA32 c = Color::transparent; | 6565 RGBA32 c = Color::transparent; |
6566 if (!parseColorFromValue(value ? value : m_valueList->current(), c)) | 6566 if (!parseColorFromValue(value ? value : m_valueList->current(), c)) |
6567 return 0; | 6567 return nullptr; |
6568 return cssValuePool().createColorValue(c); | 6568 return cssValuePool().createColorValue(c); |
6569 } | 6569 } |
6570 | 6570 |
6571 bool CSSPropertyParser::parseColorFromValue(CSSParserValue* value, RGBA32& c) | 6571 bool CSSPropertyParser::parseColorFromValue(CSSParserValue* value, RGBA32& c) |
6572 { | 6572 { |
6573 if (inQuirksMode() && value->unit == CSSPrimitiveValue::CSS_NUMBER | 6573 if (inQuirksMode() && value->unit == CSSPrimitiveValue::CSS_NUMBER |
6574 && value->fValue >= 0. && value->fValue < 1000000.) { | 6574 && value->fValue >= 0. && value->fValue < 1000000.) { |
6575 String str = String::format("%06d", static_cast<int>((value->fValue+.5))
); | 6575 String str = String::format("%06d", static_cast<int>((value->fValue+.5))
); |
6576 // FIXME: This should be strict parsing for SVG as well. | 6576 // FIXME: This should be strict parsing for SVG as well. |
6577 if (!fastParseColor(c, str, !inQuirksMode())) | 6577 if (!fastParseColor(c, str, !inQuirksMode())) |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6646 // Handle the ,, case gracefully by doing nothing. | 6646 // Handle the ,, case gracefully by doing nothing. |
6647 if (x || y || blur || spread || color || style) { | 6647 if (x || y || blur || spread || color || style) { |
6648 if (!values) | 6648 if (!values) |
6649 values = CSSValueList::createCommaSeparated(); | 6649 values = CSSValueList::createCommaSeparated(); |
6650 | 6650 |
6651 // Construct the current shadow value and add it to the list. | 6651 // Construct the current shadow value and add it to the list. |
6652 values->append(CSSShadowValue::create(x.release(), y.release(), blur
.release(), spread.release(), style.release(), color.release())); | 6652 values->append(CSSShadowValue::create(x.release(), y.release(), blur
.release(), spread.release(), style.release(), color.release())); |
6653 } | 6653 } |
6654 | 6654 |
6655 // Now reset for the next shadow value. | 6655 // Now reset for the next shadow value. |
6656 x = 0; | 6656 x = nullptr; |
6657 y = 0; | 6657 y = nullptr; |
6658 blur = 0; | 6658 blur = nullptr; |
6659 spread = 0; | 6659 spread = nullptr; |
6660 style = 0; | 6660 style = nullptr; |
6661 color = 0; | 6661 color = nullptr; |
6662 | 6662 |
6663 allowX = true; | 6663 allowX = true; |
6664 allowColor = true; | 6664 allowColor = true; |
6665 allowBreak = true; | 6665 allowBreak = true; |
6666 allowY = false; | 6666 allowY = false; |
6667 allowBlur = false; | 6667 allowBlur = false; |
6668 allowSpread = false; | 6668 allowSpread = false; |
6669 allowStyle = property == CSSPropertyWebkitBoxShadow || property == CSSPr
opertyBoxShadow; | 6669 allowStyle = property == CSSPropertyWebkitBoxShadow || property == CSSPr
opertyBoxShadow; |
6670 } | 6670 } |
6671 | 6671 |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6744 bool allowBreak; | 6744 bool allowBreak; |
6745 }; | 6745 }; |
6746 | 6746 |
6747 PassRefPtrWillBeRawPtr<CSSValueList> CSSPropertyParser::parseShadow(CSSParserVal
ueList* valueList, CSSPropertyID propId) | 6747 PassRefPtrWillBeRawPtr<CSSValueList> CSSPropertyParser::parseShadow(CSSParserVal
ueList* valueList, CSSPropertyID propId) |
6748 { | 6748 { |
6749 ShadowParseContext context(propId, this); | 6749 ShadowParseContext context(propId, this); |
6750 CSSParserValue* val; | 6750 CSSParserValue* val; |
6751 while ((val = valueList->current())) { | 6751 while ((val = valueList->current())) { |
6752 // Check for a comma break first. | 6752 // Check for a comma break first. |
6753 if (val->unit == CSSParserValue::Operator) { | 6753 if (val->unit == CSSParserValue::Operator) { |
6754 if (val->iValue != ',' || !context.allowBreak) | 6754 if (val->iValue != ',' || !context.allowBreak) { |
6755 // Other operators aren't legal or we aren't done with the curre
nt shadow | 6755 // Other operators aren't legal or we aren't done with the curre
nt shadow |
6756 // value. Treat as invalid. | 6756 // value. Treat as invalid. |
6757 return 0; | 6757 return nullptr; |
| 6758 } |
6758 // The value is good. Commit it. | 6759 // The value is good. Commit it. |
6759 context.commitValue(); | 6760 context.commitValue(); |
6760 } else if (validUnit(val, FLength, HTMLStandardMode)) { | 6761 } else if (validUnit(val, FLength, HTMLStandardMode)) { |
6761 // We required a length and didn't get one. Invalid. | 6762 // We required a length and didn't get one. Invalid. |
6762 if (!context.allowLength()) | 6763 if (!context.allowLength()) |
6763 return 0; | 6764 return nullptr; |
6764 | 6765 |
6765 // Blur radius must be non-negative. | 6766 // Blur radius must be non-negative. |
6766 if (context.allowBlur && !validUnit(val, FLength | FNonNeg, HTMLStan
dardMode)) | 6767 if (context.allowBlur && !validUnit(val, FLength | FNonNeg, HTMLStan
dardMode)) |
6767 return 0; | 6768 return nullptr; |
6768 | 6769 |
6769 // A length is allowed here. Construct the value and add it. | 6770 // A length is allowed here. Construct the value and add it. |
6770 context.commitLength(val); | 6771 context.commitLength(val); |
6771 } else if (val->id == CSSValueInset) { | 6772 } else if (val->id == CSSValueInset) { |
6772 if (!context.allowStyle) | 6773 if (!context.allowStyle) |
6773 return 0; | 6774 return nullptr; |
6774 | 6775 |
6775 context.commitStyle(val); | 6776 context.commitStyle(val); |
6776 } else { | 6777 } else { |
6777 // The only other type of value that's ok is a color value. | 6778 // The only other type of value that's ok is a color value. |
6778 RefPtrWillBeRawPtr<CSSPrimitiveValue> parsedColor; | 6779 RefPtrWillBeRawPtr<CSSPrimitiveValue> parsedColor; |
6779 bool isColor = ((val->id >= CSSValueAqua && val->id <= CSSValueWindo
wtext) || val->id == CSSValueMenu | 6780 bool isColor = ((val->id >= CSSValueAqua && val->id <= CSSValueWindo
wtext) || val->id == CSSValueMenu |
6780 || (val->id >= CSSValueWebkitFocusRingColor && val->
id <= CSSValueWebkitText && inQuirksMode()) | 6781 || (val->id >= CSSValueWebkitFocusRingColor && val->
id <= CSSValueWebkitText && inQuirksMode()) |
6781 || val->id == CSSValueCurrentcolor); | 6782 || val->id == CSSValueCurrentcolor); |
6782 if (isColor) { | 6783 if (isColor) { |
6783 if (!context.allowColor) | 6784 if (!context.allowColor) |
6784 return 0; | 6785 return nullptr; |
6785 parsedColor = cssValuePool().createIdentifierValue(val->id); | 6786 parsedColor = cssValuePool().createIdentifierValue(val->id); |
6786 } | 6787 } |
6787 | 6788 |
6788 if (!parsedColor) | 6789 if (!parsedColor) |
6789 // It's not built-in. Try to parse it as a color. | 6790 // It's not built-in. Try to parse it as a color. |
6790 parsedColor = parseColor(val); | 6791 parsedColor = parseColor(val); |
6791 | 6792 |
6792 if (!parsedColor || !context.allowColor) | 6793 if (!parsedColor || !context.allowColor) |
6793 return 0; // This value is not a color or length and is invalid
or | 6794 return nullptr; // This value is not a color or length and is in
valid or |
6794 // it is a color, but a color isn't allowed at this po
int. | 6795 // it is a color, but a color isn't allowed at this po
int. |
6795 | 6796 |
6796 context.commitColor(parsedColor.release()); | 6797 context.commitColor(parsedColor.release()); |
6797 } | 6798 } |
6798 | 6799 |
6799 valueList->next(); | 6800 valueList->next(); |
6800 } | 6801 } |
6801 | 6802 |
6802 if (context.allowBreak) { | 6803 if (context.allowBreak) { |
6803 context.commitValue(); | 6804 context.commitValue(); |
6804 if (context.values && context.values->length()) | 6805 if (context.values && context.values->length()) |
6805 return context.values.release(); | 6806 return context.values.release(); |
6806 } | 6807 } |
6807 | 6808 |
6808 return 0; | 6809 return nullptr; |
6809 } | 6810 } |
6810 | 6811 |
6811 bool CSSPropertyParser::parseReflect(CSSPropertyID propId, bool important) | 6812 bool CSSPropertyParser::parseReflect(CSSPropertyID propId, bool important) |
6812 { | 6813 { |
6813 // box-reflect: <direction> <offset> <mask> | 6814 // box-reflect: <direction> <offset> <mask> |
6814 | 6815 |
6815 // Direction comes first. | 6816 // Direction comes first. |
6816 CSSParserValue* val = m_valueList->current(); | 6817 CSSParserValue* val = m_valueList->current(); |
6817 RefPtrWillBeRawPtr<CSSPrimitiveValue> direction; | 6818 RefPtrWillBeRawPtr<CSSPrimitiveValue> direction; |
6818 switch (val->id) { | 6819 switch (val->id) { |
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7125 } | 7126 } |
7126 return false; | 7127 return false; |
7127 } | 7128 } |
7128 | 7129 |
7129 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseBorderImage(CSSProperty
ID propId) | 7130 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseBorderImage(CSSProperty
ID propId) |
7130 { | 7131 { |
7131 BorderImageParseContext context; | 7132 BorderImageParseContext context; |
7132 if (BorderImageParseContext::buildFromParser(*this, propId, context)) { | 7133 if (BorderImageParseContext::buildFromParser(*this, propId, context)) { |
7133 return context.commitCSSValue(); | 7134 return context.commitCSSValue(); |
7134 } | 7135 } |
7135 return 0; | 7136 return nullptr; |
7136 } | 7137 } |
7137 | 7138 |
7138 static bool isBorderImageRepeatKeyword(int id) | 7139 static bool isBorderImageRepeatKeyword(int id) |
7139 { | 7140 { |
7140 return id == CSSValueStretch || id == CSSValueRepeat || id == CSSValueSpace
|| id == CSSValueRound; | 7141 return id == CSSValueStretch || id == CSSValueRepeat || id == CSSValueSpace
|| id == CSSValueRound; |
7141 } | 7142 } |
7142 | 7143 |
7143 bool CSSPropertyParser::parseBorderImageRepeat(RefPtrWillBeRawPtr<CSSValue>& res
ult) | 7144 bool CSSPropertyParser::parseBorderImageRepeat(RefPtrWillBeRawPtr<CSSValue>& res
ult) |
7144 { | 7145 { |
7145 RefPtrWillBeRawPtr<CSSPrimitiveValue> firstValue; | 7146 RefPtrWillBeRawPtr<CSSPrimitiveValue> firstValue; |
(...skipping 595 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7741 a = args->next(); | 7742 a = args->next(); |
7742 } | 7743 } |
7743 | 7744 |
7744 gradient = result.release(); | 7745 gradient = result.release(); |
7745 return true; | 7746 return true; |
7746 } | 7747 } |
7747 | 7748 |
7748 static PassRefPtrWillBeRawPtr<CSSPrimitiveValue> valueFromSideKeyword(CSSParserV
alue* a, bool& isHorizontal) | 7749 static PassRefPtrWillBeRawPtr<CSSPrimitiveValue> valueFromSideKeyword(CSSParserV
alue* a, bool& isHorizontal) |
7749 { | 7750 { |
7750 if (a->unit != CSSPrimitiveValue::CSS_IDENT) | 7751 if (a->unit != CSSPrimitiveValue::CSS_IDENT) |
7751 return 0; | 7752 return nullptr; |
7752 | 7753 |
7753 switch (a->id) { | 7754 switch (a->id) { |
7754 case CSSValueLeft: | 7755 case CSSValueLeft: |
7755 case CSSValueRight: | 7756 case CSSValueRight: |
7756 isHorizontal = true; | 7757 isHorizontal = true; |
7757 break; | 7758 break; |
7758 case CSSValueTop: | 7759 case CSSValueTop: |
7759 case CSSValueBottom: | 7760 case CSSValueBottom: |
7760 isHorizontal = false; | 7761 isHorizontal = false; |
7761 break; | 7762 break; |
7762 default: | 7763 default: |
7763 return 0; | 7764 return nullptr; |
7764 } | 7765 } |
7765 return cssValuePool().createIdentifierValue(a->id); | 7766 return cssValuePool().createIdentifierValue(a->id); |
7766 } | 7767 } |
7767 | 7768 |
7768 PassRefPtrWillBeRawPtr<CSSPrimitiveValue> parseGradientColorOrKeyword(CSSPropert
yParser* p, CSSParserValue* value) | 7769 PassRefPtrWillBeRawPtr<CSSPrimitiveValue> parseGradientColorOrKeyword(CSSPropert
yParser* p, CSSParserValue* value) |
7769 { | 7770 { |
7770 CSSValueID id = value->id; | 7771 CSSValueID id = value->id; |
7771 if (id == CSSValueWebkitText || (id >= CSSValueAqua && id <= CSSValueWindowt
ext) || id == CSSValueMenu || id == CSSValueCurrentcolor) | 7772 if (id == CSSValueWebkitText || (id >= CSSValueAqua && id <= CSSValueWindowt
ext) || id == CSSValueMenu || id == CSSValueCurrentcolor) |
7772 return cssValuePool().createIdentifierValue(id); | 7773 return cssValuePool().createIdentifierValue(id); |
7773 | 7774 |
(...skipping 545 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8319 | 8320 |
8320 canvas = CSSCanvasValue::create(value->string); | 8321 canvas = CSSCanvasValue::create(value->string); |
8321 return true; | 8322 return true; |
8322 } | 8323 } |
8323 | 8324 |
8324 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseImageSet(CSSParserValue
List* valueList) | 8325 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseImageSet(CSSParserValue
List* valueList) |
8325 { | 8326 { |
8326 CSSParserValue* function = valueList->current(); | 8327 CSSParserValue* function = valueList->current(); |
8327 | 8328 |
8328 if (function->unit != CSSParserValue::Function) | 8329 if (function->unit != CSSParserValue::Function) |
8329 return 0; | 8330 return nullptr; |
8330 | 8331 |
8331 CSSParserValueList* functionArgs = valueList->current()->function->args.get(
); | 8332 CSSParserValueList* functionArgs = valueList->current()->function->args.get(
); |
8332 if (!functionArgs || !functionArgs->size() || !functionArgs->current()) | 8333 if (!functionArgs || !functionArgs->size() || !functionArgs->current()) |
8333 return 0; | 8334 return nullptr; |
8334 | 8335 |
8335 RefPtrWillBeRawPtr<CSSImageSetValue> imageSet = CSSImageSetValue::create(); | 8336 RefPtrWillBeRawPtr<CSSImageSetValue> imageSet = CSSImageSetValue::create(); |
8336 | 8337 |
8337 CSSParserValue* arg = functionArgs->current(); | 8338 CSSParserValue* arg = functionArgs->current(); |
8338 while (arg) { | 8339 while (arg) { |
8339 if (arg->unit != CSSPrimitiveValue::CSS_URI) | 8340 if (arg->unit != CSSPrimitiveValue::CSS_URI) |
8340 return 0; | 8341 return nullptr; |
8341 | 8342 |
8342 RefPtrWillBeRawPtr<CSSImageValue> image = CSSImageValue::create(complete
URL(arg->string)); | 8343 RefPtrWillBeRawPtr<CSSImageValue> image = CSSImageValue::create(complete
URL(arg->string)); |
8343 imageSet->append(image); | 8344 imageSet->append(image); |
8344 | 8345 |
8345 arg = functionArgs->next(); | 8346 arg = functionArgs->next(); |
8346 if (!arg || arg->unit != CSSPrimitiveValue::CSS_DIMENSION) | 8347 if (!arg || arg->unit != CSSPrimitiveValue::CSS_DIMENSION) |
8347 return 0; | 8348 return nullptr; |
8348 | 8349 |
8349 double imageScaleFactor = 0; | 8350 double imageScaleFactor = 0; |
8350 const String& string = arg->string; | 8351 const String& string = arg->string; |
8351 unsigned length = string.length(); | 8352 unsigned length = string.length(); |
8352 if (!length) | 8353 if (!length) |
8353 return 0; | 8354 return nullptr; |
8354 if (string.is8Bit()) { | 8355 if (string.is8Bit()) { |
8355 const LChar* start = string.characters8(); | 8356 const LChar* start = string.characters8(); |
8356 parseDouble(start, start + length, 'x', imageScaleFactor); | 8357 parseDouble(start, start + length, 'x', imageScaleFactor); |
8357 } else { | 8358 } else { |
8358 const UChar* start = string.characters16(); | 8359 const UChar* start = string.characters16(); |
8359 parseDouble(start, start + length, 'x', imageScaleFactor); | 8360 parseDouble(start, start + length, 'x', imageScaleFactor); |
8360 } | 8361 } |
8361 if (imageScaleFactor <= 0) | 8362 if (imageScaleFactor <= 0) |
8362 return 0; | 8363 return nullptr; |
8363 imageSet->append(cssValuePool().createValue(imageScaleFactor, CSSPrimiti
veValue::CSS_NUMBER)); | 8364 imageSet->append(cssValuePool().createValue(imageScaleFactor, CSSPrimiti
veValue::CSS_NUMBER)); |
8364 | 8365 |
8365 // If there are no more arguments, we're done. | 8366 // If there are no more arguments, we're done. |
8366 arg = functionArgs->next(); | 8367 arg = functionArgs->next(); |
8367 if (!arg) | 8368 if (!arg) |
8368 break; | 8369 break; |
8369 | 8370 |
8370 // If there are more arguments, they should be after a comma. | 8371 // If there are more arguments, they should be after a comma. |
8371 if (!isComma(arg)) | 8372 if (!isComma(arg)) |
8372 return 0; | 8373 return nullptr; |
8373 | 8374 |
8374 // Skip the comma and move on to the next argument. | 8375 // Skip the comma and move on to the next argument. |
8375 arg = functionArgs->next(); | 8376 arg = functionArgs->next(); |
8376 } | 8377 } |
8377 | 8378 |
8378 return imageSet.release(); | 8379 return imageSet.release(); |
8379 } | 8380 } |
8380 | 8381 |
8381 bool CSSPropertyParser::parseWillChange(bool important) | 8382 bool CSSPropertyParser::parseWillChange(bool important) |
8382 { | 8383 { |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8565 private: | 8566 private: |
8566 CSSTransformValue::TransformOperationType m_type; | 8567 CSSTransformValue::TransformOperationType m_type; |
8567 unsigned m_argCount; | 8568 unsigned m_argCount; |
8568 bool m_allowSingleArgument; | 8569 bool m_allowSingleArgument; |
8569 CSSPropertyParser::Units m_unit; | 8570 CSSPropertyParser::Units m_unit; |
8570 }; | 8571 }; |
8571 | 8572 |
8572 PassRefPtrWillBeRawPtr<CSSValueList> CSSPropertyParser::parseTransform() | 8573 PassRefPtrWillBeRawPtr<CSSValueList> CSSPropertyParser::parseTransform() |
8573 { | 8574 { |
8574 if (!m_valueList) | 8575 if (!m_valueList) |
8575 return 0; | 8576 return nullptr; |
8576 | 8577 |
8577 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createSpaceSeparated()
; | 8578 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createSpaceSeparated()
; |
8578 for (CSSParserValue* value = m_valueList->current(); value; value = m_valueL
ist->next()) { | 8579 for (CSSParserValue* value = m_valueList->current(); value; value = m_valueL
ist->next()) { |
8579 RefPtrWillBeRawPtr<CSSValue> parsedTransformValue = parseTransformValue(
value); | 8580 RefPtrWillBeRawPtr<CSSValue> parsedTransformValue = parseTransformValue(
value); |
8580 if (!parsedTransformValue) | 8581 if (!parsedTransformValue) |
8581 return 0; | 8582 return nullptr; |
8582 | 8583 |
8583 list->append(parsedTransformValue.release()); | 8584 list->append(parsedTransformValue.release()); |
8584 } | 8585 } |
8585 | 8586 |
8586 return list.release(); | 8587 return list.release(); |
8587 } | 8588 } |
8588 | 8589 |
8589 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseTransformValue(CSSParse
rValue *value) | 8590 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseTransformValue(CSSParse
rValue *value) |
8590 { | 8591 { |
8591 if (value->unit != CSSParserValue::Function || !value->function) | 8592 if (value->unit != CSSParserValue::Function || !value->function) |
8592 return 0; | 8593 return nullptr; |
8593 | 8594 |
8594 // Every primitive requires at least one argument. | 8595 // Every primitive requires at least one argument. |
8595 CSSParserValueList* args = value->function->args.get(); | 8596 CSSParserValueList* args = value->function->args.get(); |
8596 if (!args) | 8597 if (!args) |
8597 return 0; | 8598 return nullptr; |
8598 | 8599 |
8599 // See if the specified primitive is one we understand. | 8600 // See if the specified primitive is one we understand. |
8600 TransformOperationInfo info(value->function->name); | 8601 TransformOperationInfo info(value->function->name); |
8601 if (info.unknown()) | 8602 if (info.unknown()) |
8602 return 0; | 8603 return nullptr; |
8603 | 8604 |
8604 if (!info.hasCorrectArgCount(args->size())) | 8605 if (!info.hasCorrectArgCount(args->size())) |
8605 return 0; | 8606 return nullptr; |
8606 | 8607 |
8607 // The transform is a list of functional primitives that specify transform o
perations. | 8608 // The transform is a list of functional primitives that specify transform o
perations. |
8608 // We collect a list of CSSTransformValues, where each value specifies a sin
gle operation. | 8609 // We collect a list of CSSTransformValues, where each value specifies a sin
gle operation. |
8609 | 8610 |
8610 // Create the new CSSTransformValue for this operation and add it to our lis
t. | 8611 // Create the new CSSTransformValue for this operation and add it to our lis
t. |
8611 RefPtrWillBeRawPtr<CSSTransformValue> transformValue = CSSTransformValue::cr
eate(info.type()); | 8612 RefPtrWillBeRawPtr<CSSTransformValue> transformValue = CSSTransformValue::cr
eate(info.type()); |
8612 | 8613 |
8613 // Snag our values. | 8614 // Snag our values. |
8614 CSSParserValue* a = args->current(); | 8615 CSSParserValue* a = args->current(); |
8615 unsigned argNumber = 0; | 8616 unsigned argNumber = 0; |
8616 while (a) { | 8617 while (a) { |
8617 CSSPropertyParser::Units unit = info.unit(); | 8618 CSSPropertyParser::Units unit = info.unit(); |
8618 | 8619 |
8619 if (info.type() == CSSTransformValue::Rotate3DTransformOperation && argN
umber == 3) { | 8620 if (info.type() == CSSTransformValue::Rotate3DTransformOperation && argN
umber == 3) { |
8620 // 4th param of rotate3d() is an angle rather than a bare number, va
lidate it as such | 8621 // 4th param of rotate3d() is an angle rather than a bare number, va
lidate it as such |
8621 if (!validUnit(a, FAngle, HTMLStandardMode)) | 8622 if (!validUnit(a, FAngle, HTMLStandardMode)) |
8622 return 0; | 8623 return nullptr; |
8623 } else if (info.type() == CSSTransformValue::Translate3DTransformOperati
on && argNumber == 2) { | 8624 } else if (info.type() == CSSTransformValue::Translate3DTransformOperati
on && argNumber == 2) { |
8624 // 3rd param of translate3d() cannot be a percentage | 8625 // 3rd param of translate3d() cannot be a percentage |
8625 if (!validUnit(a, FLength, HTMLStandardMode)) | 8626 if (!validUnit(a, FLength, HTMLStandardMode)) |
8626 return 0; | 8627 return nullptr; |
8627 } else if (info.type() == CSSTransformValue::TranslateZTransformOperatio
n && !argNumber) { | 8628 } else if (info.type() == CSSTransformValue::TranslateZTransformOperatio
n && !argNumber) { |
8628 // 1st param of translateZ() cannot be a percentage | 8629 // 1st param of translateZ() cannot be a percentage |
8629 if (!validUnit(a, FLength, HTMLStandardMode)) | 8630 if (!validUnit(a, FLength, HTMLStandardMode)) |
8630 return 0; | 8631 return nullptr; |
8631 } else if (info.type() == CSSTransformValue::PerspectiveTransformOperati
on && !argNumber) { | 8632 } else if (info.type() == CSSTransformValue::PerspectiveTransformOperati
on && !argNumber) { |
8632 // 1st param of perspective() must be a non-negative number (depreca
ted) or length. | 8633 // 1st param of perspective() must be a non-negative number (depreca
ted) or length. |
8633 if (!validUnit(a, FNumber | FLength | FNonNeg, HTMLStandardMode)) | 8634 if (!validUnit(a, FNumber | FLength | FNonNeg, HTMLStandardMode)) |
8634 return 0; | 8635 return nullptr; |
8635 } else if (!validUnit(a, unit, HTMLStandardMode)) | 8636 } else if (!validUnit(a, unit, HTMLStandardMode)) { |
8636 return 0; | 8637 return nullptr; |
| 8638 } |
8637 | 8639 |
8638 // Add the value to the current transform operation. | 8640 // Add the value to the current transform operation. |
8639 transformValue->append(createPrimitiveNumericValue(a)); | 8641 transformValue->append(createPrimitiveNumericValue(a)); |
8640 | 8642 |
8641 a = args->next(); | 8643 a = args->next(); |
8642 if (!a) | 8644 if (!a) |
8643 break; | 8645 break; |
8644 if (a->unit != CSSParserValue::Operator || a->iValue != ',') | 8646 if (a->unit != CSSParserValue::Operator || a->iValue != ',') |
8645 return 0; | 8647 return nullptr; |
8646 a = args->next(); | 8648 a = args->next(); |
8647 | 8649 |
8648 argNumber++; | 8650 argNumber++; |
8649 } | 8651 } |
8650 | 8652 |
8651 return transformValue.release(); | 8653 return transformValue.release(); |
8652 } | 8654 } |
8653 | 8655 |
8654 bool CSSPropertyParser::isBlendMode(CSSValueID valueID) | 8656 bool CSSPropertyParser::isBlendMode(CSSValueID valueID) |
8655 { | 8657 { |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8697 | 8699 |
8698 switch (filterType) { | 8700 switch (filterType) { |
8699 case CSSFilterValue::GrayscaleFilterOperation: | 8701 case CSSFilterValue::GrayscaleFilterOperation: |
8700 case CSSFilterValue::SepiaFilterOperation: | 8702 case CSSFilterValue::SepiaFilterOperation: |
8701 case CSSFilterValue::SaturateFilterOperation: | 8703 case CSSFilterValue::SaturateFilterOperation: |
8702 case CSSFilterValue::InvertFilterOperation: | 8704 case CSSFilterValue::InvertFilterOperation: |
8703 case CSSFilterValue::OpacityFilterOperation: | 8705 case CSSFilterValue::OpacityFilterOperation: |
8704 case CSSFilterValue::ContrastFilterOperation: { | 8706 case CSSFilterValue::ContrastFilterOperation: { |
8705 // One optional argument, 0-1 or 0%-100%, if missing use 100%. | 8707 // One optional argument, 0-1 or 0%-100%, if missing use 100%. |
8706 if (args->size() > 1) | 8708 if (args->size() > 1) |
8707 return 0; | 8709 return nullptr; |
8708 | 8710 |
8709 if (args->size()) { | 8711 if (args->size()) { |
8710 CSSParserValue* value = args->current(); | 8712 CSSParserValue* value = args->current(); |
8711 if (!validUnit(value, FNumber | FPercent | FNonNeg, HTMLStandardMode
)) | 8713 if (!validUnit(value, FNumber | FPercent | FNonNeg, HTMLStandardMode
)) |
8712 return 0; | 8714 return nullptr; |
8713 | 8715 |
8714 double amount = value->fValue; | 8716 double amount = value->fValue; |
8715 | 8717 |
8716 // Saturate and Contrast allow values over 100%. | 8718 // Saturate and Contrast allow values over 100%. |
8717 if (filterType != CSSFilterValue::SaturateFilterOperation | 8719 if (filterType != CSSFilterValue::SaturateFilterOperation |
8718 && filterType != CSSFilterValue::ContrastFilterOperation) { | 8720 && filterType != CSSFilterValue::ContrastFilterOperation) { |
8719 double maxAllowed = value->unit == CSSPrimitiveValue::CSS_PERCEN
TAGE ? 100.0 : 1.0; | 8721 double maxAllowed = value->unit == CSSPrimitiveValue::CSS_PERCEN
TAGE ? 100.0 : 1.0; |
8720 if (amount > maxAllowed) | 8722 if (amount > maxAllowed) |
8721 return 0; | 8723 return nullptr; |
8722 } | 8724 } |
8723 | 8725 |
8724 filterValue->append(cssValuePool().createValue(amount, static_cast<C
SSPrimitiveValue::UnitTypes>(value->unit))); | 8726 filterValue->append(cssValuePool().createValue(amount, static_cast<C
SSPrimitiveValue::UnitTypes>(value->unit))); |
8725 } | 8727 } |
8726 break; | 8728 break; |
8727 } | 8729 } |
8728 case CSSFilterValue::BrightnessFilterOperation: { | 8730 case CSSFilterValue::BrightnessFilterOperation: { |
8729 // One optional argument, if missing use 100%. | 8731 // One optional argument, if missing use 100%. |
8730 if (args->size() > 1) | 8732 if (args->size() > 1) |
8731 return 0; | 8733 return nullptr; |
8732 | 8734 |
8733 if (args->size()) { | 8735 if (args->size()) { |
8734 CSSParserValue* value = args->current(); | 8736 CSSParserValue* value = args->current(); |
8735 if (!validUnit(value, FNumber | FPercent, HTMLStandardMode)) | 8737 if (!validUnit(value, FNumber | FPercent, HTMLStandardMode)) |
8736 return 0; | 8738 return nullptr; |
8737 | 8739 |
8738 filterValue->append(cssValuePool().createValue(value->fValue, static
_cast<CSSPrimitiveValue::UnitTypes>(value->unit))); | 8740 filterValue->append(cssValuePool().createValue(value->fValue, static
_cast<CSSPrimitiveValue::UnitTypes>(value->unit))); |
8739 } | 8741 } |
8740 break; | 8742 break; |
8741 } | 8743 } |
8742 case CSSFilterValue::HueRotateFilterOperation: { | 8744 case CSSFilterValue::HueRotateFilterOperation: { |
8743 // hue-rotate() takes one optional angle. | 8745 // hue-rotate() takes one optional angle. |
8744 if (args->size() > 1) | 8746 if (args->size() > 1) |
8745 return 0; | 8747 return nullptr; |
8746 | 8748 |
8747 if (args->size()) { | 8749 if (args->size()) { |
8748 CSSParserValue* argument = args->current(); | 8750 CSSParserValue* argument = args->current(); |
8749 if (!validUnit(argument, FAngle, HTMLStandardMode)) | 8751 if (!validUnit(argument, FAngle, HTMLStandardMode)) |
8750 return 0; | 8752 return nullptr; |
8751 | 8753 |
8752 filterValue->append(createPrimitiveNumericValue(argument)); | 8754 filterValue->append(createPrimitiveNumericValue(argument)); |
8753 } | 8755 } |
8754 break; | 8756 break; |
8755 } | 8757 } |
8756 case CSSFilterValue::BlurFilterOperation: { | 8758 case CSSFilterValue::BlurFilterOperation: { |
8757 // Blur takes a single length. Zero parameters are allowed. | 8759 // Blur takes a single length. Zero parameters are allowed. |
8758 if (args->size() > 1) | 8760 if (args->size() > 1) |
8759 return 0; | 8761 return nullptr; |
8760 | 8762 |
8761 if (args->size()) { | 8763 if (args->size()) { |
8762 CSSParserValue* argument = args->current(); | 8764 CSSParserValue* argument = args->current(); |
8763 if (!validUnit(argument, FLength | FNonNeg, HTMLStandardMode)) | 8765 if (!validUnit(argument, FLength | FNonNeg, HTMLStandardMode)) |
8764 return 0; | 8766 return nullptr; |
8765 | 8767 |
8766 filterValue->append(createPrimitiveNumericValue(argument)); | 8768 filterValue->append(createPrimitiveNumericValue(argument)); |
8767 } | 8769 } |
8768 break; | 8770 break; |
8769 } | 8771 } |
8770 case CSSFilterValue::DropShadowFilterOperation: { | 8772 case CSSFilterValue::DropShadowFilterOperation: { |
8771 // drop-shadow() takes a single shadow. | 8773 // drop-shadow() takes a single shadow. |
8772 RefPtrWillBeRawPtr<CSSValueList> shadowValueList = parseShadow(args, CSS
PropertyWebkitFilter); | 8774 RefPtrWillBeRawPtr<CSSValueList> shadowValueList = parseShadow(args, CSS
PropertyWebkitFilter); |
8773 if (!shadowValueList || shadowValueList->length() != 1) | 8775 if (!shadowValueList || shadowValueList->length() != 1) |
8774 return 0; | 8776 return nullptr; |
8775 | 8777 |
8776 filterValue->append((shadowValueList.release())->itemWithoutBoundsCheck(
0)); | 8778 filterValue->append((shadowValueList.release())->itemWithoutBoundsCheck(
0)); |
8777 break; | 8779 break; |
8778 } | 8780 } |
8779 default: | 8781 default: |
8780 ASSERT_NOT_REACHED(); | 8782 ASSERT_NOT_REACHED(); |
8781 } | 8783 } |
8782 return filterValue.release(); | 8784 return filterValue.release(); |
8783 } | 8785 } |
8784 | 8786 |
8785 PassRefPtrWillBeRawPtr<CSSValueList> CSSPropertyParser::parseFilter() | 8787 PassRefPtrWillBeRawPtr<CSSValueList> CSSPropertyParser::parseFilter() |
8786 { | 8788 { |
8787 if (!m_valueList) | 8789 if (!m_valueList) |
8788 return 0; | 8790 return nullptr; |
8789 | 8791 |
8790 // The filter is a list of functional primitives that specify individual ope
rations. | 8792 // The filter is a list of functional primitives that specify individual ope
rations. |
8791 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createSpaceSeparated()
; | 8793 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createSpaceSeparated()
; |
8792 for (CSSParserValue* value = m_valueList->current(); value; value = m_valueL
ist->next()) { | 8794 for (CSSParserValue* value = m_valueList->current(); value; value = m_valueL
ist->next()) { |
8793 if (value->unit != CSSPrimitiveValue::CSS_URI && (value->unit != CSSPars
erValue::Function || !value->function)) | 8795 if (value->unit != CSSPrimitiveValue::CSS_URI && (value->unit != CSSPars
erValue::Function || !value->function)) |
8794 return 0; | 8796 return nullptr; |
8795 | 8797 |
8796 CSSFilterValue::FilterOperationType filterType = CSSFilterValue::Unknown
FilterOperation; | 8798 CSSFilterValue::FilterOperationType filterType = CSSFilterValue::Unknown
FilterOperation; |
8797 | 8799 |
8798 // See if the specified primitive is one we understand. | 8800 // See if the specified primitive is one we understand. |
8799 if (value->unit == CSSPrimitiveValue::CSS_URI) { | 8801 if (value->unit == CSSPrimitiveValue::CSS_URI) { |
8800 RefPtrWillBeRawPtr<CSSFilterValue> referenceFilterValue = CSSFilterV
alue::create(CSSFilterValue::ReferenceFilterOperation); | 8802 RefPtrWillBeRawPtr<CSSFilterValue> referenceFilterValue = CSSFilterV
alue::create(CSSFilterValue::ReferenceFilterOperation); |
8801 list->append(referenceFilterValue); | 8803 list->append(referenceFilterValue); |
8802 referenceFilterValue->append(CSSSVGDocumentValue::create(value->stri
ng)); | 8804 referenceFilterValue->append(CSSSVGDocumentValue::create(value->stri
ng)); |
8803 } else { | 8805 } else { |
8804 const CSSParserString name = value->function->name; | 8806 const CSSParserString name = value->function->name; |
8805 unsigned maximumArgumentCount = 1; | 8807 unsigned maximumArgumentCount = 1; |
8806 | 8808 |
8807 filterInfoForName(name, filterType, maximumArgumentCount); | 8809 filterInfoForName(name, filterType, maximumArgumentCount); |
8808 | 8810 |
8809 if (filterType == CSSFilterValue::UnknownFilterOperation) | 8811 if (filterType == CSSFilterValue::UnknownFilterOperation) |
8810 return 0; | 8812 return nullptr; |
8811 | 8813 |
8812 CSSParserValueList* args = value->function->args.get(); | 8814 CSSParserValueList* args = value->function->args.get(); |
8813 if (!args) | 8815 if (!args) |
8814 return 0; | 8816 return nullptr; |
8815 | 8817 |
8816 RefPtrWillBeRawPtr<CSSFilterValue> filterValue = parseBuiltinFilterA
rguments(args, filterType); | 8818 RefPtrWillBeRawPtr<CSSFilterValue> filterValue = parseBuiltinFilterA
rguments(args, filterType); |
8817 if (!filterValue) | 8819 if (!filterValue) |
8818 return 0; | 8820 return nullptr; |
8819 | 8821 |
8820 list->append(filterValue); | 8822 list->append(filterValue); |
8821 } | 8823 } |
8822 } | 8824 } |
8823 | 8825 |
8824 return list.release(); | 8826 return list.release(); |
8825 } | 8827 } |
8826 | 8828 |
8827 bool CSSPropertyParser::parseTransformOrigin(CSSPropertyID propId, CSSPropertyID
& propId1, CSSPropertyID& propId2, CSSPropertyID& propId3, RefPtrWillBeRawPtr<CS
SValue>& value, RefPtrWillBeRawPtr<CSSValue>& value2, RefPtrWillBeRawPtr<CSSValu
e>& value3) | 8829 bool CSSPropertyParser::parseTransformOrigin(CSSPropertyID propId, CSSPropertyID
& propId1, CSSPropertyID& propId2, CSSPropertyID& propId3, RefPtrWillBeRawPtr<CS
SValue>& value, RefPtrWillBeRawPtr<CSSValue>& value2, RefPtrWillBeRawPtr<CSSValu
e>& value3) |
8828 { | 8830 { |
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9081 if (m_valueList->size() == 1) { | 9083 if (m_valueList->size() == 1) { |
9082 CSSParserValue* value = m_valueList->current(); | 9084 CSSParserValue* value = m_valueList->current(); |
9083 if (!value->id && validUnit(value, FLength | FPercent)) { | 9085 if (!value->id && validUnit(value, FLength | FPercent)) { |
9084 list->append(createPrimitiveNumericValue(value)); | 9086 list->append(createPrimitiveNumericValue(value)); |
9085 m_valueList->next(); | 9087 m_valueList->next(); |
9086 return list.release(); | 9088 return list.release(); |
9087 } | 9089 } |
9088 } | 9090 } |
9089 | 9091 |
9090 if (!RuntimeEnabledFeatures::css3TextEnabled()) | 9092 if (!RuntimeEnabledFeatures::css3TextEnabled()) |
9091 return 0; | 9093 return nullptr; |
9092 | 9094 |
9093 // The case where text-indent has only <length>(or <percentage>) value | 9095 // The case where text-indent has only <length>(or <percentage>) value |
9094 // is handled above if statement even though css3TextEnabled() returns true. | 9096 // is handled above if statement even though css3TextEnabled() returns true. |
9095 | 9097 |
9096 // [ [ <length> | <percentage> ] && each-line ] | inherit | 9098 // [ [ <length> | <percentage> ] && each-line ] | inherit |
9097 if (m_valueList->size() != 2) | 9099 if (m_valueList->size() != 2) |
9098 return 0; | 9100 return nullptr; |
9099 | 9101 |
9100 CSSParserValue* firstValue = m_valueList->current(); | 9102 CSSParserValue* firstValue = m_valueList->current(); |
9101 CSSParserValue* secondValue = m_valueList->next(); | 9103 CSSParserValue* secondValue = m_valueList->next(); |
9102 CSSParserValue* lengthOrPercentageValue = 0; | 9104 CSSParserValue* lengthOrPercentageValue = 0; |
9103 | 9105 |
9104 // [ <length> | <percentage> ] each-line | 9106 // [ <length> | <percentage> ] each-line |
9105 if (validUnit(firstValue, FLength | FPercent) && secondValue->id == CSSValue
EachLine) | 9107 if (validUnit(firstValue, FLength | FPercent) && secondValue->id == CSSValue
EachLine) |
9106 lengthOrPercentageValue = firstValue; | 9108 lengthOrPercentageValue = firstValue; |
9107 // each-line [ <length> | <percentage> ] | 9109 // each-line [ <length> | <percentage> ] |
9108 else if (firstValue->id == CSSValueEachLine && validUnit(secondValue, FLengt
h | FPercent)) | 9110 else if (firstValue->id == CSSValueEachLine && validUnit(secondValue, FLengt
h | FPercent)) |
9109 lengthOrPercentageValue = secondValue; | 9111 lengthOrPercentageValue = secondValue; |
9110 | 9112 |
9111 if (lengthOrPercentageValue) { | 9113 if (lengthOrPercentageValue) { |
9112 list->append(createPrimitiveNumericValue(lengthOrPercentageValue)); | 9114 list->append(createPrimitiveNumericValue(lengthOrPercentageValue)); |
9113 list->append(cssValuePool().createIdentifierValue(CSSValueEachLine)); | 9115 list->append(cssValuePool().createIdentifierValue(CSSValueEachLine)); |
9114 m_valueList->next(); | 9116 m_valueList->next(); |
9115 return list.release(); | 9117 return list.release(); |
9116 } | 9118 } |
9117 | 9119 |
9118 return 0; | 9120 return nullptr; |
9119 } | 9121 } |
9120 | 9122 |
9121 bool CSSPropertyParser::parseLineBoxContain(bool important) | 9123 bool CSSPropertyParser::parseLineBoxContain(bool important) |
9122 { | 9124 { |
9123 LineBoxContain lineBoxContain = LineBoxContainNone; | 9125 LineBoxContain lineBoxContain = LineBoxContainNone; |
9124 | 9126 |
9125 for (CSSParserValue* value = m_valueList->current(); value; value = m_valueL
ist->next()) { | 9127 for (CSSParserValue* value = m_valueList->current(); value; value = m_valueL
ist->next()) { |
9126 if (value->id == CSSValueBlock) { | 9128 if (value->id == CSSValueBlock) { |
9127 if (lineBoxContain & LineBoxContainBlock) | 9129 if (lineBoxContain & LineBoxContainBlock) |
9128 return false; | 9130 return false; |
(...skipping 1034 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10163 { | 10165 { |
10164 // The tokenizer checks for the construct of an+b. | 10166 // The tokenizer checks for the construct of an+b. |
10165 // However, since the {ident} rule precedes the {nth} rule, some of those | 10167 // However, since the {ident} rule precedes the {nth} rule, some of those |
10166 // tokens are identified as string literal. Furthermore we need to accept | 10168 // tokens are identified as string literal. Furthermore we need to accept |
10167 // "odd" and "even" which does not match to an+b. | 10169 // "odd" and "even" which does not match to an+b. |
10168 return equalIgnoringCase(token, "odd") || equalIgnoringCase(token, "even") | 10170 return equalIgnoringCase(token, "odd") || equalIgnoringCase(token, "even") |
10169 || equalIgnoringCase(token, "n") || equalIgnoringCase(token, "-n"); | 10171 || equalIgnoringCase(token, "n") || equalIgnoringCase(token, "-n"); |
10170 } | 10172 } |
10171 | 10173 |
10172 } | 10174 } |
OLD | NEW |