#pragma once
#include "CSSValue.h"
#include <wtf/Function.h>
#include <wtf/Vector.h>
namespace WebCore {
class CSSCustomPropertyValue;
struct CSSParserValue;
class CSSParserValueList;
class CSSValueList : public CSSValue {
public:
typedef Vector<Ref<CSSValue>, 4>::iterator iterator;
typedef Vector<Ref<CSSValue>, 4>::const_iterator const_iterator;
static Ref<CSSValueList> createCommaSeparated()
{
return adoptRef(*new CSSValueList(CommaSeparator));
}
static Ref<CSSValueList> createSpaceSeparated()
{
return adoptRef(*new CSSValueList(SpaceSeparator));
}
static Ref<CSSValueList> createSlashSeparated()
{
return adoptRef(*new CSSValueList(SlashSeparator));
}
size_t length() const { return m_values.size(); }
CSSValue* item(size_t index) { return index < m_values.size() ? m_values[index].ptr() : nullptr; }
const CSSValue* item(size_t index) const { return index < m_values.size() ? m_values[index].ptr() : nullptr; }
CSSValue* itemWithoutBoundsCheck(size_t index) { return m_values[index].ptr(); }
const CSSValue* itemWithoutBoundsCheck(size_t index) const { ASSERT(index < m_values.size()); return m_values[index].ptr(); }
const_iterator begin() const { return m_values.begin(); }
const_iterator end() const { return m_values.end(); }
iterator begin() { return m_values.begin(); }
iterator end() { return m_values.end(); }
void append(Ref<CSSValue>&&);
void prepend(Ref<CSSValue>&&);
bool removeAll(CSSValue*);
bool hasValue(CSSValue*) const;
Ref<CSSValueList> copy();
String customCSSText() const;
bool equals(const CSSValueList&) const;
bool equals(const CSSValue&) const;
bool traverseSubresources(const WTF::Function<bool (const CachedResource&)>& handler) const;
unsigned separator() const { return m_valueListSeparator; }
protected:
CSSValueList(ClassType, ValueListSeparator);
private:
explicit CSSValueList(ValueListSeparator);
Vector<Ref<CSSValue>, 4> m_values;
};
inline void CSSValueList::append(Ref<CSSValue>&& value)
{
m_values.append(WTFMove(value));
}
inline void CSSValueList::prepend(Ref<CSSValue>&& value)
{
m_values.insert(0, WTFMove(value));
}
}
SPECIALIZE_TYPE_TRAITS_CSS_VALUE(CSSValueList, isValueList())