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

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

Issue 279763002: Support a negation pseudo-class, :not(), in <content select> (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Update Created 6 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/css/CSSSelector.cpp ('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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 if (name == selectAttr) { 76 if (name == selectAttr) {
77 if (ShadowRoot* root = containingShadowRoot()) 77 if (ShadowRoot* root = containingShadowRoot())
78 root->owner()->willAffectSelector(); 78 root->owner()->willAffectSelector();
79 m_shouldParseSelect = true; 79 m_shouldParseSelect = true;
80 m_select = value; 80 m_select = value;
81 } else { 81 } else {
82 InsertionPoint::parseAttribute(name, value); 82 InsertionPoint::parseAttribute(name, value);
83 } 83 }
84 } 84 }
85 85
86 static inline bool includesDisallowedPseudoClass(const CSSSelector& selector)
87 {
88 return selector.m_match == CSSSelector::PseudoClass && selector.m_pseudoType != CSSSelector::PseudoNot;
89 }
90
86 bool HTMLContentElement::validateSelect() const 91 bool HTMLContentElement::validateSelect() const
87 { 92 {
88 ASSERT(!m_shouldParseSelect); 93 ASSERT(!m_shouldParseSelect);
89 94
90 if (m_select.isNull() || m_select.isEmpty()) 95 if (m_select.isNull() || m_select.isEmpty())
91 return true; 96 return true;
92 97
93 if (!m_selectorList.isValid()) 98 if (!m_selectorList.isValid())
94 return false; 99 return false;
95 100
96 bool disallowPseudoClasses = !RuntimeEnabledFeatures::pseudoClassesInMatchin gCriteriaInAuthorShadowTreesEnabled() && containingShadowRoot() && containingSha dowRoot()->type() == ShadowRoot::AuthorShadowRoot; 101 bool allowAnyPseudoClasses = RuntimeEnabledFeatures::pseudoClassesInMatching CriteriaInAuthorShadowTreesEnabled() || (containingShadowRoot() && containingSha dowRoot()->type() == ShadowRoot::UserAgentShadowRoot);
97 102
98 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)) {
99 if (!selector->isCompound()) 104 if (!selector->isCompound())
100 return false; 105 return false;
101 if (!disallowPseudoClasses) 106 if (allowAnyPseudoClasses)
102 continue; 107 continue;
103 for (const CSSSelector* subSelector = selector; subSelector; subSelector = subSelector->tagHistory()) { 108 for (const CSSSelector* subSelector = selector; subSelector; subSelector = subSelector->tagHistory()) {
104 if (subSelector->m_match == CSSSelector::PseudoClass) 109 if (includesDisallowedPseudoClass(*subSelector))
105 return false; 110 return false;
106 } 111 }
107 } 112 }
108 return true; 113 return true;
109 } 114 }
110 115
111 static inline bool checkOneSelector(const CSSSelector& selector, const WillBeHea pVector<RawPtrWillBeMember<Node>, 32>& siblings, int nth) 116 static inline bool checkOneSelector(const CSSSelector& selector, const WillBeHea pVector<RawPtrWillBeMember<Node>, 32>& siblings, int nth)
112 { 117 {
113 Element* element = toElement(siblings[nth]); 118 Element* element = toElement(siblings[nth]);
114 SelectorChecker selectorChecker(element->document(), SelectorChecker::Collec tingCSSRules); 119 SelectorChecker selectorChecker(element->document(), SelectorChecker::Collec tingCSSRules);
115 SelectorChecker::SelectorCheckingContext context(selector, element, Selector Checker::VisitedMatchEnabled); 120 SelectorChecker::SelectorCheckingContext context(selector, element, Selector Checker::VisitedMatchEnabled);
116 ShadowDOMSiblingTraversalStrategy strategy(siblings, nth); 121 ShadowDOMSiblingTraversalStrategy strategy(siblings, nth);
117 return selectorChecker.match(context, strategy) == SelectorChecker::Selector Matches; 122 return selectorChecker.match(context, strategy) == SelectorChecker::Selector Matches;
118 } 123 }
119 124
120 bool HTMLContentElement::matchSelector(const WillBeHeapVector<RawPtrWillBeMember <Node>, 32>& siblings, int nth) const 125 bool HTMLContentElement::matchSelector(const WillBeHeapVector<RawPtrWillBeMember <Node>, 32>& siblings, int nth) const
121 { 126 {
122 for (const CSSSelector* selector = selectorList().first(); selector; selecto r = CSSSelectorList::next(*selector)) { 127 for (const CSSSelector* selector = selectorList().first(); selector; selecto r = CSSSelectorList::next(*selector)) {
123 if (checkOneSelector(*selector, siblings, nth)) 128 if (checkOneSelector(*selector, siblings, nth))
124 return true; 129 return true;
125 } 130 }
126 return false; 131 return false;
127 } 132 }
128 133
129 } 134 }
OLDNEW
« no previous file with comments | « Source/core/css/CSSSelector.cpp ('k') | Source/core/testing/InternalSettings.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698