| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2003 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 2003 Lars Knoll (knoll@kde.org) |
| 3 * Copyright (C) 2004, 2005, 2006, 2008, 2009, 2010 Apple Inc. All rights reserv
ed. | 3 * Copyright (C) 2004, 2005, 2006, 2008, 2009, 2010 Apple Inc. All rights reserv
ed. |
| 4 * | 4 * |
| 5 * This library is free software; you can redistribute it and/or | 5 * This library is free software; you can redistribute it and/or |
| 6 * modify it under the terms of the GNU Library General Public | 6 * modify it under the terms of the GNU Library General Public |
| 7 * License as published by the Free Software Foundation; either | 7 * License as published by the Free Software Foundation; either |
| 8 * version 2 of the License, or (at your option) any later version. | 8 * version 2 of the License, or (at your option) any later version. |
| 9 * | 9 * |
| 10 * This library is distributed in the hope that it will be useful, | 10 * This library is distributed in the hope that it will be useful, |
| 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 13 * Library General Public License for more details. | 13 * Library General Public License for more details. |
| 14 * | 14 * |
| 15 * You should have received a copy of the GNU Library General Public License | 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 | 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, | 17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 18 * Boston, MA 02110-1301, USA. | 18 * Boston, MA 02110-1301, USA. |
| 19 */ | 19 */ |
| 20 | 20 |
| 21 #ifndef CSSParserValues_h | 21 #ifndef CSSParserValues_h |
| 22 #define CSSParserValues_h | 22 #define CSSParserValues_h |
| 23 | 23 |
| 24 #include "core/CSSValueKeywords.h" | 24 #include "core/CSSValueKeywords.h" |
| 25 #include "core/css/CSSPrimitiveValue.h" | 25 #include "core/css/CSSPrimitiveValue.h" |
| 26 #include "core/css/CSSSelector.h" | |
| 27 #include "core/css/CSSValueList.h" | 26 #include "core/css/CSSValueList.h" |
| 28 #include "core/css/parser/CSSParserString.h" | 27 #include "core/css/parser/CSSParserString.h" |
| 29 #include "core/css/parser/CSSParserTokenRange.h" | 28 #include "core/css/parser/CSSParserTokenRange.h" |
| 30 #include "wtf/Allocator.h" | 29 #include "wtf/Allocator.h" |
| 31 | 30 |
| 32 namespace blink { | 31 namespace blink { |
| 33 | 32 |
| 34 class QualifiedName; | 33 class QualifiedName; |
| 35 | 34 |
| 36 struct CSSParserFunction; | 35 struct CSSParserFunction; |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 OwnPtr<CSSParserValueList> args; | 120 OwnPtr<CSSParserValueList> args; |
| 122 }; | 121 }; |
| 123 | 122 |
| 124 struct CSSParserCalcFunction { | 123 struct CSSParserCalcFunction { |
| 125 WTF_MAKE_FAST_ALLOCATED(CSSParserCalcFunction); | 124 WTF_MAKE_FAST_ALLOCATED(CSSParserCalcFunction); |
| 126 public: | 125 public: |
| 127 CSSParserCalcFunction(CSSParserTokenRange args_) : args(args_) {} | 126 CSSParserCalcFunction(CSSParserTokenRange args_) : args(args_) {} |
| 128 CSSParserTokenRange args; | 127 CSSParserTokenRange args; |
| 129 }; | 128 }; |
| 130 | 129 |
| 131 class CSSParserSelector { | |
| 132 WTF_MAKE_NONCOPYABLE(CSSParserSelector); WTF_MAKE_FAST_ALLOCATED(CSSParserSe
lector); | |
| 133 public: | |
| 134 CSSParserSelector(); | |
| 135 explicit CSSParserSelector(const QualifiedName&, bool isImplicit = false); | |
| 136 | |
| 137 static PassOwnPtr<CSSParserSelector> create() { return adoptPtr(new CSSParse
rSelector); } | |
| 138 static PassOwnPtr<CSSParserSelector> create(const QualifiedName& name, bool
isImplicit = false) { return adoptPtr(new CSSParserSelector(name, isImplicit));
} | |
| 139 | |
| 140 ~CSSParserSelector(); | |
| 141 | |
| 142 PassOwnPtr<CSSSelector> releaseSelector() { return m_selector.release(); } | |
| 143 | |
| 144 CSSSelector::Relation relation() const { return m_selector->relation(); } | |
| 145 void setValue(const AtomicString& value) { m_selector->setValue(value); } | |
| 146 void setAttribute(const QualifiedName& value, CSSSelector::AttributeMatchTyp
e matchType) { m_selector->setAttribute(value, matchType); } | |
| 147 void setArgument(const AtomicString& value) { m_selector->setArgument(value)
; } | |
| 148 void setNth(int a, int b) { m_selector->setNth(a, b); } | |
| 149 void setMatch(CSSSelector::Match value) { m_selector->setMatch(value); } | |
| 150 void setRelation(CSSSelector::Relation value) { m_selector->setRelation(valu
e); } | |
| 151 void setForPage() { m_selector->setForPage(); } | |
| 152 void setRelationIsAffectedByPseudoContent() { m_selector->setRelationIsAffec
tedByPseudoContent(); } | |
| 153 bool relationIsAffectedByPseudoContent() const { return m_selector->relation
IsAffectedByPseudoContent(); } | |
| 154 | |
| 155 void updatePseudoType(const AtomicString& value, bool hasArguments = false)
const { m_selector->updatePseudoType(value, hasArguments); } | |
| 156 | |
| 157 void adoptSelectorVector(Vector<OwnPtr<CSSParserSelector>>& selectorVector); | |
| 158 void setSelectorList(PassOwnPtr<CSSSelectorList>); | |
| 159 | |
| 160 bool hasHostPseudoSelector() const; | |
| 161 | |
| 162 CSSSelector::PseudoType pseudoType() const { return m_selector->pseudoType()
; } | |
| 163 | |
| 164 // TODO(esprehn): This set of cases doesn't make sense, why PseudoShadow but
not a check for ::content or /deep/ ? | |
| 165 bool crossesTreeScopes() const { return pseudoType() == CSSSelector::PseudoW
ebKitCustomElement || pseudoType() == CSSSelector::PseudoCue || pseudoType() ==
CSSSelector::PseudoShadow; } | |
| 166 | |
| 167 bool isSimple() const; | |
| 168 bool hasShadowPseudo() const; | |
| 169 | |
| 170 CSSParserSelector* tagHistory() const { return m_tagHistory.get(); } | |
| 171 void setTagHistory(PassOwnPtr<CSSParserSelector> selector) { m_tagHistory =
selector; } | |
| 172 void clearTagHistory() { m_tagHistory.clear(); } | |
| 173 void insertTagHistory(CSSSelector::Relation before, PassOwnPtr<CSSParserSele
ctor>, CSSSelector::Relation after); | |
| 174 void appendTagHistory(CSSSelector::Relation, PassOwnPtr<CSSParserSelector>); | |
| 175 void prependTagSelector(const QualifiedName&, bool tagIsImplicit = false); | |
| 176 | |
| 177 private: | |
| 178 OwnPtr<CSSSelector> m_selector; | |
| 179 OwnPtr<CSSParserSelector> m_tagHistory; | |
| 180 }; | |
| 181 | |
| 182 inline bool CSSParserSelector::hasShadowPseudo() const | |
| 183 { | |
| 184 return m_selector->relation() == CSSSelector::ShadowPseudo; | |
| 185 } | |
| 186 | |
| 187 inline void CSSParserValue::setFromNumber(double value, CSSPrimitiveValue::UnitT
ype unit) | 130 inline void CSSParserValue::setFromNumber(double value, CSSPrimitiveValue::UnitT
ype unit) |
| 188 { | 131 { |
| 189 id = CSSValueInvalid; | 132 id = CSSValueInvalid; |
| 190 isInt = false; | 133 isInt = false; |
| 191 fValue = value; | 134 fValue = value; |
| 192 this->setUnit(std::isfinite(value) ? unit : CSSPrimitiveValue::UnitType::Unk
nown); | 135 this->setUnit(std::isfinite(value) ? unit : CSSPrimitiveValue::UnitType::Unk
nown); |
| 193 } | 136 } |
| 194 | 137 |
| 195 inline void CSSParserValue::setFromOperator(UChar c) | 138 inline void CSSParserValue::setFromOperator(UChar c) |
| 196 { | 139 { |
| 197 id = CSSValueInvalid; | 140 id = CSSValueInvalid; |
| 198 m_unit = Operator; | 141 m_unit = Operator; |
| 199 iValue = c; | 142 iValue = c; |
| 200 isInt = false; | 143 isInt = false; |
| 201 } | 144 } |
| 202 | 145 |
| 203 inline void CSSParserValue::setFromValueList(PassOwnPtr<CSSParserValueList> valu
eList) | 146 inline void CSSParserValue::setFromValueList(PassOwnPtr<CSSParserValueList> valu
eList) |
| 204 { | 147 { |
| 205 id = CSSValueInvalid; | 148 id = CSSValueInvalid; |
| 206 this->valueList = valueList.leakPtr(); | 149 this->valueList = valueList.leakPtr(); |
| 207 m_unit = ValueList; | 150 m_unit = ValueList; |
| 208 isInt = false; | 151 isInt = false; |
| 209 } | 152 } |
| 210 | 153 |
| 211 } | 154 } |
| 212 | 155 |
| 213 #endif | 156 #endif |
| OLD | NEW |