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 7355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8679 { | 8679 { |
8680 return !(equalIgnoringCase(flowName, "auto") | 8680 return !(equalIgnoringCase(flowName, "auto") |
8681 || equalIgnoringCase(flowName, "default") | 8681 || equalIgnoringCase(flowName, "default") |
8682 || equalIgnoringCase(flowName, "inherit") | 8682 || equalIgnoringCase(flowName, "inherit") |
8683 || equalIgnoringCase(flowName, "initial") | 8683 || equalIgnoringCase(flowName, "initial") |
8684 || equalIgnoringCase(flowName, "none")); | 8684 || equalIgnoringCase(flowName, "none")); |
8685 } | 8685 } |
8686 | 8686 |
8687 bool CSSParser::parseFlowThread(const String& flowName) | 8687 bool CSSParser::parseFlowThread(const String& flowName) |
8688 { | 8688 { |
8689 setupParser("@-internal-decls{-webkit-flow-into:", flowName, "}"); | 8689 setupParser("@-internal-decls -webkit-flow-into:", flowName, ""); |
8690 cssyyparse(this); | 8690 cssyyparse(this); |
8691 | 8691 |
8692 m_rule = 0; | 8692 m_rule = 0; |
8693 | 8693 |
8694 return ((m_parsedProperties.size() == 1) && (m_parsedProperties.first().id()
== CSSPropertyWebkitFlowInto)); | 8694 return ((m_parsedProperties.size() == 1) && (m_parsedProperties.first().id()
== CSSPropertyWebkitFlowInto)); |
8695 } | 8695 } |
8696 | 8696 |
8697 // none | <ident> | 8697 // none | <ident> |
8698 bool CSSParser::parseFlowThread(CSSPropertyID propId, bool important) | 8698 bool CSSParser::parseFlowThread(CSSPropertyID propId, bool important) |
8699 { | 8699 { |
(...skipping 1574 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10274 m_token = INTERNAL_SELECTOR_SYM; | 10274 m_token = INTERNAL_SELECTOR_SYM; |
10275 return; | 10275 return; |
10276 | 10276 |
10277 case 20: | 10277 case 20: |
10278 if (isEqualToCSSIdentifier(name + 2, "internal-medialist")) { | 10278 if (isEqualToCSSIdentifier(name + 2, "internal-medialist")) { |
10279 m_parsingMode = MediaQueryMode; | 10279 m_parsingMode = MediaQueryMode; |
10280 m_token = INTERNAL_MEDIALIST_SYM; | 10280 m_token = INTERNAL_MEDIALIST_SYM; |
10281 } | 10281 } |
10282 return; | 10282 return; |
10283 | 10283 |
10284 case 22: | 10284 case 24: |
10285 if (!hasEscape && isEqualToCSSIdentifier(name + 2, "webkit-keyframe-
rule")) | 10285 if (!hasEscape && isEqualToCSSIdentifier(name + 2, "internal-keyfram
e-rule")) |
10286 m_token = WEBKIT_KEYFRAME_RULE_SYM; | 10286 m_token = INTERNAL_KEYFRAME_RULE_SYM; |
10287 return; | 10287 return; |
10288 | 10288 |
10289 case 27: | 10289 case 29: |
10290 if (isEqualToCSSIdentifier(name + 2, "webkit-supports-condition")) { | 10290 if (isEqualToCSSIdentifier(name + 2, "internal-supports-condition"))
{ |
10291 m_parsingMode = SupportsMode; | 10291 m_parsingMode = SupportsMode; |
10292 m_token = WEBKIT_SUPPORTS_CONDITION_SYM; | 10292 m_token = INTERNAL_SUPPORTS_CONDITION_SYM; |
10293 } | 10293 } |
10294 return; | 10294 return; |
10295 } | 10295 } |
10296 } | 10296 } |
10297 } | 10297 } |
10298 | 10298 |
10299 template <typename CharacterType> | 10299 template <typename CharacterType> |
10300 inline void CSSParser::detectSupportsToken(int length) | 10300 inline void CSSParser::detectSupportsToken(int length) |
10301 { | 10301 { |
10302 ASSERT(m_parsingMode == SupportsMode); | 10302 ASSERT(m_parsingMode == SupportsMode); |
(...skipping 1505 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11808 { | 11808 { |
11809 // The tokenizer checks for the construct of an+b. | 11809 // The tokenizer checks for the construct of an+b. |
11810 // However, since the {ident} rule precedes the {nth} rule, some of those | 11810 // However, since the {ident} rule precedes the {nth} rule, some of those |
11811 // tokens are identified as string literal. Furthermore we need to accept | 11811 // tokens are identified as string literal. Furthermore we need to accept |
11812 // "odd" and "even" which does not match to an+b. | 11812 // "odd" and "even" which does not match to an+b. |
11813 return equalIgnoringCase(token, "odd") || equalIgnoringCase(token, "even") | 11813 return equalIgnoringCase(token, "odd") || equalIgnoringCase(token, "even") |
11814 || equalIgnoringCase(token, "n") || equalIgnoringCase(token, "-n"); | 11814 || equalIgnoringCase(token, "n") || equalIgnoringCase(token, "-n"); |
11815 } | 11815 } |
11816 | 11816 |
11817 } | 11817 } |
OLD | NEW |