OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 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 CSSSyntaxDescriptor_h |
| 6 #define CSSSyntaxDescriptor_h |
| 7 |
| 8 #include "core/css/parser/CSSParserTokenRange.h" |
| 9 |
| 10 namespace blink { |
| 11 |
| 12 class CSSValue; |
| 13 |
| 14 enum class CSSSyntaxType { |
| 15 TokenStream, |
| 16 Length, |
| 17 // TODO(timloh): Add all the other types |
| 18 }; |
| 19 |
| 20 struct CSSSyntaxComponent { |
| 21 CSSSyntaxComponent(CSSSyntaxType type) |
| 22 : m_type(type) |
| 23 { |
| 24 } |
| 25 |
| 26 CSSSyntaxType m_type; |
| 27 // TODO(timloh): This will need to support arbitrary idents and list types |
| 28 }; |
| 29 |
| 30 class CSSSyntaxDescriptor { |
| 31 public: |
| 32 CSSSyntaxDescriptor(String syntax); |
| 33 |
| 34 const CSSValue* parse(CSSParserTokenRange) const; |
| 35 const CSSValue* parse(const String&) const; |
| 36 bool isValid() const { return !m_syntaxComponents.isEmpty(); } |
| 37 bool isTokenStream() const { return m_syntaxComponents.size() == 1 && m_synt
axComponents[0].m_type == CSSSyntaxType::TokenStream; } |
| 38 |
| 39 private: |
| 40 Vector<CSSSyntaxComponent> m_syntaxComponents; |
| 41 }; |
| 42 |
| 43 } // namespace blink |
| 44 |
| 45 #endif // CSSSyntaxDescriptor_h |
OLD | NEW |