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

Unified Diff: third_party/WebKit/Source/core/css/RuleFeatureSetTest.cpp

Issue 2235723002: Use invalidation sets for nth invalidations. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Comment ::before/::after Created 4 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/css/RuleFeatureSetTest.cpp
diff --git a/third_party/WebKit/Source/core/css/RuleFeatureSetTest.cpp b/third_party/WebKit/Source/core/css/RuleFeatureSetTest.cpp
index 1bc908ff9a84757ae48d8b5ce72a66daa671279f..4afd7ba6ee4116a8d6dc54f62ca28c765b28438e 100644
--- a/third_party/WebKit/Source/core/css/RuleFeatureSetTest.cpp
+++ b/third_party/WebKit/Source/core/css/RuleFeatureSetTest.cpp
@@ -114,6 +114,11 @@ public:
m_ruleFeatureSet->collectUniversalSiblingInvalidationSet(invalidationLists, 1);
}
+ void collectNthInvalidationSet(InvalidationLists& invalidationLists)
+ {
+ m_ruleFeatureSet->collectNthInvalidationSet(invalidationLists);
+ }
+
const HashSet<AtomicString>& classSet(const InvalidationSet& invalidationSet)
{
return invalidationSet.classSetForTesting();
@@ -151,6 +156,12 @@ public:
EXPECT_FALSE(invalidationSets[0]->invalidatesSelf());
}
+ void expectWholeSubtreeInvalidation(InvalidationSetVector& invalidationSets)
+ {
+ EXPECT_EQ(1u, invalidationSets.size());
+ EXPECT_TRUE(invalidationSets[0]->wholeSubtreeInvalid());
+ }
+
void expectClassInvalidation(const AtomicString& className, InvalidationSetVector& invalidationSets)
{
EXPECT_EQ(1u, invalidationSets.size());
@@ -723,4 +734,138 @@ TEST_F(RuleFeatureSetTest, nonUniversalSiblingInvalidationLink)
expectNoInvalidation(invalidationLists.siblings);
}
+TEST_F(RuleFeatureSetTest, nthInvalidationUniversal)
+{
+ EXPECT_EQ(RuleFeatureSet::SelectorMayMatch, collectFeatures(":nth-child(2n)"));
+
+ InvalidationLists invalidationLists;
+ collectNthInvalidationSet(invalidationLists);
+
+ expectNoSelfInvalidation(invalidationLists.descendants);
+ expectWholeSubtreeInvalidation(invalidationLists.descendants);
+}
+
+TEST_F(RuleFeatureSetTest, nthInvalidationClass)
+{
+ EXPECT_EQ(RuleFeatureSet::SelectorMayMatch, collectFeatures(".a:nth-child(2n)"));
+
+ InvalidationLists invalidationLists;
+ collectNthInvalidationSet(invalidationLists);
+
+ expectNoSelfInvalidation(invalidationLists.descendants);
+ expectClassInvalidation("a", invalidationLists.descendants);
+}
+
+TEST_F(RuleFeatureSetTest, nthInvalidationUniversalDescendant)
+{
+ EXPECT_EQ(RuleFeatureSet::SelectorMayMatch, collectFeatures(":nth-child(2n) *"));
+
+ InvalidationLists invalidationLists;
+ collectNthInvalidationSet(invalidationLists);
+
+ expectNoSelfInvalidation(invalidationLists.descendants);
+ expectWholeSubtreeInvalidation(invalidationLists.descendants);
+}
+
+TEST_F(RuleFeatureSetTest, nthInvalidationDescendant)
+{
+ EXPECT_EQ(RuleFeatureSet::SelectorMayMatch, collectFeatures(":nth-child(2n) .a"));
+
+ InvalidationLists invalidationLists;
+ collectNthInvalidationSet(invalidationLists);
+
+ expectNoSelfInvalidation(invalidationLists.descendants);
+ expectClassInvalidation("a", invalidationLists.descendants);
+}
+
+TEST_F(RuleFeatureSetTest, nthInvalidationSibling)
+{
+ EXPECT_EQ(RuleFeatureSet::SelectorMayMatch, collectFeatures(":nth-child(2n) + .a"));
+
+ InvalidationLists invalidationLists;
+ collectNthInvalidationSet(invalidationLists);
+
+ expectNoInvalidation(invalidationLists.siblings);
+ expectNoSelfInvalidation(invalidationLists.descendants);
+ expectClassInvalidation("a", invalidationLists.descendants);
+}
+
+TEST_F(RuleFeatureSetTest, nthInvalidationSiblingDescendant)
+{
+ EXPECT_EQ(RuleFeatureSet::SelectorMayMatch, collectFeatures(":nth-child(2n) + .a .b"));
+
+ InvalidationLists invalidationLists;
+ collectNthInvalidationSet(invalidationLists);
+
+ expectNoInvalidation(invalidationLists.siblings);
+ expectNoSelfInvalidation(invalidationLists.descendants);
+ expectClassInvalidation("b", invalidationLists.descendants);
+}
+
+TEST_F(RuleFeatureSetTest, nthInvalidationNot)
+{
+ EXPECT_EQ(RuleFeatureSet::SelectorMayMatch, collectFeatures(":not(:nth-child(2n))"));
+
+ InvalidationLists invalidationLists;
+ collectNthInvalidationSet(invalidationLists);
+
+ expectNoSelfInvalidation(invalidationLists.descendants);
+ expectWholeSubtreeInvalidation(invalidationLists.descendants);
+}
+
+TEST_F(RuleFeatureSetTest, nthInvalidationNotClass)
+{
+ EXPECT_EQ(RuleFeatureSet::SelectorMayMatch, collectFeatures(".a:not(:nth-child(2n))"));
+
+ InvalidationLists invalidationLists;
+ collectNthInvalidationSet(invalidationLists);
+
+ expectNoSelfInvalidation(invalidationLists.descendants);
+ expectClassInvalidation("a", invalidationLists.descendants);
+}
+
+TEST_F(RuleFeatureSetTest, nthInvalidationNotDescendant)
+{
+ EXPECT_EQ(RuleFeatureSet::SelectorMayMatch, collectFeatures(".blah:not(:nth-child(2n)) .a"));
+
+ InvalidationLists invalidationLists;
+ collectNthInvalidationSet(invalidationLists);
+
+ expectNoSelfInvalidation(invalidationLists.descendants);
+ expectClassInvalidation("a", invalidationLists.descendants);
+}
+
+TEST_F(RuleFeatureSetTest, nthInvalidationAny)
+{
+ EXPECT_EQ(RuleFeatureSet::SelectorMayMatch, collectFeatures(":-webkit-any(#nomatch, :nth-child(2n))"));
+
+ InvalidationLists invalidationLists;
+ collectNthInvalidationSet(invalidationLists);
+
+ expectNoSelfInvalidation(invalidationLists.descendants);
+ expectWholeSubtreeInvalidation(invalidationLists.descendants);
+}
+
+TEST_F(RuleFeatureSetTest, nthInvalidationAnyClass)
+{
+ EXPECT_EQ(RuleFeatureSet::SelectorMayMatch, collectFeatures(".a:-webkit-any(#nomatch, :nth-child(2n))"));
+
+ InvalidationLists invalidationLists;
+ collectNthInvalidationSet(invalidationLists);
+
+ expectNoSelfInvalidation(invalidationLists.descendants);
+ expectClassInvalidation("a", invalidationLists.descendants);
+}
+
+TEST_F(RuleFeatureSetTest, nthInvalidationAnyDescendant)
+{
+ EXPECT_EQ(RuleFeatureSet::SelectorMayMatch, collectFeatures(".blah:-webkit-any(#nomatch, :nth-child(2n)) .a"));
+
+ InvalidationLists invalidationLists;
+ collectNthInvalidationSet(invalidationLists);
+
+ expectNoSelfInvalidation(invalidationLists.descendants);
+ expectClassInvalidation("a", invalidationLists.descendants);
+}
+
} // namespace blink
« no previous file with comments | « third_party/WebKit/Source/core/css/RuleFeature.cpp ('k') | third_party/WebKit/Source/core/css/invalidation/StyleInvalidator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698