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

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

Issue 2326033002: Prepare to use invalidation set for adding/removing RuleSets. (Closed)
Patch Set: Rebased Created 4 years, 3 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
« no previous file with comments | « third_party/WebKit/Source/core/css/RuleFeature.cpp ('k') | third_party/WebKit/Source/core/css/RuleSet.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 eba129ca4d501a6a39d17cff5d29311ba841a9cc..cc7854ff3115b8881be6cedc6a9a8941730aa00f 100644
--- a/third_party/WebKit/Source/core/css/RuleFeatureSetTest.cpp
+++ b/third_party/WebKit/Source/core/css/RuleFeatureSetTest.cpp
@@ -85,6 +85,11 @@ public:
return m_ruleFeatureSet->collectFeaturesFromRuleData(ruleData);
}
+ void clearFeatures()
+ {
+ m_ruleFeatureSet->clear();
+ }
+
void collectInvalidationSetsForClass(InvalidationLists& invalidationLists, const AtomicString& className) const
{
Element* element = Traversal<HTMLElement>::firstChild(*Traversal<HTMLElement>::firstChild(*m_document->body()));
@@ -255,6 +260,11 @@ public:
EXPECT_EQ(count, m_ruleFeatureSet->uncommonAttributeRules.size());
}
+ void expectFullRecalcForRuleSetInvalidation(bool expected)
+ {
+ EXPECT_EQ(expected, m_ruleFeatureSet->needsFullRecalcForRuleSetInvalidation());
+ }
+
private:
PersistentPartObject<RuleFeatureSet> m_ruleFeatureSet;
Persistent<Document> m_document;
@@ -905,4 +915,146 @@ TEST_F(RuleFeatureSetTest, nthInvalidationAnyDescendant)
expectClassInvalidation("a", invalidationLists.descendants);
}
+TEST_F(RuleFeatureSetTest, RuleSetInvalidationTypeSelector)
+{
+ EXPECT_EQ(RuleFeatureSet::SelectorMayMatch, collectFeatures("div"));
+ expectFullRecalcForRuleSetInvalidation(false);
+ clearFeatures();
+
+ EXPECT_EQ(RuleFeatureSet::SelectorMayMatch, collectFeatures("* div"));
+ expectFullRecalcForRuleSetInvalidation(false);
+ clearFeatures();
+
+ EXPECT_EQ(RuleFeatureSet::SelectorMayMatch, collectFeatures("body *"));
+ expectFullRecalcForRuleSetInvalidation(true);
+}
+
+TEST_F(RuleFeatureSetTest, RuleSetInvalidationClassIdAttr)
+{
+ EXPECT_EQ(RuleFeatureSet::SelectorMayMatch, collectFeatures(".c"));
+ expectFullRecalcForRuleSetInvalidation(false);
+ clearFeatures();
+
+ EXPECT_EQ(RuleFeatureSet::SelectorMayMatch, collectFeatures(".c *"));
+ expectFullRecalcForRuleSetInvalidation(false);
+ clearFeatures();
+
+ EXPECT_EQ(RuleFeatureSet::SelectorMayMatch, collectFeatures("#i"));
+ expectFullRecalcForRuleSetInvalidation(false);
+ clearFeatures();
+
+ EXPECT_EQ(RuleFeatureSet::SelectorMayMatch, collectFeatures("#i *"));
+ expectFullRecalcForRuleSetInvalidation(false);
+ clearFeatures();
+
+ EXPECT_EQ(RuleFeatureSet::SelectorMayMatch, collectFeatures("[attr]"));
+ expectFullRecalcForRuleSetInvalidation(false);
+ clearFeatures();
+
+ EXPECT_EQ(RuleFeatureSet::SelectorMayMatch, collectFeatures("[attr] *"));
+ expectFullRecalcForRuleSetInvalidation(false);
+}
+
+TEST_F(RuleFeatureSetTest, RuleSetInvalidationHoverActiveFocus)
+{
+ EXPECT_EQ(RuleFeatureSet::SelectorMayMatch, collectFeatures(":hover:active:focus"));
+ expectFullRecalcForRuleSetInvalidation(true);
+}
+
+TEST_F(RuleFeatureSetTest, RuleSetInvalidationHostContext)
+{
+ EXPECT_EQ(RuleFeatureSet::SelectorMayMatch, collectFeatures(":host-context(.x)"));
+ expectFullRecalcForRuleSetInvalidation(true);
+ clearFeatures();
+
+ EXPECT_EQ(RuleFeatureSet::SelectorMayMatch, collectFeatures(":host-context(.x) .y"));
+ expectFullRecalcForRuleSetInvalidation(false);
+}
+
+TEST_F(RuleFeatureSetTest, RuleSetInvalidationHost)
+{
+ EXPECT_EQ(RuleFeatureSet::SelectorMayMatch, collectFeatures(":host(.x)"));
+ expectFullRecalcForRuleSetInvalidation(false);
+ clearFeatures();
+
+ EXPECT_EQ(RuleFeatureSet::SelectorMayMatch, collectFeatures(":host(*) .y"));
+ expectFullRecalcForRuleSetInvalidation(false);
+ clearFeatures();
+
+ EXPECT_EQ(RuleFeatureSet::SelectorMayMatch, collectFeatures(":host(.x) .y"));
+ expectFullRecalcForRuleSetInvalidation(false);
+}
+
+TEST_F(RuleFeatureSetTest, RuleSetInvalidationNot)
+{
+ EXPECT_EQ(RuleFeatureSet::SelectorMayMatch, collectFeatures(":not(.x)"));
+ expectFullRecalcForRuleSetInvalidation(true);
+ clearFeatures();
+
+ EXPECT_EQ(RuleFeatureSet::SelectorMayMatch, collectFeatures(":not(.x) :hover"));
+ expectFullRecalcForRuleSetInvalidation(true);
+ clearFeatures();
+
+ EXPECT_EQ(RuleFeatureSet::SelectorMayMatch, collectFeatures(":not(.x) .y"));
+ expectFullRecalcForRuleSetInvalidation(false);
+ clearFeatures();
+
+ EXPECT_EQ(RuleFeatureSet::SelectorMayMatch, collectFeatures(":not(.x) + .y"));
+ expectFullRecalcForRuleSetInvalidation(false);
+}
+
+TEST_F(RuleFeatureSetTest, RuleSetInvalidationCustomPseudo)
+{
+ EXPECT_EQ(RuleFeatureSet::SelectorMayMatch, collectFeatures("::-webkit-slider-thumb"));
+ expectFullRecalcForRuleSetInvalidation(true);
+ clearFeatures();
+
+ EXPECT_EQ(RuleFeatureSet::SelectorMayMatch, collectFeatures(".x::-webkit-slider-thumb"));
+ expectFullRecalcForRuleSetInvalidation(false);
+ clearFeatures();
+
+ EXPECT_EQ(RuleFeatureSet::SelectorMayMatch, collectFeatures(".x + ::-webkit-slider-thumb"));
+ expectFullRecalcForRuleSetInvalidation(false);
+}
+
+TEST_F(RuleFeatureSetTest, RuleSetInvalidationSlotted)
+{
+ EXPECT_EQ(RuleFeatureSet::SelectorMayMatch, collectFeatures("::slotted(*)"));
+ expectFullRecalcForRuleSetInvalidation(true);
+ clearFeatures();
+
+ EXPECT_EQ(RuleFeatureSet::SelectorMayMatch, collectFeatures("::slotted(.y)"));
+ expectFullRecalcForRuleSetInvalidation(false);
+ clearFeatures();
+
+ EXPECT_EQ(RuleFeatureSet::SelectorMayMatch, collectFeatures(".x::slotted(.y)"));
+ expectFullRecalcForRuleSetInvalidation(false);
+ clearFeatures();
+
+ EXPECT_EQ(RuleFeatureSet::SelectorMayMatch, collectFeatures("[x] ::slotted(.y)"));
+ expectFullRecalcForRuleSetInvalidation(false);
+}
+
+TEST_F(RuleFeatureSetTest, RuleSetInvalidationAnyPseudo)
+{
+ EXPECT_EQ(RuleFeatureSet::SelectorMayMatch, collectFeatures(":-webkit-any(*, #x)"));
+ expectFullRecalcForRuleSetInvalidation(true);
+ clearFeatures();
+
+ EXPECT_EQ(RuleFeatureSet::SelectorMayMatch, collectFeatures(".x:-webkit-any(*, #y)"));
+ expectFullRecalcForRuleSetInvalidation(false);
+ clearFeatures();
+
+ EXPECT_EQ(RuleFeatureSet::SelectorMayMatch, collectFeatures(":-webkit-any(:-webkit-any(.a, .b), #x)"));
+ expectFullRecalcForRuleSetInvalidation(false);
+ clearFeatures();
+
+ EXPECT_EQ(RuleFeatureSet::SelectorMayMatch, collectFeatures(":-webkit-any(:-webkit-any(.a, *), #x)"));
+ expectFullRecalcForRuleSetInvalidation(true);
+ clearFeatures();
+
+ EXPECT_EQ(RuleFeatureSet::SelectorMayMatch, collectFeatures(":-webkit-any(*, .a) *"));
+ expectFullRecalcForRuleSetInvalidation(true);
+}
+
} // namespace blink
« no previous file with comments | « third_party/WebKit/Source/core/css/RuleFeature.cpp ('k') | third_party/WebKit/Source/core/css/RuleSet.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698