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) 2004, 2005, 2006, 2008, 2009, 2010 Apple Inc. All rights reserv
ed. | 3 * Copyright (C) 2004, 2005, 2006, 2008, 2009, 2010 Apple Inc. All rights reserv
ed. |
4 * Copyright (C) 2008 Eric Seidel <eric@webkit.org> | 4 * Copyright (C) 2008 Eric Seidel <eric@webkit.org> |
5 * Copyright (C) 2009 - 2010 Torch Mobile (Beijing) Co. Ltd. All rights reserve
d. | 5 * Copyright (C) 2009 - 2010 Torch Mobile (Beijing) Co. Ltd. All rights reserve
d. |
6 * | 6 * |
7 * This library is free software; you can redistribute it and/or | 7 * This library is free software; you can redistribute it and/or |
8 * modify it under the terms of the GNU Library General Public | 8 * modify it under the terms of the GNU Library General Public |
9 * License as published by the Free Software Foundation; either | 9 * License as published by the Free Software Foundation; either |
10 * version 2 of the License, or (at your option) any later version. | 10 * version 2 of the License, or (at your option) any later version. |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 GeneralSyntaxError | 78 GeneralSyntaxError |
79 }; | 79 }; |
80 | 80 |
81 CSSParser(const CSSParserContext&); | 81 CSSParser(const CSSParserContext&); |
82 | 82 |
83 ~CSSParser(); | 83 ~CSSParser(); |
84 | 84 |
85 void parseSheet(StyleSheetContents*, const String&, int startLineNumber = 0,
SourceDataHandler* = 0, bool = false); | 85 void parseSheet(StyleSheetContents*, const String&, int startLineNumber = 0,
SourceDataHandler* = 0, bool = false); |
86 PassRefPtr<StyleRuleBase> parseRule(StyleSheetContents*, const String&); | 86 PassRefPtr<StyleRuleBase> parseRule(StyleSheetContents*, const String&); |
87 PassRefPtr<StyleKeyframe> parseKeyframeRule(StyleSheetContents*, const Strin
g&); | 87 PassRefPtr<StyleKeyframe> parseKeyframeRule(StyleSheetContents*, const Strin
g&); |
88 #if ENABLE(CSS3_CONDITIONAL_RULES) | |
89 bool parseSupportsCondition(const String&); | 88 bool parseSupportsCondition(const String&); |
90 #endif | |
91 static bool parseValue(StylePropertySet*, CSSPropertyID, const String&, bool
important, CSSParserMode, StyleSheetContents*); | 89 static bool parseValue(StylePropertySet*, CSSPropertyID, const String&, bool
important, CSSParserMode, StyleSheetContents*); |
92 static bool parseColor(RGBA32& color, const String&, bool strict = false); | 90 static bool parseColor(RGBA32& color, const String&, bool strict = false); |
93 static bool parseSystemColor(RGBA32& color, const String&, Document*); | 91 static bool parseSystemColor(RGBA32& color, const String&, Document*); |
94 static PassRefPtr<CSSValueList> parseFontFaceValue(const AtomicString&); | 92 static PassRefPtr<CSSValueList> parseFontFaceValue(const AtomicString&); |
95 PassRefPtr<CSSPrimitiveValue> parseValidPrimitive(int ident, CSSParserValue*
); | 93 PassRefPtr<CSSPrimitiveValue> parseValidPrimitive(int ident, CSSParserValue*
); |
96 bool parseDeclaration(StylePropertySet*, const String&, SourceDataHandler*,
StyleSheetContents* contextStyleSheet); | 94 bool parseDeclaration(StylePropertySet*, const String&, SourceDataHandler*,
StyleSheetContents* contextStyleSheet); |
97 static PassRefPtr<StylePropertySet> parseInlineStyleDeclaration(const String
&, Element*); | 95 static PassRefPtr<StylePropertySet> parseInlineStyleDeclaration(const String
&, Element*); |
98 PassOwnPtr<MediaQuery> parseMediaQuery(const String&); | 96 PassOwnPtr<MediaQuery> parseMediaQuery(const String&); |
99 | 97 |
100 void addPropertyWithPrefixingVariant(CSSPropertyID, PassRefPtr<CSSValue>, bo
ol important, bool implicit = false); | 98 void addPropertyWithPrefixingVariant(CSSPropertyID, PassRefPtr<CSSValue>, bo
ol important, bool implicit = false); |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
296 StyleRuleKeyframes* createKeyframesRule(const String&, PassOwnPtr<Vector<Ref
Ptr<StyleKeyframe> > >); | 294 StyleRuleKeyframes* createKeyframesRule(const String&, PassOwnPtr<Vector<Ref
Ptr<StyleKeyframe> > >); |
297 | 295 |
298 typedef Vector<RefPtr<StyleRuleBase> > RuleList; | 296 typedef Vector<RefPtr<StyleRuleBase> > RuleList; |
299 StyleRuleBase* createMediaRule(MediaQuerySet*, RuleList*); | 297 StyleRuleBase* createMediaRule(MediaQuerySet*, RuleList*); |
300 RuleList* createRuleList(); | 298 RuleList* createRuleList(); |
301 StyleRuleBase* createStyleRule(Vector<OwnPtr<CSSParserSelector> >* selectors
); | 299 StyleRuleBase* createStyleRule(Vector<OwnPtr<CSSParserSelector> >* selectors
); |
302 StyleRuleBase* createFontFaceRule(); | 300 StyleRuleBase* createFontFaceRule(); |
303 StyleRuleBase* createPageRule(PassOwnPtr<CSSParserSelector> pageSelector); | 301 StyleRuleBase* createPageRule(PassOwnPtr<CSSParserSelector> pageSelector); |
304 StyleRuleBase* createRegionRule(Vector<OwnPtr<CSSParserSelector> >* regionSe
lector, RuleList* rules); | 302 StyleRuleBase* createRegionRule(Vector<OwnPtr<CSSParserSelector> >* regionSe
lector, RuleList* rules); |
305 StyleRuleBase* createMarginAtRule(CSSSelector::MarginBoxType); | 303 StyleRuleBase* createMarginAtRule(CSSSelector::MarginBoxType); |
306 #if ENABLE(CSS3_CONDITIONAL_RULES) | |
307 StyleRuleBase* createSupportsRule(bool conditionIsSupported, RuleList*); | 304 StyleRuleBase* createSupportsRule(bool conditionIsSupported, RuleList*); |
308 void markSupportsRuleHeaderStart(); | 305 void markSupportsRuleHeaderStart(); |
309 void markSupportsRuleHeaderEnd(); | 306 void markSupportsRuleHeaderEnd(); |
310 PassRefPtr<CSSRuleSourceData> popSupportsRuleData(); | 307 PassRefPtr<CSSRuleSourceData> popSupportsRuleData(); |
311 #endif | |
312 StyleRuleBase* createHostRule(RuleList* rules); | 308 StyleRuleBase* createHostRule(RuleList* rules); |
313 StyleRuleBase* createFilterRule(const CSSParserString&); | 309 StyleRuleBase* createFilterRule(const CSSParserString&); |
314 | 310 |
315 void startDeclarationsForMarginBox(); | 311 void startDeclarationsForMarginBox(); |
316 void endDeclarationsForMarginBox(); | 312 void endDeclarationsForMarginBox(); |
317 | 313 |
318 MediaQueryExp* createFloatingMediaQueryExp(const AtomicString&, CSSParserVal
ueList*); | 314 MediaQueryExp* createFloatingMediaQueryExp(const AtomicString&, CSSParserVal
ueList*); |
319 PassOwnPtr<MediaQueryExp> sinkFloatingMediaQueryExp(MediaQueryExp*); | 315 PassOwnPtr<MediaQueryExp> sinkFloatingMediaQueryExp(MediaQueryExp*); |
320 Vector<OwnPtr<MediaQueryExp> >* createFloatingMediaQueryExpList(); | 316 Vector<OwnPtr<MediaQueryExp> >* createFloatingMediaQueryExpList(); |
321 PassOwnPtr<Vector<OwnPtr<MediaQueryExp> > > sinkFloatingMediaQueryExpList(Ve
ctor<OwnPtr<MediaQueryExp> >*); | 317 PassOwnPtr<Vector<OwnPtr<MediaQueryExp> > > sinkFloatingMediaQueryExpList(Ve
ctor<OwnPtr<MediaQueryExp> >*); |
(...skipping 28 matching lines...) Expand all Loading... |
350 | 346 |
351 CSSParserContext m_context; | 347 CSSParserContext m_context; |
352 | 348 |
353 bool m_important; | 349 bool m_important; |
354 CSSPropertyID m_id; | 350 CSSPropertyID m_id; |
355 StyleSheetContents* m_styleSheet; | 351 StyleSheetContents* m_styleSheet; |
356 RefPtr<StyleRuleBase> m_rule; | 352 RefPtr<StyleRuleBase> m_rule; |
357 RefPtr<StyleKeyframe> m_keyframe; | 353 RefPtr<StyleKeyframe> m_keyframe; |
358 OwnPtr<MediaQuery> m_mediaQuery; | 354 OwnPtr<MediaQuery> m_mediaQuery; |
359 OwnPtr<CSSParserValueList> m_valueList; | 355 OwnPtr<CSSParserValueList> m_valueList; |
360 #if ENABLE(CSS3_CONDITIONAL_RULES) | |
361 bool m_supportsCondition; | 356 bool m_supportsCondition; |
362 #endif | |
363 | 357 |
364 typedef Vector<CSSProperty, 256> ParsedPropertyVector; | 358 typedef Vector<CSSProperty, 256> ParsedPropertyVector; |
365 ParsedPropertyVector m_parsedProperties; | 359 ParsedPropertyVector m_parsedProperties; |
366 CSSSelectorList* m_selectorListForParseSelector; | 360 CSSSelectorList* m_selectorListForParseSelector; |
367 | 361 |
368 unsigned m_numParsedPropertiesBeforeMarginBox; | 362 unsigned m_numParsedPropertiesBeforeMarginBox; |
369 | 363 |
370 int m_inParseShorthand; | 364 int m_inParseShorthand; |
371 CSSPropertyID m_currentShorthand; | 365 CSSPropertyID m_currentShorthand; |
372 bool m_implicitShorthand; | 366 bool m_implicitShorthand; |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
469 template <typename CharacterType> | 463 template <typename CharacterType> |
470 inline bool detectFunctionTypeToken(int); | 464 inline bool detectFunctionTypeToken(int); |
471 template <typename CharacterType> | 465 template <typename CharacterType> |
472 inline void detectMediaQueryToken(int); | 466 inline void detectMediaQueryToken(int); |
473 template <typename CharacterType> | 467 template <typename CharacterType> |
474 inline void detectNumberToken(CharacterType*, int); | 468 inline void detectNumberToken(CharacterType*, int); |
475 template <typename CharacterType> | 469 template <typename CharacterType> |
476 inline void detectDashToken(int); | 470 inline void detectDashToken(int); |
477 template <typename CharacterType> | 471 template <typename CharacterType> |
478 inline void detectAtToken(int, bool); | 472 inline void detectAtToken(int, bool); |
479 #if ENABLE(CSS3_CONDITIONAL_RULES) | |
480 template <typename CharacterType> | 473 template <typename CharacterType> |
481 inline void detectSupportsToken(int); | 474 inline void detectSupportsToken(int); |
482 #endif | |
483 | 475 |
484 void setStyleSheet(StyleSheetContents* styleSheet) { m_styleSheet = styleShe
et; } | 476 void setStyleSheet(StyleSheetContents* styleSheet) { m_styleSheet = styleShe
et; } |
485 | 477 |
486 inline bool inStrictMode() const { return m_context.mode == CSSStrictMode ||
m_context.mode == SVGAttributeMode; } | 478 inline bool inStrictMode() const { return m_context.mode == CSSStrictMode ||
m_context.mode == SVGAttributeMode; } |
487 inline bool inQuirksMode() const { return m_context.mode == CSSQuirksMode; } | 479 inline bool inQuirksMode() const { return m_context.mode == CSSQuirksMode; } |
488 | 480 |
489 KURL completeURL(const String& url) const; | 481 KURL completeURL(const String& url) const; |
490 | 482 |
491 void recheckAtKeyword(const UChar* str, int len); | 483 void recheckAtKeyword(const UChar* str, int len); |
492 | 484 |
(...skipping 28 matching lines...) Expand all Loading... |
521 SizeParameterType parseSizeParameter(CSSValueList* parsedValues, CSSParserVa
lue* value, SizeParameterType prevParamType); | 513 SizeParameterType parseSizeParameter(CSSValueList* parsedValues, CSSParserVa
lue* value, SizeParameterType prevParamType); |
522 | 514 |
523 bool parseFontFaceSrcURI(CSSValueList*); | 515 bool parseFontFaceSrcURI(CSSValueList*); |
524 bool parseFontFaceSrcLocal(CSSValueList*); | 516 bool parseFontFaceSrcLocal(CSSValueList*); |
525 | 517 |
526 bool parseColor(const String&); | 518 bool parseColor(const String&); |
527 | 519 |
528 enum ParsingMode { | 520 enum ParsingMode { |
529 NormalMode, | 521 NormalMode, |
530 MediaQueryMode, | 522 MediaQueryMode, |
531 #if ENABLE(CSS3_CONDITIONAL_RULES) | |
532 SupportsMode, | 523 SupportsMode, |
533 #endif | |
534 NthChildMode | 524 NthChildMode |
535 }; | 525 }; |
536 | 526 |
537 ParsingMode m_parsingMode; | 527 ParsingMode m_parsingMode; |
538 bool m_is8BitSource; | 528 bool m_is8BitSource; |
539 OwnArrayPtr<LChar> m_dataStart8; | 529 OwnArrayPtr<LChar> m_dataStart8; |
540 OwnArrayPtr<UChar> m_dataStart16; | 530 OwnArrayPtr<UChar> m_dataStart16; |
541 LChar* m_currentCharacter8; | 531 LChar* m_currentCharacter8; |
542 UChar* m_currentCharacter16; | 532 UChar* m_currentCharacter16; |
543 union { | 533 union { |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
576 OwnPtr<MediaQueryExp> m_floatingMediaQueryExp; | 566 OwnPtr<MediaQueryExp> m_floatingMediaQueryExp; |
577 OwnPtr<Vector<OwnPtr<MediaQueryExp> > > m_floatingMediaQueryExpList; | 567 OwnPtr<Vector<OwnPtr<MediaQueryExp> > > m_floatingMediaQueryExpList; |
578 | 568 |
579 OwnPtr<Vector<RefPtr<StyleKeyframe> > > m_floatingKeyframeVector; | 569 OwnPtr<Vector<RefPtr<StyleKeyframe> > > m_floatingKeyframeVector; |
580 | 570 |
581 Vector<OwnPtr<CSSParserSelector> > m_reusableSelectorVector; | 571 Vector<OwnPtr<CSSParserSelector> > m_reusableSelectorVector; |
582 Vector<OwnPtr<CSSParserSelector> > m_reusableRegionSelectorVector; | 572 Vector<OwnPtr<CSSParserSelector> > m_reusableRegionSelectorVector; |
583 | 573 |
584 RefPtr<CSSCalcValue> m_parsedCalculation; | 574 RefPtr<CSSCalcValue> m_parsedCalculation; |
585 | 575 |
586 #if ENABLE(CSS3_CONDITIONAL_RULES) | |
587 OwnPtr<RuleSourceDataList> m_supportsRuleDataStack; | 576 OwnPtr<RuleSourceDataList> m_supportsRuleDataStack; |
588 #endif | |
589 | 577 |
590 // defines units allowed for a certain property, used in parseUnit | 578 // defines units allowed for a certain property, used in parseUnit |
591 enum Units { | 579 enum Units { |
592 FUnknown = 0x0000, | 580 FUnknown = 0x0000, |
593 FInteger = 0x0001, | 581 FInteger = 0x0001, |
594 FNumber = 0x0002, // Real Numbers | 582 FNumber = 0x0002, // Real Numbers |
595 FPercent = 0x0004, | 583 FPercent = 0x0004, |
596 FLength = 0x0008, | 584 FLength = 0x0008, |
597 FAngle = 0x0010, | 585 FAngle = 0x0010, |
598 FTime = 0x0020, | 586 FTime = 0x0020, |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
709 } | 697 } |
710 | 698 |
711 inline int cssyylex(void* yylval, CSSParser* parser) | 699 inline int cssyylex(void* yylval, CSSParser* parser) |
712 { | 700 { |
713 return parser->lex(yylval); | 701 return parser->lex(yylval); |
714 } | 702 } |
715 | 703 |
716 } // namespace WebCore | 704 } // namespace WebCore |
717 | 705 |
718 #endif // CSSParser_h | 706 #endif // CSSParser_h |
OLD | NEW |