2 * Copyright (C) 2003 Lars Knoll (knoll@kde.org)
3 * Copyright (C) 2004, 2005, 2006, 2008, 2009, 2010 Apple Inc. All rights reserved.
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Library General Public License for more details.
15 * You should have received a copy of the GNU Library General Public License
16 * along with this library; see the file COPYING.LIB. If not, write to
17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 * Boston, MA 02110-1301, USA.
21 #ifndef CSSParserValues_h
22 #define CSSParserValues_h
24 #include "CSSSelector.h"
25 #include <wtf/text/AtomicString.h>
32 struct CSSParserString {
38 operator String() const { return String(characters, length); }
39 operator AtomicString() const { return AtomicString(characters, length); }
42 struct CSSParserFunction;
44 struct CSSParserValue {
50 CSSParserString string;
51 CSSParserFunction* function;
61 PassRefPtr<CSSValue> createCSSValue();
64 class CSSParserValueList {
65 WTF_MAKE_FAST_ALLOCATED;
71 ~CSSParserValueList();
73 void addValue(const CSSParserValue&);
74 void insertValueAt(unsigned, const CSSParserValue&);
75 void deleteValueAt(unsigned);
76 void extend(CSSParserValueList&);
78 unsigned size() const { return m_values.size(); }
79 CSSParserValue* current() { return m_current < m_values.size() ? &m_values[m_current] : 0; }
80 CSSParserValue* next() { ++m_current; return current(); }
81 CSSParserValue* previous()
89 CSSParserValue* valueAt(unsigned i) { return i < m_values.size() ? &m_values[i] : 0; }
91 void clear() { m_values.clear(); }
95 Vector<CSSParserValue, 4> m_values;
98 struct CSSParserFunction {
99 WTF_MAKE_FAST_ALLOCATED;
101 CSSParserString name;
102 OwnPtr<CSSParserValueList> args;
105 class CSSParserSelector {
106 WTF_MAKE_FAST_ALLOCATED;
109 ~CSSParserSelector();
111 PassOwnPtr<CSSSelector> releaseSelector() { return m_selector.release(); }
113 void setTag(const QualifiedName& value) { m_selector->setTag(value); }
114 void setValue(const AtomicString& value) { m_selector->setValue(value); }
115 void setAttribute(const QualifiedName& value) { m_selector->setAttribute(value); }
116 void setArgument(const AtomicString& value) { m_selector->setArgument(value); }
117 void setMatch(CSSSelector::Match value) { m_selector->m_match = value; }
118 void setRelation(CSSSelector::Relation value) { m_selector->m_relation = value; }
119 void setForPage() { m_selector->setForPage(); }
121 void adoptSelectorVector(Vector<OwnPtr<CSSParserSelector> >& selectorVector);
123 CSSSelector::PseudoType pseudoType() const { return m_selector->pseudoType(); }
124 bool isUnknownPseudoElement() const { return m_selector->isUnknownPseudoElement(); }
125 bool isSimple() const { return !m_tagHistory && m_selector->isSimple(); }
126 bool hasShadowDescendant() const;
128 CSSParserSelector* tagHistory() const { return m_tagHistory.get(); }
129 void setTagHistory(PassOwnPtr<CSSParserSelector> selector) { m_tagHistory = selector; }
130 void insertTagHistory(CSSSelector::Relation before, PassOwnPtr<CSSParserSelector>, CSSSelector::Relation after);
131 void appendTagHistory(CSSSelector::Relation, PassOwnPtr<CSSParserSelector>);
134 OwnPtr<CSSSelector> m_selector;
135 OwnPtr<CSSParserSelector> m_tagHistory;
138 inline bool CSSParserSelector::hasShadowDescendant() const
140 return m_selector->relation() == CSSSelector::ShadowDescendant;