| // Copyright 2016 The Chromium Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| |
| #ifndef CSSUnparsedValue_h |
| #define CSSUnparsedValue_h |
| |
| #include "bindings/core/v8/string_or_css_variable_reference_value.h" |
| #include "core/css/CSSVariableReferenceValue.h" |
| #include "core/css/cssom/CSSStyleValue.h" |
| #include "platform/wtf/Vector.h" |
| |
| namespace blink { |
| |
| class CORE_EXPORT CSSUnparsedValue final : public CSSStyleValue { |
| WTF_MAKE_NONCOPYABLE(CSSUnparsedValue); |
| DEFINE_WRAPPERTYPEINFO(); |
| |
| public: |
| static CSSUnparsedValue* Create( |
| const HeapVector<StringOrCSSVariableReferenceValue>& tokens) { |
| return new CSSUnparsedValue(tokens); |
| } |
| |
| static CSSUnparsedValue* FromCSSValue(const CSSVariableReferenceValue&); |
| |
| const CSSValue* ToCSSValue(SecureContextMode) const override; |
| |
| StyleValueType GetType() const override { return kUnparsedType; } |
| |
| StringOrCSSVariableReferenceValue AnonymousIndexedGetter( |
| unsigned index, |
| ExceptionState& exception_state) const { |
| if (index < tokens_.size()) |
| return tokens_[index]; |
| return {}; |
| } |
| |
| size_t length() const { return tokens_.size(); } |
| |
| virtual void Trace(Visitor* visitor) { |
| visitor->Trace(tokens_); |
| CSSStyleValue::Trace(visitor); |
| } |
| |
| protected: |
| CSSUnparsedValue(const HeapVector<StringOrCSSVariableReferenceValue>& tokens) |
| : CSSStyleValue(), tokens_(tokens) {} |
| |
| private: |
| static CSSUnparsedValue* FromString(const String& string) { |
| HeapVector<StringOrCSSVariableReferenceValue> tokens; |
| tokens.push_back(StringOrCSSVariableReferenceValue::FromString(string)); |
| return Create(tokens); |
| } |
| |
| FRIEND_TEST_ALL_PREFIXES(CSSVariableReferenceValueTest, MixedList); |
| |
| HeapVector<StringOrCSSVariableReferenceValue> tokens_; |
| }; |
| |
| } // namespace blink |
| |
| #endif // CSSUnparsedValue_h |