OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CSSParserImpl_h | 5 #ifndef CSSParserImpl_h |
6 #define CSSParserImpl_h | 6 #define CSSParserImpl_h |
7 | 7 |
8 #include "core/CSSPropertyNames.h" | 8 #include "core/CSSPropertyNames.h" |
9 #include "core/css/CSSProperty.h" | 9 #include "core/css/CSSProperty.h" |
10 #include "core/css/CSSPropertySourceData.h" | 10 #include "core/css/CSSPropertySourceData.h" |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 AllowImportRules, | 50 AllowImportRules, |
51 AllowNamespaceRules, | 51 AllowNamespaceRules, |
52 RegularRules, | 52 RegularRules, |
53 KeyframeRules, | 53 KeyframeRules, |
54 ApplyRules, // For @apply inside style rules | 54 ApplyRules, // For @apply inside style rules |
55 NoRules, // For parsing at-rules inside declaration lists | 55 NoRules, // For parsing at-rules inside declaration lists |
56 }; | 56 }; |
57 | 57 |
58 static bool parseValue(MutableStylePropertySet*, CSSPropertyID, const String
&, bool important, const CSSParserContext&); | 58 static bool parseValue(MutableStylePropertySet*, CSSPropertyID, const String
&, bool important, const CSSParserContext&); |
59 static bool parseVariableValue(MutableStylePropertySet*, const AtomicString&
propertyName, const String&, bool important, const CSSParserContext&); | 59 static bool parseVariableValue(MutableStylePropertySet*, const AtomicString&
propertyName, const String&, bool important, const CSSParserContext&); |
60 static RawPtr<ImmutableStylePropertySet> parseInlineStyleDeclaration(const S
tring&, Element*); | 60 static ImmutableStylePropertySet* parseInlineStyleDeclaration(const String&,
Element*); |
61 static bool parseDeclarationList(MutableStylePropertySet*, const String&, co
nst CSSParserContext&); | 61 static bool parseDeclarationList(MutableStylePropertySet*, const String&, co
nst CSSParserContext&); |
62 static RawPtr<StyleRuleBase> parseRule(const String&, const CSSParserContext
&, StyleSheetContents*, AllowedRulesType); | 62 static StyleRuleBase* parseRule(const String&, const CSSParserContext&, Styl
eSheetContents*, AllowedRulesType); |
63 static void parseStyleSheet(const String&, const CSSParserContext&, StyleShe
etContents*); | 63 static void parseStyleSheet(const String&, const CSSParserContext&, StyleShe
etContents*); |
64 static CSSSelectorList parsePageSelector(CSSParserTokenRange, StyleSheetCont
ents*); | 64 static CSSSelectorList parsePageSelector(CSSParserTokenRange, StyleSheetCont
ents*); |
65 | 65 |
66 static RawPtr<ImmutableStylePropertySet> parseCustomPropertySet(CSSParserTok
enRange); | 66 static ImmutableStylePropertySet* parseCustomPropertySet(CSSParserTokenRange
); |
67 | 67 |
68 static PassOwnPtr<Vector<double>> parseKeyframeKeyList(const String&); | 68 static PassOwnPtr<Vector<double>> parseKeyframeKeyList(const String&); |
69 | 69 |
70 bool supportsDeclaration(CSSParserTokenRange&); | 70 bool supportsDeclaration(CSSParserTokenRange&); |
71 | 71 |
72 static void parseDeclarationListForInspector(const String&, const CSSParserC
ontext&, CSSParserObserver&); | 72 static void parseDeclarationListForInspector(const String&, const CSSParserC
ontext&, CSSParserObserver&); |
73 static void parseStyleSheetForInspector(const String&, const CSSParserContex
t&, StyleSheetContents*, CSSParserObserver&); | 73 static void parseStyleSheetForInspector(const String&, const CSSParserContex
t&, StyleSheetContents*, CSSParserObserver&); |
74 | 74 |
75 private: | 75 private: |
76 enum RuleListType { | 76 enum RuleListType { |
77 TopLevelRuleList, | 77 TopLevelRuleList, |
78 RegularRuleList, | 78 RegularRuleList, |
79 KeyframesRuleList | 79 KeyframesRuleList |
80 }; | 80 }; |
81 | 81 |
82 // Returns whether the first encountered rule was valid | 82 // Returns whether the first encountered rule was valid |
83 template<typename T> | 83 template<typename T> |
84 bool consumeRuleList(CSSParserTokenRange, RuleListType, T callback); | 84 bool consumeRuleList(CSSParserTokenRange, RuleListType, T callback); |
85 | 85 |
86 // These two functions update the range they're given | 86 // These two functions update the range they're given |
87 RawPtr<StyleRuleBase> consumeAtRule(CSSParserTokenRange&, AllowedRulesType); | 87 StyleRuleBase* consumeAtRule(CSSParserTokenRange&, AllowedRulesType); |
88 RawPtr<StyleRuleBase> consumeQualifiedRule(CSSParserTokenRange&, AllowedRule
sType); | 88 StyleRuleBase* consumeQualifiedRule(CSSParserTokenRange&, AllowedRulesType); |
89 | 89 |
90 static RawPtr<StyleRuleCharset> consumeCharsetRule(CSSParserTokenRange prelu
de); | 90 static StyleRuleCharset* consumeCharsetRule(CSSParserTokenRange prelude); |
91 RawPtr<StyleRuleImport> consumeImportRule(CSSParserTokenRange prelude); | 91 StyleRuleImport* consumeImportRule(CSSParserTokenRange prelude); |
92 RawPtr<StyleRuleNamespace> consumeNamespaceRule(CSSParserTokenRange prelude)
; | 92 StyleRuleNamespace* consumeNamespaceRule(CSSParserTokenRange prelude); |
93 RawPtr<StyleRuleMedia> consumeMediaRule(CSSParserTokenRange prelude, CSSPars
erTokenRange block); | 93 StyleRuleMedia* consumeMediaRule(CSSParserTokenRange prelude, CSSParserToken
Range block); |
94 RawPtr<StyleRuleSupports> consumeSupportsRule(CSSParserTokenRange prelude, C
SSParserTokenRange block); | 94 StyleRuleSupports* consumeSupportsRule(CSSParserTokenRange prelude, CSSParse
rTokenRange block); |
95 RawPtr<StyleRuleViewport> consumeViewportRule(CSSParserTokenRange prelude, C
SSParserTokenRange block); | 95 StyleRuleViewport* consumeViewportRule(CSSParserTokenRange prelude, CSSParse
rTokenRange block); |
96 RawPtr<StyleRuleFontFace> consumeFontFaceRule(CSSParserTokenRange prelude, C
SSParserTokenRange block); | 96 StyleRuleFontFace* consumeFontFaceRule(CSSParserTokenRange prelude, CSSParse
rTokenRange block); |
97 RawPtr<StyleRuleKeyframes> consumeKeyframesRule(bool webkitPrefixed, CSSPars
erTokenRange prelude, CSSParserTokenRange block); | 97 StyleRuleKeyframes* consumeKeyframesRule(bool webkitPrefixed, CSSParserToken
Range prelude, CSSParserTokenRange block); |
98 RawPtr<StyleRulePage> consumePageRule(CSSParserTokenRange prelude, CSSParser
TokenRange block); | 98 StyleRulePage* consumePageRule(CSSParserTokenRange prelude, CSSParserTokenRa
nge block); |
99 // Updates m_parsedProperties | 99 // Updates m_parsedProperties |
100 void consumeApplyRule(CSSParserTokenRange prelude); | 100 void consumeApplyRule(CSSParserTokenRange prelude); |
101 | 101 |
102 RawPtr<StyleRuleKeyframe> consumeKeyframeStyleRule(CSSParserTokenRange prelu
de, CSSParserTokenRange block); | 102 StyleRuleKeyframe* consumeKeyframeStyleRule(CSSParserTokenRange prelude, CSS
ParserTokenRange block); |
103 RawPtr<StyleRule> consumeStyleRule(CSSParserTokenRange prelude, CSSParserTok
enRange block); | 103 StyleRule* consumeStyleRule(CSSParserTokenRange prelude, CSSParserTokenRange
block); |
104 | 104 |
105 void consumeDeclarationList(CSSParserTokenRange, StyleRule::RuleType); | 105 void consumeDeclarationList(CSSParserTokenRange, StyleRule::RuleType); |
106 void consumeDeclaration(CSSParserTokenRange, StyleRule::RuleType); | 106 void consumeDeclaration(CSSParserTokenRange, StyleRule::RuleType); |
107 void consumeDeclarationValue(CSSParserTokenRange, CSSPropertyID, bool import
ant, StyleRule::RuleType); | 107 void consumeDeclarationValue(CSSParserTokenRange, CSSPropertyID, bool import
ant, StyleRule::RuleType); |
108 void consumeVariableValue(CSSParserTokenRange, const AtomicString& propertyN
ame, bool important); | 108 void consumeVariableValue(CSSParserTokenRange, const AtomicString& propertyN
ame, bool important); |
109 | 109 |
110 static PassOwnPtr<Vector<double>> consumeKeyframeKeyList(CSSParserTokenRange
); | 110 static PassOwnPtr<Vector<double>> consumeKeyframeKeyList(CSSParserTokenRange
); |
111 | 111 |
112 // FIXME: Can we build StylePropertySets directly? | 112 // FIXME: Can we build StylePropertySets directly? |
113 // FIXME: Investigate using a smaller inline buffer | 113 // FIXME: Investigate using a smaller inline buffer |
114 HeapVector<CSSProperty, 256> m_parsedProperties; | 114 HeapVector<CSSProperty, 256> m_parsedProperties; |
115 CSSParserContext m_context; | 115 CSSParserContext m_context; |
116 | 116 |
117 Member<StyleSheetContents> m_styleSheet; | 117 Member<StyleSheetContents> m_styleSheet; |
118 | 118 |
119 // For the inspector | 119 // For the inspector |
120 CSSParserObserverWrapper* m_observerWrapper; | 120 CSSParserObserverWrapper* m_observerWrapper; |
121 }; | 121 }; |
122 | 122 |
123 } // namespace blink | 123 } // namespace blink |
124 | 124 |
125 #endif // CSSParserImpl_h | 125 #endif // CSSParserImpl_h |
OLD | NEW |