#ifndef CSSSelectorList_h
#define CSSSelectorList_h
#include "CSSSelector.h"
#include <memory>
namespace WebCore {
class CSSParserSelector;
class CSSSelectorList {
WTF_MAKE_FAST_ALLOCATED;
public:
CSSSelectorList() : m_selectorArray(0) { }
CSSSelectorList(const CSSSelectorList&);
CSSSelectorList(CSSSelectorList&&);
~CSSSelectorList() { deleteSelectors(); }
void adoptSelectorVector(Vector<std::unique_ptr<CSSParserSelector>>& selectorVector);
void adoptSelectorArray(CSSSelector* selectors) { ASSERT(!m_selectorArray); m_selectorArray = selectors; }
bool isValid() const { return !!m_selectorArray; }
const CSSSelector* first() const { return m_selectorArray; }
static const CSSSelector* next(const CSSSelector*);
bool hasOneSelector() const { return m_selectorArray && !next(m_selectorArray); }
const CSSSelector* selectorAt(size_t index) const { return &m_selectorArray[index]; }
size_t indexOfNextSelectorAfter(size_t index) const
{
const CSSSelector* current = selectorAt(index);
current = next(current);
if (!current)
return notFound;
return current - m_selectorArray;
}
bool selectorsNeedNamespaceResolution();
bool hasInvalidSelector() const;
String selectorsText() const;
unsigned componentCount() const;
CSSSelectorList& operator=(CSSSelectorList&&);
private:
void deleteSelectors();
CSSSelector* m_selectorArray;
};
inline const CSSSelector* CSSSelectorList::next(const CSSSelector* current)
{
while (!current->isLastInTagHistory())
current++;
return current->isLastInSelectorList() ? 0 : current + 1;
}
}
#endif // CSSSelectorList_h