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 421 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
432 #endif // CSS3_TEXT | 432 #endif // CSS3_TEXT |
433 case CSSPropertyWebkitTextEmphasisColor: | 433 case CSSPropertyWebkitTextEmphasisColor: |
434 case CSSPropertyWebkitTextFillColor: | 434 case CSSPropertyWebkitTextFillColor: |
435 case CSSPropertyWebkitTextStrokeColor: | 435 case CSSPropertyWebkitTextStrokeColor: |
436 return true; | 436 return true; |
437 default: | 437 default: |
438 return false; | 438 return false; |
439 } | 439 } |
440 } | 440 } |
441 | 441 |
442 static bool parseColorValue(StylePropertySet* declaration, CSSPropertyID propert
yId, const String& string, bool important, CSSParserMode cssParserMode) | 442 static bool parseColorValue(MutableStylePropertySet* declaration, CSSPropertyID
propertyId, const String& string, bool important, CSSParserMode cssParserMode) |
443 { | 443 { |
444 ASSERT(!string.isEmpty()); | 444 ASSERT(!string.isEmpty()); |
445 bool strict = isStrictParserMode(cssParserMode); | 445 bool strict = isStrictParserMode(cssParserMode); |
446 if (!isColorPropertyID(propertyId)) | 446 if (!isColorPropertyID(propertyId)) |
447 return false; | 447 return false; |
448 CSSParserString cssString; | 448 CSSParserString cssString; |
449 cssString.init(string); | 449 cssString.init(string); |
450 int valueID = cssValueKeywordID(cssString); | 450 int valueID = cssValueKeywordID(cssString); |
451 bool validPrimitive = false; | 451 bool validPrimitive = false; |
452 if (valueID == CSSValueWebkitText) | 452 if (valueID == CSSValueWebkitText) |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
528 } | 528 } |
529 | 529 |
530 // We rely on charactersToDouble for validation as well. The function | 530 // We rely on charactersToDouble for validation as well. The function |
531 // will set "ok" to "false" if the entire passed-in character range does | 531 // will set "ok" to "false" if the entire passed-in character range does |
532 // not represent a double. | 532 // not represent a double. |
533 bool ok; | 533 bool ok; |
534 number = charactersToDouble(characters, length, &ok); | 534 number = charactersToDouble(characters, length, &ok); |
535 return ok; | 535 return ok; |
536 } | 536 } |
537 | 537 |
538 static bool parseSimpleLengthValue(StylePropertySet* declaration, CSSPropertyID
propertyId, const String& string, bool important, CSSParserMode cssParserMode) | 538 static bool parseSimpleLengthValue(MutableStylePropertySet* declaration, CSSProp
ertyID propertyId, const String& string, bool important, CSSParserMode cssParser
Mode) |
539 { | 539 { |
540 ASSERT(!string.isEmpty()); | 540 ASSERT(!string.isEmpty()); |
541 bool acceptsNegativeNumbers; | 541 bool acceptsNegativeNumbers; |
542 if (!isSimpleLengthPropertyID(propertyId, acceptsNegativeNumbers)) | 542 if (!isSimpleLengthPropertyID(propertyId, acceptsNegativeNumbers)) |
543 return false; | 543 return false; |
544 | 544 |
545 unsigned length = string.length(); | 545 unsigned length = string.length(); |
546 double number; | 546 double number; |
547 CSSPrimitiveValue::UnitTypes unit = CSSPrimitiveValue::CSS_NUMBER; | 547 CSSPrimitiveValue::UnitTypes unit = CSSPrimitiveValue::CSS_NUMBER; |
548 | 548 |
(...skipping 496 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1045 case CSSPropertyWebkitWritingMode: | 1045 case CSSPropertyWebkitWritingMode: |
1046 case CSSPropertyWhiteSpace: | 1046 case CSSPropertyWhiteSpace: |
1047 case CSSPropertyWordBreak: | 1047 case CSSPropertyWordBreak: |
1048 case CSSPropertyWordWrap: | 1048 case CSSPropertyWordWrap: |
1049 return true; | 1049 return true; |
1050 default: | 1050 default: |
1051 return false; | 1051 return false; |
1052 } | 1052 } |
1053 } | 1053 } |
1054 | 1054 |
1055 static bool parseKeywordValue(StylePropertySet* declaration, CSSPropertyID prope
rtyId, const String& string, bool important, const CSSParserContext& parserConte
xt) | 1055 static bool parseKeywordValue(MutableStylePropertySet* declaration, CSSPropertyI
D propertyId, const String& string, bool important, const CSSParserContext& pars
erContext) |
1056 { | 1056 { |
1057 ASSERT(!string.isEmpty()); | 1057 ASSERT(!string.isEmpty()); |
1058 | 1058 |
1059 if (!isKeywordPropertyID(propertyId)) { | 1059 if (!isKeywordPropertyID(propertyId)) { |
1060 // All properties accept the values of "initial" and "inherit". | 1060 // All properties accept the values of "initial" and "inherit". |
1061 String lowerCaseString = string.lower(); | 1061 String lowerCaseString = string.lower(); |
1062 if (lowerCaseString != "initial" && lowerCaseString != "inherit") | 1062 if (lowerCaseString != "initial" && lowerCaseString != "inherit") |
1063 return false; | 1063 return false; |
1064 | 1064 |
1065 // Parse initial/inherit shorthands using the CSSParser. | 1065 // Parse initial/inherit shorthands using the CSSParser. |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1102 return false; | 1102 return false; |
1103 if (unit != CSSPrimitiveValue::CSS_PX && (number || unit != CSSPrimitive
Value::CSS_NUMBER)) | 1103 if (unit != CSSPrimitiveValue::CSS_PX && (number || unit != CSSPrimitive
Value::CSS_NUMBER)) |
1104 return false; | 1104 return false; |
1105 transformValue->append(cssValuePool().createValue(number, unit)); | 1105 transformValue->append(cssValuePool().createValue(number, unit)); |
1106 start = end + 1; | 1106 start = end + 1; |
1107 --expectedCount; | 1107 --expectedCount; |
1108 } | 1108 } |
1109 return true; | 1109 return true; |
1110 } | 1110 } |
1111 | 1111 |
1112 static bool parseTranslateTransformValue(StylePropertySet* properties, CSSProper
tyID propertyID, const String& string, bool important) | 1112 static bool parseTranslateTransformValue(MutableStylePropertySet* properties, CS
SPropertyID propertyID, const String& string, bool important) |
1113 { | 1113 { |
1114 if (propertyID != CSSPropertyWebkitTransform) | 1114 if (propertyID != CSSPropertyWebkitTransform) |
1115 return false; | 1115 return false; |
1116 static const unsigned shortestValidTransformStringLength = 12; | 1116 static const unsigned shortestValidTransformStringLength = 12; |
1117 static const unsigned likelyMultipartTransformStringLengthCutoff = 32; | 1117 static const unsigned likelyMultipartTransformStringLengthCutoff = 32; |
1118 if (string.length() < shortestValidTransformStringLength || string.length()
> likelyMultipartTransformStringLengthCutoff) | 1118 if (string.length() < shortestValidTransformStringLength || string.length()
> likelyMultipartTransformStringLengthCutoff) |
1119 return false; | 1119 return false; |
1120 if (!string.startsWith("translate", false)) | 1120 if (!string.startsWith("translate", false)) |
1121 return false; | 1121 return false; |
1122 UChar c9 = toASCIILower(string[9]); | 1122 UChar c9 = toASCIILower(string[9]); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1159 PassRefPtr<CSSValueList> CSSParser::parseFontFaceValue(const AtomicString& strin
g) | 1159 PassRefPtr<CSSValueList> CSSParser::parseFontFaceValue(const AtomicString& strin
g) |
1160 { | 1160 { |
1161 if (string.isEmpty()) | 1161 if (string.isEmpty()) |
1162 return 0; | 1162 return 0; |
1163 RefPtr<MutableStylePropertySet> dummyStyle = MutableStylePropertySet::create
(); | 1163 RefPtr<MutableStylePropertySet> dummyStyle = MutableStylePropertySet::create
(); |
1164 if (!parseValue(dummyStyle.get(), CSSPropertyFontFamily, string, false, CSSQ
uirksMode, 0)) | 1164 if (!parseValue(dummyStyle.get(), CSSPropertyFontFamily, string, false, CSSQ
uirksMode, 0)) |
1165 return 0; | 1165 return 0; |
1166 return static_pointer_cast<CSSValueList>(dummyStyle->getPropertyCSSValue(CSS
PropertyFontFamily)); | 1166 return static_pointer_cast<CSSValueList>(dummyStyle->getPropertyCSSValue(CSS
PropertyFontFamily)); |
1167 } | 1167 } |
1168 | 1168 |
1169 bool CSSParser::parseValue(StylePropertySet* declaration, CSSPropertyID property
ID, const String& string, bool important, Document* document) | 1169 bool CSSParser::parseValue(MutableStylePropertySet* declaration, CSSPropertyID p
ropertyID, const String& string, bool important, Document* document) |
1170 { | 1170 { |
1171 ASSERT(!string.isEmpty()); | 1171 ASSERT(!string.isEmpty()); |
1172 | 1172 |
1173 CSSParserContext context(document); | 1173 CSSParserContext context(document); |
1174 | 1174 |
1175 if (parseSimpleLengthValue(declaration, propertyID, string, important, conte
xt.mode)) | 1175 if (parseSimpleLengthValue(declaration, propertyID, string, important, conte
xt.mode)) |
1176 return true; | 1176 return true; |
1177 if (parseColorValue(declaration, propertyID, string, important, context.mode
)) | 1177 if (parseColorValue(declaration, propertyID, string, important, context.mode
)) |
1178 return true; | 1178 return true; |
1179 if (parseKeywordValue(declaration, propertyID, string, important, context)) | 1179 if (parseKeywordValue(declaration, propertyID, string, important, context)) |
1180 return true; | 1180 return true; |
1181 | 1181 |
1182 CSSParser parser(context, UseCounter::getFrom(document)); | 1182 CSSParser parser(context, UseCounter::getFrom(document)); |
1183 return parser.parseValue(declaration, propertyID, string, important, static_
cast<StyleSheetContents*>(0)); | 1183 return parser.parseValue(declaration, propertyID, string, important, static_
cast<StyleSheetContents*>(0)); |
1184 } | 1184 } |
1185 | 1185 |
1186 bool CSSParser::parseValue(StylePropertySet* declaration, CSSPropertyID property
ID, const String& string, bool important, CSSParserMode cssParserMode, StyleShee
tContents* contextStyleSheet) | 1186 bool CSSParser::parseValue(MutableStylePropertySet* declaration, CSSPropertyID p
ropertyID, const String& string, bool important, CSSParserMode cssParserMode, St
yleSheetContents* contextStyleSheet) |
1187 { | 1187 { |
1188 ASSERT(!string.isEmpty()); | 1188 ASSERT(!string.isEmpty()); |
1189 if (parseSimpleLengthValue(declaration, propertyID, string, important, cssPa
rserMode)) | 1189 if (parseSimpleLengthValue(declaration, propertyID, string, important, cssPa
rserMode)) |
1190 return true; | 1190 return true; |
1191 if (parseColorValue(declaration, propertyID, string, important, cssParserMod
e)) | 1191 if (parseColorValue(declaration, propertyID, string, important, cssParserMod
e)) |
1192 return true; | 1192 return true; |
1193 | 1193 |
1194 CSSParserContext context(cssParserMode); | 1194 CSSParserContext context(cssParserMode); |
1195 if (contextStyleSheet) { | 1195 if (contextStyleSheet) { |
1196 context = contextStyleSheet->parserContext(); | 1196 context = contextStyleSheet->parserContext(); |
1197 context.mode = cssParserMode; | 1197 context.mode = cssParserMode; |
1198 } | 1198 } |
1199 | 1199 |
1200 if (parseKeywordValue(declaration, propertyID, string, important, context)) | 1200 if (parseKeywordValue(declaration, propertyID, string, important, context)) |
1201 return true; | 1201 return true; |
1202 if (parseTranslateTransformValue(declaration, propertyID, string, important)
) | 1202 if (parseTranslateTransformValue(declaration, propertyID, string, important)
) |
1203 return true; | 1203 return true; |
1204 | 1204 |
1205 CSSParser parser(context); | 1205 CSSParser parser(context); |
1206 return parser.parseValue(declaration, propertyID, string, important, context
StyleSheet); | 1206 return parser.parseValue(declaration, propertyID, string, important, context
StyleSheet); |
1207 } | 1207 } |
1208 | 1208 |
1209 bool CSSParser::parseValue(StylePropertySet* declaration, CSSPropertyID property
ID, const String& string, bool important, StyleSheetContents* contextStyleSheet) | 1209 bool CSSParser::parseValue(MutableStylePropertySet* declaration, CSSPropertyID p
ropertyID, const String& string, bool important, StyleSheetContents* contextStyl
eSheet) |
1210 { | 1210 { |
1211 // FIXME: Check RuntimeCSSEnabled::isPropertyEnabled or isValueEnabledForPro
perty. | 1211 // FIXME: Check RuntimeCSSEnabled::isPropertyEnabled or isValueEnabledForPro
perty. |
1212 | 1212 |
1213 if (m_useCounter) | 1213 if (m_useCounter) |
1214 m_useCounter->count(propertyID); | 1214 m_useCounter->count(propertyID); |
1215 | 1215 |
1216 setStyleSheet(contextStyleSheet); | 1216 setStyleSheet(contextStyleSheet); |
1217 | 1217 |
1218 setupParser("@-internal-value{", string, "} "); | 1218 setupParser("@-internal-value{", string, "} "); |
1219 | 1219 |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1316 | 1316 |
1317 if (m_hasFontFaceOnlyValues) | 1317 if (m_hasFontFaceOnlyValues) |
1318 deleteFontFaceOnlyValues(); | 1318 deleteFontFaceOnlyValues(); |
1319 | 1319 |
1320 RefPtr<ImmutableStylePropertySet> style = createStylePropertySet(); | 1320 RefPtr<ImmutableStylePropertySet> style = createStylePropertySet(); |
1321 clearProperties(); | 1321 clearProperties(); |
1322 return style.release(); | 1322 return style.release(); |
1323 } | 1323 } |
1324 | 1324 |
1325 | 1325 |
1326 bool CSSParser::parseDeclaration(StylePropertySet* declaration, const String& st
ring, SourceDataHandler* sourceDataHandler, StyleSheetContents* contextStyleShee
t) | 1326 bool CSSParser::parseDeclaration(MutableStylePropertySet* declaration, const Str
ing& string, SourceDataHandler* sourceDataHandler, StyleSheetContents* contextSt
yleSheet) |
1327 { | 1327 { |
1328 setStyleSheet(contextStyleSheet); | 1328 setStyleSheet(contextStyleSheet); |
1329 | 1329 |
1330 m_sourceDataHandler = sourceDataHandler; | 1330 m_sourceDataHandler = sourceDataHandler; |
1331 | 1331 |
1332 setupParser("@-internal-decls{", string, "} "); | 1332 setupParser("@-internal-decls{", string, "} "); |
1333 if (m_sourceDataHandler) { | 1333 if (m_sourceDataHandler) { |
1334 m_sourceDataHandler->startRuleHeader(CSSRuleSourceData::STYLE_RULE, 0); | 1334 m_sourceDataHandler->startRuleHeader(CSSRuleSourceData::STYLE_RULE, 0); |
1335 m_sourceDataHandler->endRuleHeader(1); | 1335 m_sourceDataHandler->endRuleHeader(1); |
1336 m_sourceDataHandler->startRuleBody(0); | 1336 m_sourceDataHandler->startRuleBody(0); |
(...skipping 10400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11737 { | 11737 { |
11738 // The tokenizer checks for the construct of an+b. | 11738 // The tokenizer checks for the construct of an+b. |
11739 // However, since the {ident} rule precedes the {nth} rule, some of those | 11739 // However, since the {ident} rule precedes the {nth} rule, some of those |
11740 // tokens are identified as string literal. Furthermore we need to accept | 11740 // tokens are identified as string literal. Furthermore we need to accept |
11741 // "odd" and "even" which does not match to an+b. | 11741 // "odd" and "even" which does not match to an+b. |
11742 return equalIgnoringCase(token, "odd") || equalIgnoringCase(token, "even") | 11742 return equalIgnoringCase(token, "odd") || equalIgnoringCase(token, "even") |
11743 || equalIgnoringCase(token, "n") || equalIgnoringCase(token, "-n"); | 11743 || equalIgnoringCase(token, "n") || equalIgnoringCase(token, "-n"); |
11744 } | 11744 } |
11745 | 11745 |
11746 } | 11746 } |
OLD | NEW |