Chromium Code Reviews| 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 template <int T> | |
| 16 class CORE_EXPORT CSSStringValueBase : public CSSValue { | |
| 17 public: | |
| 18 static PassRefPtrWillBeRawPtr<CSSStringValueBase> create(const String& str) | |
| 19 { | |
| 20 return adoptRefWillBeNoop(new CSSStringValueBase(str)); | |
| 21 } | |
| 22 | |
| 23 String value() const { return m_string; } | |
| 24 | |
| 25 String customCSSText() const; | |
| 26 | |
| 27 bool equals(const CSSStringValueBase& other) const | |
| 28 { | |
| 29 return m_string == other.m_string; | |
| 30 } | |
| 31 | |
| 32 DEFINE_INLINE_TRACE_AFTER_DISPATCH() | |
| 33 { | |
| 34 CSSValue::traceAfterDispatch(visitor); | |
| 35 } | |
| 36 | |
| 37 private: | |
| 38 CSSStringValueBase(const String& str) | |
| 39 : CSSValue(static_cast<ClassType>(T)) | |
|
alancutter (OOO until 2018)
2015/09/17 02:59:29
Is the static_cast necessary?
sashab
2015/09/17 04:19:49
Yes, but turns out you can add types to template a
| |
| 40 , m_string(str) { } | |
| 41 | |
| 42 String m_string; | |
| 43 }; | |
| 44 | |
| 45 using CSSStringValue = CSSStringValueBase<CSSValue::StringClass>; | |
| 46 using CSSCustomIdentValue = CSSStringValueBase<CSSValue::CustomIdentClass>; | |
| 47 using CSSURIValue = CSSStringValueBase<CSSValue::URIClass>; | |
| 48 | |
| 49 DEFINE_CSS_VALUE_TYPE_CASTS(CSSStringValue, isStringValue()); | |
| 50 DEFINE_CSS_VALUE_TYPE_CASTS(CSSCustomIdentValue, isCustomIdentValue()); | |
| 51 DEFINE_CSS_VALUE_TYPE_CASTS(CSSURIValue, isURIValue()); | |
| 52 | |
| 53 } // namespace blink | |
| 54 | |
| 55 #endif // CSSStringValueBase_h | |
| OLD | NEW |