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

Side by Side Diff: trunk/Source/core/dom/SelectorQuery.cpp

Issue 75463008: Revert 162247 "Revert 162180 "[Refactoring] Remove include "core..." (Closed) Base URL: svn://svn.chromium.org/blink/
Patch Set: Created 7 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « trunk/Source/core/dom/Node.h ('k') | trunk/Source/core/dom/StyleEngine.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011 Apple Inc. All rights reserved. 2 * Copyright (C) 2011 Apple Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 16 matching lines...) Expand all
27 #include "core/dom/SelectorQuery.h" 27 #include "core/dom/SelectorQuery.h"
28 28
29 #include "bindings/v8/ExceptionState.h" 29 #include "bindings/v8/ExceptionState.h"
30 #include "core/css/CSSParser.h" 30 #include "core/css/CSSParser.h"
31 #include "core/css/CSSSelectorList.h" 31 #include "core/css/CSSSelectorList.h"
32 #include "core/css/SelectorChecker.h" 32 #include "core/css/SelectorChecker.h"
33 #include "core/css/SelectorCheckerFastPath.h" 33 #include "core/css/SelectorCheckerFastPath.h"
34 #include "core/css/SiblingTraversalStrategies.h" 34 #include "core/css/SiblingTraversalStrategies.h"
35 #include "core/dom/Document.h" 35 #include "core/dom/Document.h"
36 #include "core/dom/ElementTraversal.h" 36 #include "core/dom/ElementTraversal.h"
37 #include "core/dom/Node.h"
37 #include "core/dom/StaticNodeList.h" 38 #include "core/dom/StaticNodeList.h"
38 39
39 namespace WebCore { 40 namespace WebCore {
40 41
41 class SimpleNodeList { 42 class SimpleNodeList {
42 public: 43 public:
43 virtual ~SimpleNodeList() { } 44 virtual ~SimpleNodeList() { }
44 virtual bool isEmpty() const = 0; 45 virtual bool isEmpty() const = 0;
45 virtual Node* next() = 0; 46 virtual Node* next() = 0;
46 }; 47 };
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 Vector<RefPtr<Node> > result; 173 Vector<RefPtr<Node> > result;
173 executeQueryAll(rootNode, result); 174 executeQueryAll(rootNode, result);
174 return StaticNodeList::adopt(result); 175 return StaticNodeList::adopt(result);
175 } 176 }
176 177
177 PassRefPtr<Element> SelectorDataList::queryFirst(Node& rootNode) const 178 PassRefPtr<Element> SelectorDataList::queryFirst(Node& rootNode) const
178 { 179 {
179 return executeQueryFirst(rootNode); 180 return executeQueryFirst(rootNode);
180 } 181 }
181 182
182 static inline bool isTreeScopeRoot(Node* node)
183 {
184 ASSERT(node);
185 return node->isDocumentNode() || node->isShadowRoot();
186 }
187
188 void SelectorDataList::collectElementsByClassName(Node& rootNode, const AtomicSt ring& className, Vector<RefPtr<Node> >& traversalRoots) const 183 void SelectorDataList::collectElementsByClassName(Node& rootNode, const AtomicSt ring& className, Vector<RefPtr<Node> >& traversalRoots) const
189 { 184 {
190 for (Element* element = ElementTraversal::firstWithin(rootNode); element; el ement = ElementTraversal::next(*element, &rootNode)) { 185 for (Element* element = ElementTraversal::firstWithin(rootNode); element; el ement = ElementTraversal::next(*element, &rootNode)) {
191 if (element->hasClass() && element->classNames().contains(className)) 186 if (element->hasClass() && element->classNames().contains(className))
192 traversalRoots.append(element); 187 traversalRoots.append(element);
193 } 188 }
194 } 189 }
195 190
196 void SelectorDataList::collectElementsByTagName(Node& rootNode, const QualifiedN ame& tagName, Vector<RefPtr<Node> >& traversalRoots) const 191 void SelectorDataList::collectElementsByTagName(Node& rootNode, const QualifiedN ame& tagName, Vector<RefPtr<Node> >& traversalRoots) const
197 { 192 {
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 ASSERT(m_selectors.size() == 1); 246 ASSERT(m_selectors.size() == 1);
252 ASSERT(m_selectors[0].selector); 247 ASSERT(m_selectors[0].selector);
253 248
254 bool isRightmostSelector = true; 249 bool isRightmostSelector = true;
255 bool startFromParent = false; 250 bool startFromParent = false;
256 251
257 for (const CSSSelector* selector = m_selectors[0].selector; selector; select or = selector->tagHistory()) { 252 for (const CSSSelector* selector = m_selectors[0].selector; selector; select or = selector->tagHistory()) {
258 if (selector->m_match == CSSSelector::Id && !rootNode.document().contain sMultipleElementsWithId(selector->value())) { 253 if (selector->m_match == CSSSelector::Id && !rootNode.document().contain sMultipleElementsWithId(selector->value())) {
259 Element* element = rootNode.treeScope().getElementById(selector->val ue()); 254 Element* element = rootNode.treeScope().getElementById(selector->val ue());
260 Node* adjustedNode = &rootNode; 255 Node* adjustedNode = &rootNode;
261 if (element && (isTreeScopeRoot(&rootNode) || element->isDescendantO f(&rootNode))) 256 if (element && (isTreeScopeRoot(rootNode) || element->isDescendantOf (&rootNode)))
262 adjustedNode = element; 257 adjustedNode = element;
263 else if (!element || isRightmostSelector) 258 else if (!element || isRightmostSelector)
264 adjustedNode = 0; 259 adjustedNode = 0;
265 if (isRightmostSelector) { 260 if (isRightmostSelector) {
266 matchTraverseRoots = true; 261 matchTraverseRoots = true;
267 return adoptPtr(new SingleNodeList(adjustedNode)); 262 return adoptPtr(new SingleNodeList(adjustedNode));
268 } 263 }
269 if (startFromParent && adjustedNode) 264 if (startFromParent && adjustedNode)
270 adjustedNode = adjustedNode->parentNode(); 265 adjustedNode = adjustedNode->parentNode();
271 266
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
526 m_entries.add(selectors, selectorQuery.release()); 521 m_entries.add(selectors, selectorQuery.release());
527 return rawSelectorQuery; 522 return rawSelectorQuery;
528 } 523 }
529 524
530 void SelectorQueryCache::invalidate() 525 void SelectorQueryCache::invalidate()
531 { 526 {
532 m_entries.clear(); 527 m_entries.clear();
533 } 528 }
534 529
535 } 530 }
OLDNEW
« no previous file with comments | « trunk/Source/core/dom/Node.h ('k') | trunk/Source/core/dom/StyleEngine.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698