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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 class CSSParser { | 72 class CSSParser { |
73 friend inline int cssyylex(void*, CSSParser*); | 73 friend inline int cssyylex(void*, CSSParser*); |
74 | 74 |
75 public: | 75 public: |
76 class SourceDataHandler; | 76 class SourceDataHandler; |
77 enum ErrorType { | 77 enum ErrorType { |
78 NoError, | 78 NoError, |
79 PropertyDeclarationError, | 79 PropertyDeclarationError, |
80 InvalidPropertyValueError, | 80 InvalidPropertyValueError, |
81 InvalidPropertyError, | 81 InvalidPropertyError, |
| 82 InvalidSelectorError, |
| 83 InvalidRuleError, |
82 GeneralError | 84 GeneralError |
83 }; | 85 }; |
84 | 86 |
85 CSSParser(const CSSParserContext&, UseCounter* = 0); | 87 CSSParser(const CSSParserContext&, UseCounter* = 0); |
86 | 88 |
87 ~CSSParser(); | 89 ~CSSParser(); |
88 | 90 |
89 void parseSheet(StyleSheetContents*, const String&, int startLineNumber = 0,
SourceDataHandler* = 0, bool = false); | 91 void parseSheet(StyleSheetContents*, const String&, int startLineNumber = 0,
SourceDataHandler* = 0, bool = false); |
90 PassRefPtr<StyleRuleBase> parseRule(StyleSheetContents*, const String&); | 92 PassRefPtr<StyleRuleBase> parseRule(StyleSheetContents*, const String&); |
91 PassRefPtr<StyleKeyframe> parseKeyframeRule(StyleSheetContents*, const Strin
g&); | 93 PassRefPtr<StyleKeyframe> parseKeyframeRule(StyleSheetContents*, const Strin
g&); |
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
361 | 363 |
362 unsigned m_numParsedPropertiesBeforeMarginBox; | 364 unsigned m_numParsedPropertiesBeforeMarginBox; |
363 | 365 |
364 int m_inParseShorthand; | 366 int m_inParseShorthand; |
365 CSSPropertyID m_currentShorthand; | 367 CSSPropertyID m_currentShorthand; |
366 bool m_implicitShorthand; | 368 bool m_implicitShorthand; |
367 | 369 |
368 bool m_hasFontFaceOnlyValues; | 370 bool m_hasFontFaceOnlyValues; |
369 bool m_hadSyntacticallyValidCSSRule; | 371 bool m_hadSyntacticallyValidCSSRule; |
370 bool m_logErrors; | 372 bool m_logErrors; |
371 bool m_ignoreErrorsInDeclaration; | 373 bool m_ignoreErrors; |
372 | 374 |
373 bool m_inFilterRule; | 375 bool m_inFilterRule; |
374 | 376 |
375 AtomicString m_defaultNamespace; | 377 AtomicString m_defaultNamespace; |
376 | 378 |
377 // tokenizer methods and data | 379 // tokenizer methods and data |
378 size_t m_parsedTextPrefixLength; | 380 size_t m_parsedTextPrefixLength; |
379 size_t m_parsedTextSuffixLength; | 381 size_t m_parsedTextSuffixLength; |
380 SourceDataHandler* m_sourceDataHandler; | 382 SourceDataHandler* m_sourceDataHandler; |
381 | 383 |
382 void startRuleHeader(CSSRuleSourceData::Type); | 384 void startRuleHeader(CSSRuleSourceData::Type); |
383 void endRuleHeader(); | 385 void endRuleHeader(); |
384 void startSelector(); | 386 void startSelector(); |
385 void endSelector(); | 387 void endSelector(); |
386 void startRuleBody(); | 388 void startRuleBody(); |
387 void endRuleBody(bool discard = false); | 389 void endRuleBody(bool discard = false); |
388 void startProperty(); | 390 void startProperty(); |
389 void endProperty(bool isImportantFound, bool isPropertyParsed, ErrorType = N
oError); | 391 void endProperty(bool isImportantFound, bool isPropertyParsed, ErrorType = N
oError); |
390 void startEndUnknownRule(); | 392 void startEndUnknownRule(); |
| 393 |
| 394 void endInvalidRuleHeader(); |
391 void reportError(const CSSParserLocation&, ErrorType = GeneralError); | 395 void reportError(const CSSParserLocation&, ErrorType = GeneralError); |
| 396 void resumeErrorLogging() { m_ignoreErrors = false; } |
392 | 397 |
393 inline int lex(void* yylval) { return (this->*m_lexFunc)(yylval); } | 398 inline int lex(void* yylval) { return (this->*m_lexFunc)(yylval); } |
394 | 399 |
395 int token() { return m_token; } | 400 int token() { return m_token; } |
396 | 401 |
397 void tokenToLowerCase(const CSSParserString& token); | 402 void tokenToLowerCase(const CSSParserString& token); |
398 | 403 |
399 #if ENABLE(CSS_DEVICE_ADAPTATION) | 404 #if ENABLE(CSS_DEVICE_ADAPTATION) |
400 void markViewportRuleBodyStart() { m_inViewport = true; } | 405 void markViewportRuleBodyStart() { m_inViewport = true; } |
401 void markViewportRuleBodyEnd() { m_inViewport = false; } | 406 void markViewportRuleBodyEnd() { m_inViewport = false; } |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
562 const String* m_source; | 567 const String* m_source; |
563 union { | 568 union { |
564 LChar* ptr8; | 569 LChar* ptr8; |
565 UChar* ptr16; | 570 UChar* ptr16; |
566 } m_tokenStart; | 571 } m_tokenStart; |
567 unsigned m_length; | 572 unsigned m_length; |
568 int m_token; | 573 int m_token; |
569 int m_lineNumber; | 574 int m_lineNumber; |
570 int m_tokenStartLineNumber; | 575 int m_tokenStartLineNumber; |
571 int m_lastSelectorLineNumber; | 576 int m_lastSelectorLineNumber; |
| 577 CSSRuleSourceData::Type m_ruleHeaderType; |
| 578 unsigned m_ruleHeaderStartOffset; |
| 579 int m_ruleHeaderStartLineNumber; |
572 | 580 |
573 bool m_allowImportRules; | 581 bool m_allowImportRules; |
574 bool m_allowNamespaceDeclarations; | 582 bool m_allowNamespaceDeclarations; |
575 | 583 |
576 #if ENABLE(CSS_DEVICE_ADAPTATION) | 584 #if ENABLE(CSS_DEVICE_ADAPTATION) |
577 bool parseViewportProperty(CSSPropertyID propId, bool important); | 585 bool parseViewportProperty(CSSPropertyID propId, bool important); |
578 bool parseViewportShorthand(CSSPropertyID propId, CSSPropertyID first, CSSPr
opertyID second, bool important); | 586 bool parseViewportShorthand(CSSPropertyID propId, CSSPropertyID first, CSSPr
opertyID second, bool important); |
579 | 587 |
580 bool inViewport() const { return m_inViewport; } | 588 bool inViewport() const { return m_inViewport; } |
581 bool m_inViewport; | 589 bool m_inViewport; |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
672 m_parser->m_currentShorthand = CSSPropertyInvalid; | 680 m_parser->m_currentShorthand = CSSPropertyInvalid; |
673 } | 681 } |
674 | 682 |
675 private: | 683 private: |
676 CSSParser* m_parser; | 684 CSSParser* m_parser; |
677 }; | 685 }; |
678 | 686 |
679 struct CSSParserLocation { | 687 struct CSSParserLocation { |
680 int lineNumber; | 688 int lineNumber; |
681 CSSParserString content; | 689 CSSParserString content; |
682 | |
683 CSSParserLocation trimTrailingWhitespace() const; | |
684 }; | 690 }; |
685 | 691 |
686 class CSSParser::SourceDataHandler { | 692 class CSSParser::SourceDataHandler { |
687 public: | 693 public: |
688 virtual void startRuleHeader(CSSRuleSourceData::Type, unsigned offset) = 0; | 694 virtual void startRuleHeader(CSSRuleSourceData::Type, unsigned offset) = 0; |
689 virtual void endRuleHeader(unsigned offset) = 0; | 695 virtual void endRuleHeader(unsigned offset) = 0; |
690 virtual void startSelector(unsigned offset) = 0; | 696 virtual void startSelector(unsigned offset) = 0; |
691 virtual void endSelector(unsigned offset) = 0; | 697 virtual void endSelector(unsigned offset) = 0; |
692 virtual void startRuleBody(unsigned offset) = 0; | 698 virtual void startRuleBody(unsigned offset) = 0; |
693 virtual void endRuleBody(unsigned offset, bool error) = 0; | 699 virtual void endRuleBody(unsigned offset, bool error) = 0; |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
731 } | 737 } |
732 | 738 |
733 inline int cssyylex(void* yylval, CSSParser* parser) | 739 inline int cssyylex(void* yylval, CSSParser* parser) |
734 { | 740 { |
735 return parser->lex(yylval); | 741 return parser->lex(yylval); |
736 } | 742 } |
737 | 743 |
738 } // namespace WebCore | 744 } // namespace WebCore |
739 | 745 |
740 #endif // CSSParser_h | 746 #endif // CSSParser_h |
OLD | NEW |