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 Apple Inc. All rights reserved. | 3 * Copyright (C) 2004, 2005, 2006, 2008 Apple Inc. All rights reserved. |
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 #include "config.h" | 21 #include "config.h" |
22 #include "core/css/parser/CSSParserValues.h" | 22 #include "core/css/parser/CSSParserValues.h" |
23 | 23 |
24 #include "core/css/CSSFunctionValue.h" | 24 #include "core/css/CSSFunctionValue.h" |
25 #include "core/css/CSSSelectorList.h" | |
26 #include "core/css/parser/CSSParserToken.h" | 25 #include "core/css/parser/CSSParserToken.h" |
27 #include "core/css/parser/CSSParserTokenRange.h" | 26 #include "core/css/parser/CSSParserTokenRange.h" |
28 #include "core/css/parser/CSSPropertyParser.h" | 27 #include "core/css/parser/CSSPropertyParser.h" |
29 #include "core/html/parser/HTMLParserIdioms.h" | 28 #include "core/html/parser/HTMLParserIdioms.h" |
30 | 29 |
31 namespace blink { | 30 namespace blink { |
32 | 31 |
33 using namespace WTF; | 32 using namespace WTF; |
34 | 33 |
35 CSSParserValueList::CSSParserValueList(CSSParserTokenRange range) | 34 CSSParserValueList::CSSParserValueList(CSSParserTokenRange range) |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
248 CSSParserValueList::~CSSParserValueList() | 247 CSSParserValueList::~CSSParserValueList() |
249 { | 248 { |
250 destroy(m_values); | 249 destroy(m_values); |
251 } | 250 } |
252 | 251 |
253 void CSSParserValueList::addValue(const CSSParserValue& v) | 252 void CSSParserValueList::addValue(const CSSParserValue& v) |
254 { | 253 { |
255 m_values.append(v); | 254 m_values.append(v); |
256 } | 255 } |
257 | 256 |
258 CSSParserSelector::CSSParserSelector() | |
259 : m_selector(adoptPtr(new CSSSelector())) | |
260 { | |
261 } | |
262 | |
263 CSSParserSelector::CSSParserSelector(const QualifiedName& tagQName, bool isImpli
cit) | |
264 : m_selector(adoptPtr(new CSSSelector(tagQName, isImplicit))) | |
265 { | |
266 } | |
267 | |
268 CSSParserSelector::~CSSParserSelector() | |
269 { | |
270 if (!m_tagHistory) | |
271 return; | |
272 Vector<OwnPtr<CSSParserSelector>, 16> toDelete; | |
273 OwnPtr<CSSParserSelector> selector = m_tagHistory.release(); | |
274 while (true) { | |
275 OwnPtr<CSSParserSelector> next = selector->m_tagHistory.release(); | |
276 toDelete.append(selector.release()); | |
277 if (!next) | |
278 break; | |
279 selector = next.release(); | |
280 } | |
281 } | |
282 | |
283 void CSSParserSelector::adoptSelectorVector(Vector<OwnPtr<CSSParserSelector>>& s
electorVector) | |
284 { | |
285 CSSSelectorList* selectorList = new CSSSelectorList(); | |
286 selectorList->adoptSelectorVector(selectorVector); | |
287 m_selector->setSelectorList(adoptPtr(selectorList)); | |
288 } | |
289 | |
290 void CSSParserSelector::setSelectorList(PassOwnPtr<CSSSelectorList> selectorList
) | |
291 { | |
292 m_selector->setSelectorList(selectorList); | |
293 } | |
294 | |
295 bool CSSParserSelector::isSimple() const | |
296 { | |
297 if (m_selector->selectorList() || m_selector->match() == CSSSelector::Pseudo
Element) | |
298 return false; | |
299 | |
300 if (!m_tagHistory) | |
301 return true; | |
302 | |
303 if (m_selector->match() == CSSSelector::Tag) { | |
304 // We can't check against anyQName() here because namespace may not be n
ullAtom. | |
305 // Example: | |
306 // @namespace "http://www.w3.org/2000/svg"; | |
307 // svg:not(:root) { ... | |
308 if (m_selector->tagQName().localName() == starAtom) | |
309 return m_tagHistory->isSimple(); | |
310 } | |
311 | |
312 return false; | |
313 } | |
314 | |
315 void CSSParserSelector::insertTagHistory(CSSSelector::Relation before, PassOwnPt
r<CSSParserSelector> selector, CSSSelector::Relation after) | |
316 { | |
317 if (m_tagHistory) | |
318 selector->setTagHistory(m_tagHistory.release()); | |
319 setRelation(before); | |
320 selector->setRelation(after); | |
321 m_tagHistory = selector; | |
322 } | |
323 | |
324 void CSSParserSelector::appendTagHistory(CSSSelector::Relation relation, PassOwn
Ptr<CSSParserSelector> selector) | |
325 { | |
326 CSSParserSelector* end = this; | |
327 while (end->tagHistory()) | |
328 end = end->tagHistory(); | |
329 end->setRelation(relation); | |
330 end->setTagHistory(selector); | |
331 } | |
332 | |
333 void CSSParserSelector::prependTagSelector(const QualifiedName& tagQName, bool i
sImplicit) | |
334 { | |
335 OwnPtr<CSSParserSelector> second = CSSParserSelector::create(); | |
336 second->m_selector = m_selector.release(); | |
337 second->m_tagHistory = m_tagHistory.release(); | |
338 m_tagHistory = second.release(); | |
339 m_selector = adoptPtr(new CSSSelector(tagQName, isImplicit)); | |
340 } | |
341 | |
342 bool CSSParserSelector::hasHostPseudoSelector() const | |
343 { | |
344 for (CSSParserSelector* selector = const_cast<CSSParserSelector*>(this); sel
ector; selector = selector->tagHistory()) { | |
345 if (selector->pseudoType() == CSSSelector::PseudoHost || selector->pseud
oType() == CSSSelector::PseudoHostContext) | |
346 return true; | |
347 } | |
348 return false; | |
349 } | |
350 | |
351 } // namespace blink | 257 } // namespace blink |
OLD | NEW |