Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(848)

Side by Side Diff: third_party/WebKit/Source/core/css/CSSSyntaxDescriptor.h

Issue 2330893002: CSS Properties and Values API: Support more syntax strings (Closed)
Patch Set: Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 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 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 CSSSyntaxDescriptor_h 5 #ifndef CSSSyntaxDescriptor_h
6 #define CSSSyntaxDescriptor_h 6 #define CSSSyntaxDescriptor_h
7 7
8 #include "core/css/parser/CSSParserTokenRange.h" 8 #include "core/css/parser/CSSParserTokenRange.h"
9 9
10 namespace blink { 10 namespace blink {
11 11
12 class CSSValue; 12 class CSSValue;
13 13
14 enum class CSSSyntaxType { 14 enum class CSSSyntaxType {
15 TokenStream, 15 TokenStream,
16 Ident,
16 Length, 17 Length,
17 // TODO(timloh): Add all the other types 18 Number,
19 Percentage,
20 LengthPercentage,
21 Color,
22 Image,
23 Url,
24 Integer,
25 Angle,
26 Time,
27 Resolution,
28 TransformFunction,
29 CustomIdent,
meade_UTC10 2016/09/14 12:54:13 Should these be alphabetised?
Timothy Loh 2016/09/19 07:14:14 These (Length->CustomIdent) are ordered the same a
18 }; 30 };
19 31
20 struct CSSSyntaxComponent { 32 struct CSSSyntaxComponent {
21 CSSSyntaxComponent(CSSSyntaxType type) 33 CSSSyntaxComponent(CSSSyntaxType type, const String& string, bool repeatable )
22 : m_type(type) 34 : m_type(type)
35 , m_string(string)
36 , m_repeatable(repeatable)
23 { 37 {
24 } 38 }
25 39
26 CSSSyntaxType m_type; 40 CSSSyntaxType m_type;
27 // TODO(timloh): This will need to support arbitrary idents and list types 41 String m_string; // Only used when m_type is CSSSyntaxType::Ident
42 bool m_repeatable;
28 }; 43 };
29 44
30 class CSSSyntaxDescriptor { 45 class CSSSyntaxDescriptor {
31 public: 46 public:
32 CSSSyntaxDescriptor(String syntax); 47 CSSSyntaxDescriptor(String syntax);
33 48
34 const CSSValue* parse(CSSParserTokenRange) const; 49 const CSSValue* parse(CSSParserTokenRange) const;
35 const CSSValue* parse(const String&) const; 50 const CSSValue* parse(const String&) const;
36 bool isValid() const { return !m_syntaxComponents.isEmpty(); } 51 bool isValid() const { return !m_syntaxComponents.isEmpty(); }
37 bool isTokenStream() const { return m_syntaxComponents.size() == 1 && m_synt axComponents[0].m_type == CSSSyntaxType::TokenStream; } 52 bool isTokenStream() const { return m_syntaxComponents.size() == 1 && m_synt axComponents[0].m_type == CSSSyntaxType::TokenStream; }
38 53
39 private: 54 private:
40 Vector<CSSSyntaxComponent> m_syntaxComponents; 55 Vector<CSSSyntaxComponent> m_syntaxComponents;
41 }; 56 };
42 57
43 } // namespace blink 58 } // namespace blink
44 59
45 #endif // CSSSyntaxDescriptor_h 60 #endif // CSSSyntaxDescriptor_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698