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

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: wip Created 4 years, 8 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 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 void SelectorDataList::findTraverseRootsAndExecute(ContainerNode& rootNode, type name SelectorQueryTrait::OutputType& output) const 254 void SelectorDataList::findTraverseRootsAndExecute(ContainerNode& rootNode, type name SelectorQueryTrait::OutputType& output) const
255 { 255 {
256 // We need to return the matches in document order. To use id lookup while t here is possiblity of multiple matches 256 // We need to return the matches in document order. To use id lookup while t here is possiblity of multiple matches
257 // we would need to sort the results. For now, just traverse the document in that case. 257 // we would need to sort the results. For now, just traverse the document in that case.
258 DCHECK_EQ(m_selectors.size(), 1u); 258 DCHECK_EQ(m_selectors.size(), 1u);
259 259
260 bool isRightmostSelector = true; 260 bool isRightmostSelector = true;
261 bool startFromParent = false; 261 bool startFromParent = false;
262 262
263 for (const CSSSelector* selector = m_selectors[0]; selector; selector = sele ctor->tagHistory()) { 263 for (const CSSSelector* selector = m_selectors[0]; selector; selector = sele ctor->tagHistory()) {
264 if (selector->match() == CSSSelector::Id && !rootNode.document().contain sMultipleElementsWithId(selector->value())) { 264 if (selector->match() == CSSSelector::Id && rootNode.isInTreeScope() && !rootNode.rootTreeScope().containsMultipleElementsWithId(selector->value())) {
hayato 2016/04/14 07:29:58 Using document() here looks a bug to me.
rune 2016/04/14 08:48:01 Yes. Perhaps fix that in a separate CL. Reported
265 Element* element = rootNode.treeScope().getElementById(selector->val ue()); 265 Element* element = rootNode.rootTreeScope().getElementById(selector- >value());
266 ContainerNode* adjustedNode = &rootNode; 266 ContainerNode* adjustedNode = &rootNode;
267 if (element && (isTreeScopeRoot(rootNode) || element->isDescendantOf (&rootNode))) 267 if (element && (isTreeScopeRoot(rootNode) || element->isDescendantOf (&rootNode)))
268 adjustedNode = element; 268 adjustedNode = element;
269 else if (!element || isRightmostSelector) 269 else if (!element || isRightmostSelector)
270 adjustedNode = nullptr; 270 adjustedNode = nullptr;
271 if (isRightmostSelector) { 271 if (isRightmostSelector) {
272 executeForTraverseRoot<SelectorQueryTrait>(*m_selectors[0], adju stedNode, MatchesTraverseRoots, rootNode, output); 272 executeForTraverseRoot<SelectorQueryTrait>(*m_selectors[0], adju stedNode, MatchesTraverseRoots, rootNode, output);
273 return; 273 return;
274 } 274 }
275 275
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
570 570
571 return m_entries.add(selectors, SelectorQuery::adopt(std::move(selectorList) )).storedValue->value.get(); 571 return m_entries.add(selectors, SelectorQuery::adopt(std::move(selectorList) )).storedValue->value.get();
572 } 572 }
573 573
574 void SelectorQueryCache::invalidate() 574 void SelectorQueryCache::invalidate()
575 { 575 {
576 m_entries.clear(); 576 m_entries.clear();
577 } 577 }
578 578
579 } // namespace blink 579 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/dom/Node.cpp ('k') | third_party/WebKit/Source/core/page/FocusController.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698