• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef CSSParser_h
6 #define CSSParser_h
7 
8 #include "core/css/parser/BisonCSSParser.h"
9 
10 namespace blink {
11 
12 // This class serves as the public API for the css/parser subsystem
13 
14 // FIXME: This should probably be a static-only class or a singleton class
15 class CSSParser {
16     STACK_ALLOCATED();
17 public:
18     explicit CSSParser(const CSSParserContext&);
19 
20     bool parseDeclaration(MutableStylePropertySet*, const String&, CSSParserObserver*, StyleSheetContents* contextStyleSheet);
21     void parseSelector(const String&, CSSSelectorList&);
22 
23     static PassRefPtrWillBeRawPtr<StyleRuleBase> parseRule(const CSSParserContext&, StyleSheetContents*, const String&);
24     static void parseSheet(const CSSParserContext&, StyleSheetContents*, const String&, const TextPosition& startPosition, CSSParserObserver*, bool logErrors = false);
25     static bool parseValue(MutableStylePropertySet*, CSSPropertyID, const String&, bool important, CSSParserMode, StyleSheetContents*);
26 
27     // This is for non-shorthands only
28     static PassRefPtrWillBeRawPtr<CSSValue> parseSingleValue(CSSPropertyID, const String&, const CSSParserContext& = strictCSSParserContext());
29 
30     static PassRefPtrWillBeRawPtr<ImmutableStylePropertySet> parseInlineStyleDeclaration(const String&, Element*);
31 
32     static PassOwnPtr<Vector<double> > parseKeyframeKeyList(const String&);
33     static PassRefPtrWillBeRawPtr<StyleKeyframe> parseKeyframeRule(const CSSParserContext&, StyleSheetContents*, const String&);
34 
35     static bool parseSupportsCondition(const String&);
36 
37     static bool parseColor(RGBA32& color, const String&, bool strict = false);
38     static bool parseSystemColor(RGBA32& color, const String&);
39     static StyleColor colorFromRGBColorString(const String&);
40 
41 private:
42     static bool parseValue(MutableStylePropertySet*, CSSPropertyID, const String&, bool important, const CSSParserContext&);
43 
44     BisonCSSParser m_bisonParser;
45 };
46 
47 CSSPropertyID cssPropertyID(const String&);
48 
49 } // namespace blink
50 
51 #endif // CSSParser_h
52