OLD | NEW |
| (Empty) |
1 // Copyright 2015 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 CSSStringValueBase_h | |
6 #define CSSStringValueBase_h | |
7 | |
8 #include "core/CoreExport.h" | |
9 #include "core/css/CSSValue.h" | |
10 #include "wtf/PassRefPtr.h" | |
11 #include "wtf/RefCounted.h" | |
12 | |
13 namespace blink { | |
14 | |
15 enum class StringValueClass { | |
16 StringClass, | |
17 CustomIdentClass, | |
18 URIClass, | |
19 }; | |
20 | |
21 template <StringValueClass T> | |
22 class CSSStringValueBase : public CSSValue { | |
23 public: | |
24 static PassRefPtrWillBeRawPtr<CSSStringValueBase> create(const String& str) | |
25 { | |
26 return adoptRefWillBeNoop(new CSSStringValueBase(str)); | |
27 } | |
28 | |
29 String value() const { return m_string; } | |
30 | |
31 String customCSSText() const; | |
32 | |
33 bool equals(const CSSStringValueBase& other) const | |
34 { | |
35 return m_string == other.m_string; | |
36 } | |
37 | |
38 DEFINE_INLINE_TRACE_AFTER_DISPATCH() | |
39 { | |
40 CSSValue::traceAfterDispatch(visitor); | |
41 } | |
42 | |
43 private: | |
44 CSSStringValueBase(const String&); | |
45 | |
46 String m_string; | |
47 }; | |
48 | |
49 using CSSStringValue = CSSStringValueBase<StringValueClass::StringClass>; | |
50 using CSSCustomIdentValue = CSSStringValueBase<StringValueClass::CustomIdentClas
s>; | |
51 using CSSURIValue = CSSStringValueBase<StringValueClass::URIClass>; | |
52 | |
53 DEFINE_CSS_VALUE_TYPE_CASTS(CSSStringValue, isStringValue()); | |
54 DEFINE_CSS_VALUE_TYPE_CASTS(CSSCustomIdentValue, isCustomIdentValue()); | |
55 DEFINE_CSS_VALUE_TYPE_CASTS(CSSURIValue, isURIValue()); | |
56 | |
57 } // namespace blink | |
58 | |
59 #endif // CSSStringValueBase_h | |
OLD | NEW |