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 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
372 m_sourceDataHandler = 0; | 372 m_sourceDataHandler = 0; |
373 m_rule = 0; | 373 m_rule = 0; |
374 m_ignoreErrors = false; | 374 m_ignoreErrors = false; |
375 m_logErrors = false; | 375 m_logErrors = false; |
376 } | 376 } |
377 | 377 |
378 PassRefPtr<StyleRuleBase> CSSParser::parseRule(StyleSheetContents* sheet, const
String& string) | 378 PassRefPtr<StyleRuleBase> CSSParser::parseRule(StyleSheetContents* sheet, const
String& string) |
379 { | 379 { |
380 setStyleSheet(sheet); | 380 setStyleSheet(sheet); |
381 m_allowNamespaceDeclarations = false; | 381 m_allowNamespaceDeclarations = false; |
382 setupParser("@-internal-rule{", string, "} "); | 382 setupParser("@-internal-rule ", string, ""); |
383 cssyyparse(this); | 383 cssyyparse(this); |
384 return m_rule.release(); | 384 return m_rule.release(); |
385 } | 385 } |
386 | 386 |
387 PassRefPtr<StyleKeyframe> CSSParser::parseKeyframeRule(StyleSheetContents* sheet
, const String& string) | 387 PassRefPtr<StyleKeyframe> CSSParser::parseKeyframeRule(StyleSheetContents* sheet
, const String& string) |
388 { | 388 { |
389 setStyleSheet(sheet); | 389 setStyleSheet(sheet); |
390 setupParser("@-webkit-keyframe-rule{ ", string, "} "); | 390 setupParser("@-internal-keyframe-rule ", string, ""); |
391 cssyyparse(this); | 391 cssyyparse(this); |
392 return m_keyframe.release(); | 392 return m_keyframe.release(); |
393 } | 393 } |
394 | 394 |
395 bool CSSParser::parseSupportsCondition(const String& string) | 395 bool CSSParser::parseSupportsCondition(const String& string) |
396 { | 396 { |
397 m_supportsCondition = false; | 397 m_supportsCondition = false; |
398 setupParser("@-webkit-supports-condition{ ", string, "} "); | 398 setupParser("@-internal-supports-condition ", string, ""); |
399 cssyyparse(this); | 399 cssyyparse(this); |
400 return m_supportsCondition; | 400 return m_supportsCondition; |
401 } | 401 } |
402 | 402 |
403 static inline bool isColorPropertyID(CSSPropertyID propertyId) | 403 static inline bool isColorPropertyID(CSSPropertyID propertyId) |
404 { | 404 { |
405 switch (propertyId) { | 405 switch (propertyId) { |
406 case CSSPropertyColor: | 406 case CSSPropertyColor: |
407 case CSSPropertyBackgroundColor: | 407 case CSSPropertyBackgroundColor: |
408 case CSSPropertyBorderBottomColor: | 408 case CSSPropertyBorderBottomColor: |
(...skipping 780 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1189 | 1189 |
1190 bool CSSParser::parseValue(MutableStylePropertySet* declaration, CSSPropertyID p
ropertyID, const String& string, bool important, StyleSheetContents* contextStyl
eSheet) | 1190 bool CSSParser::parseValue(MutableStylePropertySet* declaration, CSSPropertyID p
ropertyID, const String& string, bool important, StyleSheetContents* contextStyl
eSheet) |
1191 { | 1191 { |
1192 // FIXME: Check RuntimeCSSEnabled::isPropertyEnabled or isValueEnabledForPro
perty. | 1192 // FIXME: Check RuntimeCSSEnabled::isPropertyEnabled or isValueEnabledForPro
perty. |
1193 | 1193 |
1194 if (m_useCounter) | 1194 if (m_useCounter) |
1195 m_useCounter->count(propertyID); | 1195 m_useCounter->count(propertyID); |
1196 | 1196 |
1197 setStyleSheet(contextStyleSheet); | 1197 setStyleSheet(contextStyleSheet); |
1198 | 1198 |
1199 setupParser("@-internal-value{", string, "} "); | 1199 setupParser("@-internal-value ", string, ""); |
1200 | 1200 |
1201 m_id = propertyID; | 1201 m_id = propertyID; |
1202 m_important = important; | 1202 m_important = important; |
1203 | 1203 |
1204 cssyyparse(this); | 1204 cssyyparse(this); |
1205 | 1205 |
1206 m_rule = 0; | 1206 m_rule = 0; |
1207 m_id = CSSPropertyInvalid; | 1207 m_id = CSSPropertyInvalid; |
1208 | 1208 |
1209 bool ok = false; | 1209 bool ok = false; |
(...skipping 29 matching lines...) Expand all Loading... |
1239 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); | 1239 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); |
1240 if (!primitiveValue->isRGBColor()) | 1240 if (!primitiveValue->isRGBColor()) |
1241 return false; | 1241 return false; |
1242 | 1242 |
1243 color = primitiveValue->getRGBA32Value(); | 1243 color = primitiveValue->getRGBA32Value(); |
1244 return true; | 1244 return true; |
1245 } | 1245 } |
1246 | 1246 |
1247 bool CSSParser::parseColor(const String& string) | 1247 bool CSSParser::parseColor(const String& string) |
1248 { | 1248 { |
1249 setupParser("@-internal-decls{color:", string, "} "); | 1249 setupParser("@-internal-decls color:", string, ""); |
1250 cssyyparse(this); | 1250 cssyyparse(this); |
1251 m_rule = 0; | 1251 m_rule = 0; |
1252 | 1252 |
1253 return !m_parsedProperties.isEmpty() && m_parsedProperties.first().id() == C
SSPropertyColor; | 1253 return !m_parsedProperties.isEmpty() && m_parsedProperties.first().id() == C
SSPropertyColor; |
1254 } | 1254 } |
1255 | 1255 |
1256 bool CSSParser::parseSystemColor(RGBA32& color, const String& string, Document*
document) | 1256 bool CSSParser::parseSystemColor(RGBA32& color, const String& string, Document*
document) |
1257 { | 1257 { |
1258 if (!document || !document->page()) | 1258 if (!document || !document->page()) |
1259 return false; | 1259 return false; |
1260 | 1260 |
1261 CSSParserString cssColor; | 1261 CSSParserString cssColor; |
1262 cssColor.init(string); | 1262 cssColor.init(string); |
1263 CSSValueID id = cssValueKeywordID(cssColor); | 1263 CSSValueID id = cssValueKeywordID(cssColor); |
1264 if (id <= 0) | 1264 if (id <= 0) |
1265 return false; | 1265 return false; |
1266 | 1266 |
1267 color = document->page()->theme()->systemColor(id).rgb(); | 1267 color = document->page()->theme()->systemColor(id).rgb(); |
1268 return true; | 1268 return true; |
1269 } | 1269 } |
1270 | 1270 |
1271 void CSSParser::parseSelector(const String& string, CSSSelectorList& selectorLis
t) | 1271 void CSSParser::parseSelector(const String& string, CSSSelectorList& selectorLis
t) |
1272 { | 1272 { |
1273 m_selectorListForParseSelector = &selectorList; | 1273 m_selectorListForParseSelector = &selectorList; |
1274 | 1274 |
1275 setupParser("@-internal-selector{", string, "}"); | 1275 setupParser("@-internal-selector ", string, ""); |
1276 | 1276 |
1277 cssyyparse(this); | 1277 cssyyparse(this); |
1278 | 1278 |
1279 m_selectorListForParseSelector = 0; | 1279 m_selectorListForParseSelector = 0; |
1280 } | 1280 } |
1281 | 1281 |
1282 PassRefPtr<ImmutableStylePropertySet> CSSParser::parseInlineStyleDeclaration(con
st String& string, Element* element) | 1282 PassRefPtr<ImmutableStylePropertySet> CSSParser::parseInlineStyleDeclaration(con
st String& string, Element* element) |
1283 { | 1283 { |
1284 Document* document = element->document(); | 1284 Document* document = element->document(); |
1285 CSSParserContext context = document->elementSheet()->contents()->parserConte
xt(); | 1285 CSSParserContext context = document->elementSheet()->contents()->parserConte
xt(); |
1286 context.mode = strictToCSSParserMode(element->isHTMLElement() && !document->
inQuirksMode()); | 1286 context.mode = strictToCSSParserMode(element->isHTMLElement() && !document->
inQuirksMode()); |
1287 return CSSParser(context, UseCounter::getFrom(document)).parseDeclaration(st
ring, document->elementSheet()->contents()); | 1287 return CSSParser(context, UseCounter::getFrom(document)).parseDeclaration(st
ring, document->elementSheet()->contents()); |
1288 } | 1288 } |
1289 | 1289 |
1290 PassRefPtr<ImmutableStylePropertySet> CSSParser::parseDeclaration(const String&
string, StyleSheetContents* contextStyleSheet) | 1290 PassRefPtr<ImmutableStylePropertySet> CSSParser::parseDeclaration(const String&
string, StyleSheetContents* contextStyleSheet) |
1291 { | 1291 { |
1292 setStyleSheet(contextStyleSheet); | 1292 setStyleSheet(contextStyleSheet); |
1293 | 1293 |
1294 setupParser("@-internal-decls{", string, "} "); | 1294 setupParser("@-internal-decls ", string, ""); |
1295 cssyyparse(this); | 1295 cssyyparse(this); |
1296 m_rule = 0; | 1296 m_rule = 0; |
1297 | 1297 |
1298 if (m_hasFontFaceOnlyValues) | 1298 if (m_hasFontFaceOnlyValues) |
1299 deleteFontFaceOnlyValues(); | 1299 deleteFontFaceOnlyValues(); |
1300 | 1300 |
1301 RefPtr<ImmutableStylePropertySet> style = createStylePropertySet(); | 1301 RefPtr<ImmutableStylePropertySet> style = createStylePropertySet(); |
1302 clearProperties(); | 1302 clearProperties(); |
1303 return style.release(); | 1303 return style.release(); |
1304 } | 1304 } |
1305 | 1305 |
1306 | 1306 |
1307 bool CSSParser::parseDeclaration(MutableStylePropertySet* declaration, const Str
ing& string, SourceDataHandler* sourceDataHandler, StyleSheetContents* contextSt
yleSheet) | 1307 bool CSSParser::parseDeclaration(MutableStylePropertySet* declaration, const Str
ing& string, SourceDataHandler* sourceDataHandler, StyleSheetContents* contextSt
yleSheet) |
1308 { | 1308 { |
1309 setStyleSheet(contextStyleSheet); | 1309 setStyleSheet(contextStyleSheet); |
1310 | 1310 |
1311 m_sourceDataHandler = sourceDataHandler; | 1311 m_sourceDataHandler = sourceDataHandler; |
1312 | 1312 |
1313 setupParser("@-internal-decls{", string, "} "); | 1313 setupParser("@-internal-decls ", string, ""); |
1314 if (m_sourceDataHandler) { | 1314 if (m_sourceDataHandler) { |
1315 m_sourceDataHandler->startRuleHeader(CSSRuleSourceData::STYLE_RULE, 0); | 1315 m_sourceDataHandler->startRuleHeader(CSSRuleSourceData::STYLE_RULE, 0); |
1316 m_sourceDataHandler->endRuleHeader(1); | 1316 m_sourceDataHandler->endRuleHeader(1); |
1317 m_sourceDataHandler->startRuleBody(0); | 1317 m_sourceDataHandler->startRuleBody(0); |
1318 } | 1318 } |
1319 cssyyparse(this); | 1319 cssyyparse(this); |
1320 m_rule = 0; | 1320 m_rule = 0; |
1321 | 1321 |
1322 bool ok = false; | 1322 bool ok = false; |
1323 if (m_hasFontFaceOnlyValues) | 1323 if (m_hasFontFaceOnlyValues) |
(...skipping 7335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8659 { | 8659 { |
8660 return !(equalIgnoringCase(flowName, "auto") | 8660 return !(equalIgnoringCase(flowName, "auto") |
8661 || equalIgnoringCase(flowName, "default") | 8661 || equalIgnoringCase(flowName, "default") |
8662 || equalIgnoringCase(flowName, "inherit") | 8662 || equalIgnoringCase(flowName, "inherit") |
8663 || equalIgnoringCase(flowName, "initial") | 8663 || equalIgnoringCase(flowName, "initial") |
8664 || equalIgnoringCase(flowName, "none")); | 8664 || equalIgnoringCase(flowName, "none")); |
8665 } | 8665 } |
8666 | 8666 |
8667 bool CSSParser::parseFlowThread(const String& flowName) | 8667 bool CSSParser::parseFlowThread(const String& flowName) |
8668 { | 8668 { |
8669 setupParser("@-internal-decls{-webkit-flow-into:", flowName, "}"); | 8669 setupParser("@-internal-decls -webkit-flow-into:", flowName, ""); |
8670 cssyyparse(this); | 8670 cssyyparse(this); |
8671 | 8671 |
8672 m_rule = 0; | 8672 m_rule = 0; |
8673 | 8673 |
8674 return ((m_parsedProperties.size() == 1) && (m_parsedProperties.first().id()
== CSSPropertyWebkitFlowInto)); | 8674 return ((m_parsedProperties.size() == 1) && (m_parsedProperties.first().id()
== CSSPropertyWebkitFlowInto)); |
8675 } | 8675 } |
8676 | 8676 |
8677 // none | <ident> | 8677 // none | <ident> |
8678 bool CSSParser::parseFlowThread(CSSPropertyID propId, bool important) | 8678 bool CSSParser::parseFlowThread(CSSPropertyID propId, bool important) |
8679 { | 8679 { |
(...skipping 1562 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10242 m_token = INTERNAL_SELECTOR_SYM; | 10242 m_token = INTERNAL_SELECTOR_SYM; |
10243 return; | 10243 return; |
10244 | 10244 |
10245 case 20: | 10245 case 20: |
10246 if (isEqualToCSSIdentifier(name + 2, "internal-medialist")) { | 10246 if (isEqualToCSSIdentifier(name + 2, "internal-medialist")) { |
10247 m_parsingMode = MediaQueryMode; | 10247 m_parsingMode = MediaQueryMode; |
10248 m_token = INTERNAL_MEDIALIST_SYM; | 10248 m_token = INTERNAL_MEDIALIST_SYM; |
10249 } | 10249 } |
10250 return; | 10250 return; |
10251 | 10251 |
10252 case 22: | 10252 case 24: |
10253 if (!hasEscape && isEqualToCSSIdentifier(name + 2, "webkit-keyframe-
rule")) | 10253 if (!hasEscape && isEqualToCSSIdentifier(name + 2, "internal-keyfram
e-rule")) |
10254 m_token = WEBKIT_KEYFRAME_RULE_SYM; | 10254 m_token = INTERNAL_KEYFRAME_RULE_SYM; |
10255 return; | 10255 return; |
10256 | 10256 |
10257 case 27: | 10257 case 29: |
10258 if (isEqualToCSSIdentifier(name + 2, "webkit-supports-condition")) { | 10258 if (isEqualToCSSIdentifier(name + 2, "internal-supports-condition"))
{ |
10259 m_parsingMode = SupportsMode; | 10259 m_parsingMode = SupportsMode; |
10260 m_token = WEBKIT_SUPPORTS_CONDITION_SYM; | 10260 m_token = INTERNAL_SUPPORTS_CONDITION_SYM; |
10261 } | 10261 } |
10262 return; | 10262 return; |
10263 } | 10263 } |
10264 } | 10264 } |
10265 } | 10265 } |
10266 | 10266 |
10267 template <typename CharacterType> | 10267 template <typename CharacterType> |
10268 inline void CSSParser::detectSupportsToken(int length) | 10268 inline void CSSParser::detectSupportsToken(int length) |
10269 { | 10269 { |
10270 ASSERT(m_parsingMode == SupportsMode); | 10270 ASSERT(m_parsingMode == SupportsMode); |
(...skipping 1497 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11768 { | 11768 { |
11769 // The tokenizer checks for the construct of an+b. | 11769 // The tokenizer checks for the construct of an+b. |
11770 // However, since the {ident} rule precedes the {nth} rule, some of those | 11770 // However, since the {ident} rule precedes the {nth} rule, some of those |
11771 // tokens are identified as string literal. Furthermore we need to accept | 11771 // tokens are identified as string literal. Furthermore we need to accept |
11772 // "odd" and "even" which does not match to an+b. | 11772 // "odd" and "even" which does not match to an+b. |
11773 return equalIgnoringCase(token, "odd") || equalIgnoringCase(token, "even") | 11773 return equalIgnoringCase(token, "odd") || equalIgnoringCase(token, "even") |
11774 || equalIgnoringCase(token, "n") || equalIgnoringCase(token, "-n"); | 11774 || equalIgnoringCase(token, "n") || equalIgnoringCase(token, "-n"); |
11775 } | 11775 } |
11776 | 11776 |
11777 } | 11777 } |
OLD | NEW |