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

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

Issue 1418133013: CSS: Reduce style invalidation with sibling combinators (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: use enum Created 5 years, 1 month 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 "config.h" 5 #include "config.h"
6 #include "core/css/RuleFeature.h" 6 #include "core/css/RuleFeature.h"
7 7
8 #include "core/css/CSSSelectorList.h" 8 #include "core/css/CSSSelectorList.h"
9 #include "core/css/RuleSet.h" 9 #include "core/css/RuleSet.h"
10 #include "core/css/StylePropertySet.h" 10 #include "core/css/StylePropertySet.h"
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 { 94 {
95 EXPECT_EQ(0u, invalidationSets.size()); 95 EXPECT_EQ(0u, invalidationSets.size());
96 } 96 }
97 97
98 void expectSelfInvalidation(InvalidationSetVector& invalidationSets) 98 void expectSelfInvalidation(InvalidationSetVector& invalidationSets)
99 { 99 {
100 EXPECT_EQ(1u, invalidationSets.size()); 100 EXPECT_EQ(1u, invalidationSets.size());
101 EXPECT_TRUE(invalidationSets[0]->invalidatesSelf()); 101 EXPECT_TRUE(invalidationSets[0]->invalidatesSelf());
102 } 102 }
103 103
104 void expectNoSelfInvalidation(InvalidationSetVector& invalidationSets)
105 {
106 EXPECT_EQ(1u, invalidationSets.size());
107 EXPECT_FALSE(invalidationSets[0]->invalidatesSelf());
108 }
109
104 void expectClassInvalidation(const AtomicString& className, InvalidationSetV ector& invalidationSets) 110 void expectClassInvalidation(const AtomicString& className, InvalidationSetV ector& invalidationSets)
105 { 111 {
106 EXPECT_EQ(1u, invalidationSets.size()); 112 EXPECT_EQ(1u, invalidationSets.size());
107 HashSet<AtomicString> classes = classSet(*invalidationSets[0]); 113 HashSet<AtomicString> classes = classSet(*invalidationSets[0]);
108 EXPECT_EQ(1u, classes.size()); 114 EXPECT_EQ(1u, classes.size());
109 EXPECT_TRUE(classes.contains(className)); 115 EXPECT_TRUE(classes.contains(className));
110 } 116 }
111 117
112 void expectSiblingInvalidation(unsigned maxDirectAdjacentSelectors, const At omicString& siblingName, InvalidationSetVector& invalidationSets) 118 void expectSiblingInvalidation(unsigned maxDirectAdjacentSelectors, const At omicString& siblingName, InvalidationSetVector& invalidationSets)
113 { 119 {
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 updateInvalidationSets(".o + .p"); 200 updateInvalidationSets(".o + .p");
195 201
196 InvalidationLists invalidationLists; 202 InvalidationLists invalidationLists;
197 collectInvalidationSetsForClass(invalidationLists, "o"); 203 collectInvalidationSetsForClass(invalidationLists, "o");
198 expectNoInvalidation(invalidationLists.descendants); 204 expectNoInvalidation(invalidationLists.descendants);
199 expectSiblingInvalidation(1, "p", invalidationLists.siblings); 205 expectSiblingInvalidation(1, "p", invalidationLists.siblings);
200 } 206 }
201 207
202 TEST_F(RuleFeatureSetTest, interleavedDescendantSibling3) 208 TEST_F(RuleFeatureSetTest, interleavedDescendantSibling3)
203 { 209 {
204 updateInvalidationSets(".n .o + .p"); 210 updateInvalidationSets(".m + .n .o + .p");
205 211
206 InvalidationLists invalidationLists; 212 InvalidationLists invalidationLists;
207 collectInvalidationSetsForClass(invalidationLists, "n"); 213 collectInvalidationSetsForClass(invalidationLists, "n");
214 expectNoSelfInvalidation(invalidationLists.descendants);
208 expectClassInvalidation("p", invalidationLists.descendants); 215 expectClassInvalidation("p", invalidationLists.descendants);
209 expectNoInvalidation(invalidationLists.siblings); 216 expectNoInvalidation(invalidationLists.siblings);
210 } 217 }
211 218
212 TEST_F(RuleFeatureSetTest, interleavedDescendantSibling4) 219 TEST_F(RuleFeatureSetTest, interleavedDescendantSibling4)
213 { 220 {
214 updateInvalidationSets(".m + .n .o + .p"); 221 updateInvalidationSets(".m + .n .o + .p");
215 222
216 InvalidationLists invalidationLists; 223 InvalidationLists invalidationLists;
217 collectInvalidationSetsForClass(invalidationLists, "m"); 224 collectInvalidationSetsForClass(invalidationLists, "m");
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
310 TEST_F(RuleFeatureSetTest, tagName) 317 TEST_F(RuleFeatureSetTest, tagName)
311 { 318 {
312 updateInvalidationSets(":valid e"); 319 updateInvalidationSets(":valid e");
313 320
314 InvalidationLists invalidationLists; 321 InvalidationLists invalidationLists;
315 collectInvalidationSetsForPseudoClass(invalidationLists, CSSSelector::Pseudo Valid); 322 collectInvalidationSetsForPseudoClass(invalidationLists, CSSSelector::Pseudo Valid);
316 expectTagNameInvalidation("e", invalidationLists.descendants); 323 expectTagNameInvalidation("e", invalidationLists.descendants);
317 } 324 }
318 325
319 } // namespace blink 326 } // 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