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

Side by Side Diff: third_party/WebKit/Source/core/css/RuleFeatureSetTest.cpp

Issue 1683923003: Don't add siblingRules with combinator left of ::content. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Missing clear Created 4 years, 10 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/RuleFeature.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 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "core/css/RuleFeature.h" 5 #include "core/css/RuleFeature.h"
6 6
7 #include "core/css/CSSSelectorList.h" 7 #include "core/css/CSSSelectorList.h"
8 #include "core/css/RuleSet.h" 8 #include "core/css/RuleSet.h"
9 #include "core/css/StylePropertySet.h" 9 #include "core/css/StylePropertySet.h"
10 #include "core/css/StyleRule.h" 10 #include "core/css/StyleRule.h"
(...skipping 26 matching lines...) Expand all
37 37
38 void updateInvalidationSets(const String& selectorText) 38 void updateInvalidationSets(const String& selectorText)
39 { 39 {
40 CSSSelectorList selectorList = CSSParser::parseSelector(strictCSSParserC ontext(), nullptr, selectorText); 40 CSSSelectorList selectorList = CSSParser::parseSelector(strictCSSParserC ontext(), nullptr, selectorText);
41 41
42 RefPtrWillBeRawPtr<StyleRule> styleRule = StyleRule::create(std::move(se lectorList), MutableStylePropertySet::create(HTMLStandardMode)); 42 RefPtrWillBeRawPtr<StyleRule> styleRule = StyleRule::create(std::move(se lectorList), MutableStylePropertySet::create(HTMLStandardMode));
43 RuleData ruleData(styleRule.get(), 0, 0, RuleHasNoSpecialState); 43 RuleData ruleData(styleRule.get(), 0, 0, RuleHasNoSpecialState);
44 m_ruleFeatureSet.updateInvalidationSets(ruleData); 44 m_ruleFeatureSet.updateInvalidationSets(ruleData);
45 } 45 }
46 46
47 void collectFeatures(const String& selectorText)
48 {
49 CSSSelectorList selectorList = CSSParser::parseSelector(strictCSSParserC ontext(), nullptr, selectorText);
50
51 RefPtrWillBeRawPtr<StyleRule> styleRule = StyleRule::create(std::move(se lectorList), MutableStylePropertySet::create(HTMLStandardMode));
52 RuleData ruleData(styleRule.get(), 0, 0, RuleHasNoSpecialState);
53 m_ruleFeatureSet.collectFeaturesFromRuleData(ruleData);
54 }
55
47 void collectInvalidationSetsForClass(InvalidationLists& invalidationLists, c onst AtomicString& className) const 56 void collectInvalidationSetsForClass(InvalidationLists& invalidationLists, c onst AtomicString& className) const
48 { 57 {
49 Element* element = Traversal<HTMLElement>::firstChild(*Traversal<HTMLEle ment>::firstChild(*m_document->body())); 58 Element* element = Traversal<HTMLElement>::firstChild(*Traversal<HTMLEle ment>::firstChild(*m_document->body()));
50 m_ruleFeatureSet.collectInvalidationSetsForClass(invalidationLists, *ele ment, className); 59 m_ruleFeatureSet.collectInvalidationSetsForClass(invalidationLists, *ele ment, className);
51 } 60 }
52 61
53 void collectInvalidationSetsForId(InvalidationLists& invalidationLists, cons t AtomicString& id) const 62 void collectInvalidationSetsForId(InvalidationLists& invalidationLists, cons t AtomicString& id) const
54 { 63 {
55 Element* element = Traversal<HTMLElement>::firstChild(*Traversal<HTMLEle ment>::firstChild(*m_document->body())); 64 Element* element = Traversal<HTMLElement>::firstChild(*Traversal<HTMLEle ment>::firstChild(*m_document->body()));
56 m_ruleFeatureSet.collectInvalidationSetsForId(invalidationLists, *elemen t, id); 65 m_ruleFeatureSet.collectInvalidationSetsForId(invalidationLists, *elemen t, id);
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 } 172 }
164 173
165 void expectAttributeInvalidation(const AtomicString& attribute, Invalidation SetVector& invalidationSets) 174 void expectAttributeInvalidation(const AtomicString& attribute, Invalidation SetVector& invalidationSets)
166 { 175 {
167 EXPECT_EQ(1u, invalidationSets.size()); 176 EXPECT_EQ(1u, invalidationSets.size());
168 HashSet<AtomicString> attributes = attributeSet(*invalidationSets[0]); 177 HashSet<AtomicString> attributes = attributeSet(*invalidationSets[0]);
169 EXPECT_EQ(1u, attributes.size()); 178 EXPECT_EQ(1u, attributes.size());
170 EXPECT_TRUE(attributes.contains(attribute)); 179 EXPECT_TRUE(attributes.contains(attribute));
171 } 180 }
172 181
182 void expectSiblingRuleCount(unsigned count)
183 {
184 EXPECT_EQ(count, m_ruleFeatureSet.siblingRules.size());
185 }
186
173 DEFINE_INLINE_TRACE() 187 DEFINE_INLINE_TRACE()
174 { 188 {
175 #if ENABLE(OILPAN) 189 #if ENABLE(OILPAN)
176 visitor->trace(m_ruleFeatureSet); 190 visitor->trace(m_ruleFeatureSet);
177 visitor->trace(m_document); 191 visitor->trace(m_document);
178 #endif 192 #endif
179 } 193 }
180 194
181 private: 195 private:
182 RuleFeatureSet m_ruleFeatureSet; 196 RuleFeatureSet m_ruleFeatureSet;
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 collectInvalidationSetsForClass(invalidationLists, "a"); 344 collectInvalidationSetsForClass(invalidationLists, "a");
331 expectClassInvalidation("c", invalidationLists.descendants); 345 expectClassInvalidation("c", invalidationLists.descendants);
332 346
333 updateInvalidationSets(".a .b"); 347 updateInvalidationSets(".a .b");
334 348
335 invalidationLists.descendants.clear(); 349 invalidationLists.descendants.clear();
336 collectInvalidationSetsForClass(invalidationLists, "a"); 350 collectInvalidationSetsForClass(invalidationLists, "a");
337 expectClassesInvalidation("b", "c", invalidationLists.descendants); 351 expectClassesInvalidation("b", "c", invalidationLists.descendants);
338 } 352 }
339 353
354 TEST_F(RuleFeatureSetTest, siblingRulesBeforeContentPseudo)
355 {
356 collectFeatures("a + b ::content .c");
357 expectSiblingRuleCount(0);
358 }
359
360 TEST_F(RuleFeatureSetTest, siblingRulesAfterContentPseudo)
361 {
362 collectFeatures(".a ::content .b + .c");
363 expectSiblingRuleCount(1);
364 }
365
366 TEST_F(RuleFeatureSetTest, siblingRulesNthBeforeContentPseudo)
367 {
368 collectFeatures(":nth-child(2) ::content .a");
369 expectSiblingRuleCount(0);
370 }
371
372 TEST_F(RuleFeatureSetTest, siblingRulesNthAfterContentPseudo)
373 {
374 collectFeatures(".a ::content :nth-child(2)");
375 expectSiblingRuleCount(1);
376 }
377
378 TEST_F(RuleFeatureSetTest, siblingRulesBeforeDeep)
379 {
380 collectFeatures("a + b /deep/ .c");
381 expectSiblingRuleCount(1);
382 }
383
384 TEST_F(RuleFeatureSetTest, siblingRulesAfterDeep)
385 {
386 collectFeatures(".a /deep/ .b + .c");
387 expectSiblingRuleCount(1);
388 }
389
390 TEST_F(RuleFeatureSetTest, siblingRulesBeforeShadow)
391 {
392 collectFeatures(".a + .b::shadow .c");
393 expectSiblingRuleCount(1);
394 }
395
396 TEST_F(RuleFeatureSetTest, siblingRulesAfterShadow)
397 {
398 collectFeatures(".a ::shadow .b + .c");
399 expectSiblingRuleCount(1);
400 }
401
402 TEST_F(RuleFeatureSetTest, siblingRulesBeforeSlotted)
403 {
404 collectFeatures(".a + ::slotted(.b)");
405 expectSiblingRuleCount(1);
406 }
407
340 } // namespace blink 408 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/css/RuleFeature.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698