Chromium Code Reviews| 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 22 matching lines...) Expand all Loading... | |
| 33 class StyleRuleViewport; | 33 class StyleRuleViewport; |
| 34 class StyleSheetContents; | 34 class StyleSheetContents; |
| 35 class ImmutableStylePropertySet; | 35 class ImmutableStylePropertySet; |
| 36 class Element; | 36 class Element; |
| 37 class MutableStylePropertySet; | 37 class MutableStylePropertySet; |
| 38 | 38 |
| 39 class CSSParserImpl { | 39 class CSSParserImpl { |
| 40 STACK_ALLOCATED(); | 40 STACK_ALLOCATED(); |
| 41 WTF_MAKE_NONCOPYABLE(CSSParserImpl); | 41 WTF_MAKE_NONCOPYABLE(CSSParserImpl); |
| 42 public: | 42 public: |
| 43 CSSParserImpl(const CSSParserContext&, StyleSheetContents* = nullptr); | 43 CSSParserImpl(const CSSParserContext&, StyleSheetContents* = nullptr, bool d eferPropertyParsing = false); |
| 44 | 44 |
| 45 enum AllowedRulesType { | 45 enum AllowedRulesType { |
| 46 // As per css-syntax, css-cascade and css-namespaces, @charset rules | 46 // As per css-syntax, css-cascade and css-namespaces, @charset rules |
| 47 // must come first, followed by @import then @namespace. | 47 // must come first, followed by @import then @namespace. |
| 48 // AllowImportRules actually means we allow @import and any rules thay | 48 // AllowImportRules actually means we allow @import and any rules thay |
| 49 // may follow it, i.e. @namespace rules and regular rules. | 49 // may follow it, i.e. @namespace rules and regular rules. |
| 50 // AllowCharsetRules and AllowNamespaceRules behave similarly. | 50 // AllowCharsetRules and AllowNamespaceRules behave similarly. |
| 51 AllowCharsetRules, | 51 AllowCharsetRules, |
| 52 AllowImportRules, | 52 AllowImportRules, |
| 53 AllowNamespaceRules, | 53 AllowNamespaceRules, |
| 54 RegularRules, | 54 RegularRules, |
| 55 KeyframeRules, | 55 KeyframeRules, |
| 56 ApplyRules, // For @apply inside style rules | 56 ApplyRules, // For @apply inside style rules |
| 57 NoRules, // For parsing at-rules inside declaration lists | 57 NoRules, // For parsing at-rules inside declaration lists |
| 58 }; | 58 }; |
| 59 | 59 |
| 60 static bool parseValue(MutableStylePropertySet*, CSSPropertyID, const String &, bool important, const CSSParserContext&); | 60 static bool parseValue(MutableStylePropertySet*, CSSPropertyID, const String &, bool important, const CSSParserContext&); |
| 61 static bool parseVariableValue(MutableStylePropertySet*, const AtomicString& propertyName, const String&, bool important, const CSSParserContext&); | 61 static bool parseVariableValue(MutableStylePropertySet*, const AtomicString& propertyName, const String&, bool important, const CSSParserContext&); |
| 62 static ImmutableStylePropertySet* parseInlineStyleDeclaration(const String&, Element*); | 62 static ImmutableStylePropertySet* parseInlineStyleDeclaration(const String&, Element*); |
| 63 static bool parseDeclarationList(MutableStylePropertySet*, const String&, co nst CSSParserContext&); | 63 static bool parseDeclarationList(MutableStylePropertySet*, const String&, co nst CSSParserContext&); |
| 64 static StyleRuleBase* parseRule(const String&, const CSSParserContext&, Styl eSheetContents*, AllowedRulesType); | 64 static StyleRuleBase* parseRule(const String&, const CSSParserContext&, Styl eSheetContents*, AllowedRulesType); |
| 65 static void parseStyleSheet(const String&, const CSSParserContext&, StyleShe etContents*); | 65 static void parseStyleSheet(const String&, const CSSParserContext&, StyleShe etContents*, bool deferPropertyParsing = false); |
| 66 static CSSSelectorList parsePageSelector(CSSParserTokenRange, StyleSheetCont ents*); | 66 static CSSSelectorList parsePageSelector(CSSParserTokenRange, StyleSheetCont ents*); |
| 67 | 67 |
| 68 static ImmutableStylePropertySet* parseCustomPropertySet(CSSParserTokenRange ); | 68 static ImmutableStylePropertySet* parseCustomPropertySet(CSSParserTokenRange ); |
| 69 | 69 |
| 70 static std::unique_ptr<Vector<double>> parseKeyframeKeyList(const String&); | 70 static std::unique_ptr<Vector<double>> parseKeyframeKeyList(const String&); |
| 71 | 71 |
| 72 bool supportsDeclaration(CSSParserTokenRange&); | 72 bool supportsDeclaration(CSSParserTokenRange&); |
| 73 | 73 |
| 74 static void parseDeclarationListForInspector(const String&, const CSSParserC ontext&, CSSParserObserver&); | 74 static void parseDeclarationListForInspector(const String&, const CSSParserC ontext&, CSSParserObserver&); |
| 75 static void parseStyleSheetForInspector(const String&, const CSSParserContex t&, StyleSheetContents*, CSSParserObserver&); | 75 static void parseStyleSheetForInspector(const String&, const CSSParserContex t&, StyleSheetContents*, CSSParserObserver&); |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 104 StyleRuleKeyframe* consumeKeyframeStyleRule(CSSParserTokenRange prelude, CSS ParserTokenRange block); | 104 StyleRuleKeyframe* consumeKeyframeStyleRule(CSSParserTokenRange prelude, CSS ParserTokenRange block); |
| 105 StyleRule* consumeStyleRule(CSSParserTokenRange prelude, CSSParserTokenRange block); | 105 StyleRule* consumeStyleRule(CSSParserTokenRange prelude, CSSParserTokenRange block); |
| 106 | 106 |
| 107 void consumeDeclarationList(CSSParserTokenRange, StyleRule::RuleType); | 107 void consumeDeclarationList(CSSParserTokenRange, StyleRule::RuleType); |
| 108 void consumeDeclaration(CSSParserTokenRange, StyleRule::RuleType); | 108 void consumeDeclaration(CSSParserTokenRange, StyleRule::RuleType); |
| 109 void consumeDeclarationValue(CSSParserTokenRange, CSSPropertyID, bool import ant, StyleRule::RuleType); | 109 void consumeDeclarationValue(CSSParserTokenRange, CSSPropertyID, bool import ant, StyleRule::RuleType); |
| 110 void consumeVariableValue(CSSParserTokenRange, const AtomicString& propertyN ame, bool important); | 110 void consumeVariableValue(CSSParserTokenRange, const AtomicString& propertyN ame, bool important); |
| 111 | 111 |
| 112 static std::unique_ptr<Vector<double>> consumeKeyframeKeyList(CSSParserToken Range); | 112 static std::unique_ptr<Vector<double>> consumeKeyframeKeyList(CSSParserToken Range); |
| 113 | 113 |
| 114 static std::unique_ptr<DeferredPropertiesClosure> createDeferredPropertiesCl osure(CSSParserTokenRange, const CSSParserContext&, UseCounter*); | |
| 115 | |
| 116 static StylePropertySet* parseDeclarationListForLazyStyle(Vector<CSSParserTo ken>, const CSSParserContext*, UseCounter*); | |
| 117 | |
| 118 static bool shouldLazilyParseProperties(const CSSSelectorList& selectors); | |
| 119 | |
| 114 // FIXME: Can we build StylePropertySets directly? | 120 // FIXME: Can we build StylePropertySets directly? |
| 115 // FIXME: Investigate using a smaller inline buffer | 121 // FIXME: Investigate using a smaller inline buffer |
| 116 HeapVector<CSSProperty, 256> m_parsedProperties; | 122 HeapVector<CSSProperty, 256> m_parsedProperties; |
| 117 const CSSParserContext& m_context; | 123 const CSSParserContext& m_context; |
| 118 | 124 |
| 119 Member<StyleSheetContents> m_styleSheet; | 125 Member<StyleSheetContents> m_styleSheet; |
| 120 | 126 |
| 121 // For the inspector | 127 // For the inspector |
| 122 CSSParserObserverWrapper* m_observerWrapper; | 128 CSSParserObserverWrapper* m_observerWrapper; |
| 129 | |
| 130 bool m_deferPropertyParsing = false; | |
|
Timothy Loh
2016/09/28 02:01:44
Not sure "= false" does anything here.
| |
| 123 }; | 131 }; |
| 124 | 132 |
| 125 } // namespace blink | 133 } // namespace blink |
| 126 | 134 |
| 127 #endif // CSSParserImpl_h | 135 #endif // CSSParserImpl_h |
| OLD | NEW |