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

Side by Side Diff: Source/core/html/HTMLContentElement.cpp

Issue 1129673002: Remove support for pseudo classes in <content select>. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fix more tests. Created 5 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/html/HTMLContentElement.h ('k') | Source/core/testing/InternalSettings.h » ('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 Google Inc. All rights reserved. 2 * Copyright (C) 2011 Google 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 are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * 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 * * Neither the name of Google Inc. nor the names of its 10 * * Neither the name of Google Inc. nor the names of its
(...skipping 11 matching lines...) Expand all
22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 */ 25 */
26 26
27 #include "config.h" 27 #include "config.h"
28 #include "core/html/HTMLContentElement.h" 28 #include "core/html/HTMLContentElement.h"
29 29
30 #include "core/HTMLNames.h" 30 #include "core/HTMLNames.h"
31 #include "core/css/SelectorChecker.h" 31 #include "core/css/SelectorChecker.h"
32 #include "core/css/SiblingTraversalStrategies.h"
33 #include "core/css/parser/CSSParser.h" 32 #include "core/css/parser/CSSParser.h"
34 #include "core/dom/QualifiedName.h" 33 #include "core/dom/QualifiedName.h"
35 #include "core/dom/shadow/ElementShadow.h" 34 #include "core/dom/shadow/ElementShadow.h"
36 #include "core/dom/shadow/ShadowRoot.h" 35 #include "core/dom/shadow/ShadowRoot.h"
37 #include "platform/RuntimeEnabledFeatures.h" 36 #include "platform/RuntimeEnabledFeatures.h"
38 37
39 namespace blink { 38 namespace blink {
40 39
41 using namespace HTMLNames; 40 using namespace HTMLNames;
42 41
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 bool HTMLContentElement::validateSelect() const 93 bool HTMLContentElement::validateSelect() const
95 { 94 {
96 ASSERT(!m_shouldParseSelect); 95 ASSERT(!m_shouldParseSelect);
97 96
98 if (m_select.isNull() || m_select.isEmpty()) 97 if (m_select.isNull() || m_select.isEmpty())
99 return true; 98 return true;
100 99
101 if (!m_selectorList.isValid()) 100 if (!m_selectorList.isValid())
102 return false; 101 return false;
103 102
104 bool allowAnyPseudoClasses = RuntimeEnabledFeatures::pseudoClassesInMatching CriteriaInAuthorShadowTreesEnabled() || (containingShadowRoot() && containingSha dowRoot()->type() == ShadowRoot::UserAgentShadowRoot);
105
106 for (const CSSSelector* selector = m_selectorList.first(); selector; selecto r = m_selectorList.next(*selector)) { 103 for (const CSSSelector* selector = m_selectorList.first(); selector; selecto r = m_selectorList.next(*selector)) {
107 if (!selector->isCompound()) 104 if (!selector->isCompound())
108 return false; 105 return false;
109 if (allowAnyPseudoClasses)
110 continue;
111 for (const CSSSelector* subSelector = selector; subSelector; subSelector = subSelector->tagHistory()) { 106 for (const CSSSelector* subSelector = selector; subSelector; subSelector = subSelector->tagHistory()) {
112 if (includesDisallowedPseudoClass(*subSelector)) 107 if (includesDisallowedPseudoClass(*subSelector))
113 return false; 108 return false;
114 } 109 }
115 } 110 }
116 return true; 111 return true;
117 } 112 }
118 113
119 static inline bool checkOneSelector(const CSSSelector& selector, const WillBeHea pVector<RawPtrWillBeMember<Node>, 32>& siblings, int nth) 114 // TODO(esprehn): element should really be const, but matching a selector is not
115 // const for some SelectorCheckingModes (mainly ResolvingStyle) where it sets
116 // dynamic restyle flags on elements.
117 bool HTMLContentElement::matchSelector(Element& element) const
120 { 118 {
121 Element* element = toElement(siblings[nth]);
122 SelectorChecker selectorChecker(SelectorChecker::QueryingRules); 119 SelectorChecker selectorChecker(SelectorChecker::QueryingRules);
123 SelectorChecker::SelectorCheckingContext context(selector, element, Selector Checker::VisitedMatchEnabled);
124 ShadowDOMSiblingTraversalStrategy strategy(siblings, nth);
125 return selectorChecker.match(context, strategy) == SelectorChecker::Selector Matches;
126 }
127
128 bool HTMLContentElement::matchSelector(const WillBeHeapVector<RawPtrWillBeMember <Node>, 32>& siblings, int nth) const
129 {
130 for (const CSSSelector* selector = selectorList().first(); selector; selecto r = CSSSelectorList::next(*selector)) { 120 for (const CSSSelector* selector = selectorList().first(); selector; selecto r = CSSSelectorList::next(*selector)) {
131 if (checkOneSelector(*selector, siblings, nth)) 121 SelectorChecker::SelectorCheckingContext context(*selector, &element, Se lectorChecker::VisitedMatchDisabled);
esprehn 2015/05/06 23:57:52 I also switched this to VisitedMatchDisabled. Sinc
122 if (selectorChecker.match(context) == SelectorChecker::SelectorMatches)
132 return true; 123 return true;
133 } 124 }
134 return false; 125 return false;
135 } 126 }
136 127
137 } 128 }
OLDNEW
« no previous file with comments | « Source/core/html/HTMLContentElement.h ('k') | Source/core/testing/InternalSettings.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698