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

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

Issue 1796573005: Do not show deprecation message for ::shadow and /deep/ on querySelector (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix layout test expectation Created 4 years, 9 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 | « third_party/WebKit/Source/core/css/SelectorChecker.cpp ('k') | no next file » | 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, 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 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 m_selectors.uncheckedAppend(selector); 115 m_selectors.uncheckedAppend(selector);
116 m_usesDeepCombinatorOrShadowPseudo |= selectorList.selectorUsesDeepCombi natorOrShadowPseudo(index); 116 m_usesDeepCombinatorOrShadowPseudo |= selectorList.selectorUsesDeepCombi natorOrShadowPseudo(index);
117 m_needsUpdatedDistribution |= selectorList.selectorNeedsUpdatedDistribut ion(index); 117 m_needsUpdatedDistribution |= selectorList.selectorNeedsUpdatedDistribut ion(index);
118 } 118 }
119 } 119 }
120 120
121 inline bool SelectorDataList::selectorMatches(const CSSSelector& selector, Eleme nt& element, const ContainerNode& rootNode) const 121 inline bool SelectorDataList::selectorMatches(const CSSSelector& selector, Eleme nt& element, const ContainerNode& rootNode) const
122 { 122 {
123 SelectorChecker::Init init; 123 SelectorChecker::Init init;
124 init.mode = SelectorChecker::QueryingRules; 124 init.mode = SelectorChecker::QueryingRules;
125 init.isQuerySelector = true;
125 SelectorChecker checker(init); 126 SelectorChecker checker(init);
126 SelectorChecker::SelectorCheckingContext context(&element, SelectorChecker:: VisitedMatchDisabled); 127 SelectorChecker::SelectorCheckingContext context(&element, SelectorChecker:: VisitedMatchDisabled);
127 context.selector = &selector; 128 context.selector = &selector;
128 context.scope = &rootNode; 129 context.scope = &rootNode;
129 return checker.match(context); 130 return checker.match(context);
130 } 131 }
131 132
132 bool SelectorDataList::matches(Element& targetElement) const 133 bool SelectorDataList::matches(Element& targetElement) const
133 { 134 {
134 if (m_needsUpdatedDistribution) 135 if (m_needsUpdatedDistribution)
135 targetElement.updateDistribution(); 136 targetElement.updateDistribution();
136 137
137 unsigned selectorCount = m_selectors.size(); 138 unsigned selectorCount = m_selectors.size();
138 for (unsigned i = 0; i < selectorCount; ++i) { 139 for (unsigned i = 0; i < selectorCount; ++i) {
139 if (selectorMatches(*m_selectors[i], targetElement, targetElement)) 140 if (selectorMatches(*m_selectors[i], targetElement, targetElement))
140 return true; 141 return true;
141 } 142 }
142 143
143 return false; 144 return false;
144 } 145 }
145 146
146 Element* SelectorDataList::closest(Element& targetElement) const 147 Element* SelectorDataList::closest(Element& targetElement) const
147 { 148 {
148 unsigned selectorCount = m_selectors.size(); 149 unsigned selectorCount = m_selectors.size();
149 if (!selectorCount) 150 if (!selectorCount)
150 return nullptr; 151 return nullptr;
151
152 if (m_needsUpdatedDistribution) 152 if (m_needsUpdatedDistribution)
153 targetElement.updateDistribution(); 153 targetElement.updateDistribution();
154 154
155 for (Element* currentElement = &targetElement; currentElement; currentElemen t = currentElement->parentElement()) { 155 for (Element* currentElement = &targetElement; currentElement; currentElemen t = currentElement->parentElement()) {
156 for (unsigned i = 0; i < selectorCount; ++i) { 156 for (unsigned i = 0; i < selectorCount; ++i) {
157 if (selectorMatches(*m_selectors[i], *currentElement, targetElement) ) 157 if (selectorMatches(*m_selectors[i], *currentElement, targetElement) )
158 return currentElement; 158 return currentElement;
159 } 159 }
160 } 160 }
161 return nullptr; 161 return nullptr;
(...skipping 408 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/css/SelectorChecker.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698