Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(14)

Side by Side Diff: Source/core/css/parser/CSSParserSelector.cpp

Issue 1317743006: Move CSSParserSelector out of CSSParserValues.h/cpp (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Source/core/css/parser/CSSParserSelector.h ('k') | Source/core/css/parser/CSSParserValues.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * Copyright (C) 2003 Lars Knoll (knoll@kde.org)
3 * Copyright (C) 2004, 2005, 2006, 2008 Apple Inc. All rights reserved.
4 *
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.
9 *
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.
14 *
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.
19 */
20
21 #include "config.h"
22 #include "core/css/parser/CSSParserSelector.h"
23
24 #include "core/css/CSSSelectorList.h"
25
26 namespace blink {
27
28 CSSParserSelector::CSSParserSelector()
29 : m_selector(adoptPtr(new CSSSelector()))
30 {
31 }
32
33 CSSParserSelector::CSSParserSelector(const QualifiedName& tagQName, bool isImpli cit)
34 : m_selector(adoptPtr(new CSSSelector(tagQName, isImplicit)))
35 {
36 }
37
38 CSSParserSelector::~CSSParserSelector()
39 {
40 if (!m_tagHistory)
41 return;
42 Vector<OwnPtr<CSSParserSelector>, 16> toDelete;
43 OwnPtr<CSSParserSelector> selector = m_tagHistory.release();
44 while (true) {
45 OwnPtr<CSSParserSelector> next = selector->m_tagHistory.release();
46 toDelete.append(selector.release());
47 if (!next)
48 break;
49 selector = next.release();
50 }
51 }
52
53 void CSSParserSelector::adoptSelectorVector(Vector<OwnPtr<CSSParserSelector>>& s electorVector)
54 {
55 CSSSelectorList* selectorList = new CSSSelectorList();
56 selectorList->adoptSelectorVector(selectorVector);
57 m_selector->setSelectorList(adoptPtr(selectorList));
58 }
59
60 void CSSParserSelector::setSelectorList(PassOwnPtr<CSSSelectorList> selectorList )
61 {
62 m_selector->setSelectorList(selectorList);
63 }
64
65 bool CSSParserSelector::isSimple() const
66 {
67 if (m_selector->selectorList() || m_selector->match() == CSSSelector::Pseudo Element)
68 return false;
69
70 if (!m_tagHistory)
71 return true;
72
73 if (m_selector->match() == CSSSelector::Tag) {
74 // We can't check against anyQName() here because namespace may not be n ullAtom.
75 // Example:
76 // @namespace "http://www.w3.org/2000/svg";
77 // svg:not(:root) { ...
78 if (m_selector->tagQName().localName() == starAtom)
79 return m_tagHistory->isSimple();
80 }
81
82 return false;
83 }
84
85 void CSSParserSelector::insertTagHistory(CSSSelector::Relation before, PassOwnPt r<CSSParserSelector> selector, CSSSelector::Relation after)
86 {
87 if (m_tagHistory)
88 selector->setTagHistory(m_tagHistory.release());
89 setRelation(before);
90 selector->setRelation(after);
91 m_tagHistory = selector;
92 }
93
94 void CSSParserSelector::appendTagHistory(CSSSelector::Relation relation, PassOwn Ptr<CSSParserSelector> selector)
95 {
96 CSSParserSelector* end = this;
97 while (end->tagHistory())
98 end = end->tagHistory();
99 end->setRelation(relation);
100 end->setTagHistory(selector);
101 }
102
103 void CSSParserSelector::prependTagSelector(const QualifiedName& tagQName, bool i sImplicit)
104 {
105 OwnPtr<CSSParserSelector> second = CSSParserSelector::create();
106 second->m_selector = m_selector.release();
107 second->m_tagHistory = m_tagHistory.release();
108 m_tagHistory = second.release();
109 m_selector = adoptPtr(new CSSSelector(tagQName, isImplicit));
110 }
111
112 bool CSSParserSelector::hasHostPseudoSelector() const
113 {
114 for (CSSParserSelector* selector = const_cast<CSSParserSelector*>(this); sel ector; selector = selector->tagHistory()) {
115 if (selector->pseudoType() == CSSSelector::PseudoHost || selector->pseud oType() == CSSSelector::PseudoHostContext)
116 return true;
117 }
118 return false;
119 }
120
121 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/css/parser/CSSParserSelector.h ('k') | Source/core/css/parser/CSSParserValues.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698