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

Side by Side Diff: third_party/WebKit/Source/core/dom/SelectorQuery.cpp

Issue 1883083002: Introduce Node::containingTreeScope(), which asserts that the node's root is a tree scope (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: renamed Created 4 years, 6 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011, 2013 Apple Inc. All rights reserved. 2 * Copyright (C) 2011, 2013 Apple Inc. All rights reserved.
3 * Copyright (C) 2014 Samsung Electronics. All rights reserved. 3 * Copyright (C) 2014 Samsung Electronics. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 8 *
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 void SelectorDataList::findTraverseRootsAndExecute(ContainerNode& rootNode, type name SelectorQueryTrait::OutputType& output) const 252 void SelectorDataList::findTraverseRootsAndExecute(ContainerNode& rootNode, type name SelectorQueryTrait::OutputType& output) const
253 { 253 {
254 // We need to return the matches in document order. To use id lookup while t here is possiblity of multiple matches 254 // We need to return the matches in document order. To use id lookup while t here is possiblity of multiple matches
255 // we would need to sort the results. For now, just traverse the document in that case. 255 // we would need to sort the results. For now, just traverse the document in that case.
256 DCHECK_EQ(m_selectors.size(), 1u); 256 DCHECK_EQ(m_selectors.size(), 1u);
257 257
258 bool isRightmostSelector = true; 258 bool isRightmostSelector = true;
259 bool startFromParent = false; 259 bool startFromParent = false;
260 260
261 for (const CSSSelector* selector = m_selectors[0]; selector; selector = sele ctor->tagHistory()) { 261 for (const CSSSelector* selector = m_selectors[0]; selector; selector = sele ctor->tagHistory()) {
262 if (selector->match() == CSSSelector::Id && !rootNode.treeScope().contai nsMultipleElementsWithId(selector->value())) { 262 if (selector->match() == CSSSelector::Id && rootNode.isInTreeScope() && !rootNode.containingTreeScope().containsMultipleElementsWithId(selector->value() )) {
263 Element* element = rootNode.treeScope().getElementById(selector->val ue()); 263 Element* element = rootNode.containingTreeScope().getElementById(sel ector->value());
264 ContainerNode* adjustedNode = &rootNode; 264 ContainerNode* adjustedNode = &rootNode;
265 if (element && (isTreeScopeRoot(rootNode) || element->isDescendantOf (&rootNode))) 265 if (element && (isTreeScopeRoot(rootNode) || element->isDescendantOf (&rootNode)))
266 adjustedNode = element; 266 adjustedNode = element;
267 else if (!element || isRightmostSelector) 267 else if (!element || isRightmostSelector)
268 adjustedNode = nullptr; 268 adjustedNode = nullptr;
269 if (isRightmostSelector) { 269 if (isRightmostSelector) {
270 executeForTraverseRoot<SelectorQueryTrait>(*m_selectors[0], adju stedNode, MatchesTraverseRoots, rootNode, output); 270 executeForTraverseRoot<SelectorQueryTrait>(*m_selectors[0], adju stedNode, MatchesTraverseRoots, rootNode, output);
271 return; 271 return;
272 } 272 }
273 273
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after
575 575
576 return m_entries.add(selectors, SelectorQuery::adopt(std::move(selectorList) )).storedValue->value.get(); 576 return m_entries.add(selectors, SelectorQuery::adopt(std::move(selectorList) )).storedValue->value.get();
577 } 577 }
578 578
579 void SelectorQueryCache::invalidate() 579 void SelectorQueryCache::invalidate()
580 { 580 {
581 m_entries.clear(); 581 m_entries.clear();
582 } 582 }
583 583
584 } // namespace blink 584 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/dom/Node.cpp ('k') | third_party/WebKit/Source/core/html/HTMLAnchorElement.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698