OLD | NEW |
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 CSSIdentifierValue_h | 5 #ifndef CSSIdentifierValue_h |
6 #define CSSIdentifierValue_h | 6 #define CSSIdentifierValue_h |
7 | 7 |
8 #include "core/CSSValueKeywords.h" | 8 #include "core/CSSValueKeywords.h" |
9 #include "core/css/CSSValue.h" | 9 #include "core/css/CSSValue.h" |
| 10 #include "core/css/CSSValueIDMappings.h" |
10 #include "wtf/TypeTraits.h" | 11 #include "wtf/TypeTraits.h" |
11 | 12 |
12 namespace blink { | 13 namespace blink { |
13 | 14 |
14 // CSSIdentifierValue stores CSS value keywords, e.g. 'none', 'auto', | 15 // CSSIdentifierValue stores CSS value keywords, e.g. 'none', 'auto', |
15 // 'lower-roman'. | 16 // 'lower-roman'. |
16 // TODO(sashab): Rename this class to CSSKeywordValue once it no longer | 17 // TODO(sashab): Rename this class to CSSKeywordValue once it no longer |
17 // conflicts with CSSOM's CSSKeywordValue class. | 18 // conflicts with CSSOM's CSSKeywordValue class. |
18 class CORE_EXPORT CSSIdentifierValue : public CSSValue { | 19 class CORE_EXPORT CSSIdentifierValue : public CSSValue { |
19 public: | 20 public: |
(...skipping 14 matching lines...) Expand all Loading... |
34 | 35 |
35 CSSValueID getValueID() const { return m_valueID; } | 36 CSSValueID getValueID() const { return m_valueID; } |
36 | 37 |
37 String customCSSText() const; | 38 String customCSSText() const; |
38 | 39 |
39 bool equals(const CSSIdentifierValue& other) const { | 40 bool equals(const CSSIdentifierValue& other) const { |
40 return m_valueID == other.m_valueID; | 41 return m_valueID == other.m_valueID; |
41 } | 42 } |
42 | 43 |
43 template <typename T> | 44 template <typename T> |
44 inline T convertTo() const; // Defined in CSSPrimitiveValueMappings.h | 45 inline T convertTo() |
| 46 const { // Overridden for special cases in CSSPrimitiveValueMappings.h |
| 47 return cssValueIDToPlatformEnum<T>(m_valueID); |
| 48 } |
45 | 49 |
46 DECLARE_TRACE_AFTER_DISPATCH(); | 50 DECLARE_TRACE_AFTER_DISPATCH(); |
47 | 51 |
48 private: | 52 private: |
49 explicit CSSIdentifierValue(CSSValueID); | 53 explicit CSSIdentifierValue(CSSValueID); |
50 | 54 |
51 // TODO(sashab): Remove this function, and update mapping methods to | 55 // TODO(sashab): Remove this function, and update mapping methods to |
52 // specialize the create() method instead. | 56 // specialize the create() method instead. |
53 template <typename T> | 57 template <typename T> |
54 CSSIdentifierValue(T); // Defined in CSSPrimitiveValueMappings.h | 58 CSSIdentifierValue( |
| 59 T t) // Overriden for special cases in CSSPrimitiveValueMappings.h |
| 60 : CSSValue(IdentifierClass), |
| 61 m_valueID(platformEnumToCSSValueID(t)) {} |
55 | 62 |
56 CSSIdentifierValue(const Length&); | 63 CSSIdentifierValue(const Length&); |
57 | 64 |
58 CSSValueID m_valueID; | 65 CSSValueID m_valueID; |
59 }; | 66 }; |
60 | 67 |
61 DEFINE_CSS_VALUE_TYPE_CASTS(CSSIdentifierValue, isIdentifierValue()); | 68 DEFINE_CSS_VALUE_TYPE_CASTS(CSSIdentifierValue, isIdentifierValue()); |
62 | 69 |
63 } // namespace blink | 70 } // namespace blink |
64 | 71 |
65 #endif // CSSIdentifierValue_h | 72 #endif // CSSIdentifierValue_h |
OLD | NEW |