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

Unified Diff: Source/core/css/RuleFeature.cpp

Issue 208013002: Support invalidation sets for :host pseudo. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 9 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 | « Source/core/css/RuleFeature.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/css/RuleFeature.cpp
diff --git a/Source/core/css/RuleFeature.cpp b/Source/core/css/RuleFeature.cpp
index d49e8ad5c84db54ec5bd1b046881e124a9d161b7..eb6055eedeeed2116ef73b6c78d0fdfebb494d1c 100644
--- a/Source/core/css/RuleFeature.cpp
+++ b/Source/core/css/RuleFeature.cpp
@@ -54,7 +54,7 @@ static bool isSkippableComponentForInvalidation(const CSSSelector& selector)
|| selector.isAttributeSelector())
return true;
if (selector.m_match == CSSSelector::PseudoElement) {
- switch (selector.m_pseudoType) {
+ switch (selector.pseudoType()) {
case CSSSelector::PseudoBefore:
case CSSSelector::PseudoAfter:
case CSSSelector::PseudoBackdrop:
@@ -119,6 +119,16 @@ RuleFeatureSet::InvalidationSetMode RuleFeatureSet::supportsClassDescendantInval
if (component->m_match == CSSSelector::Class) {
if (!foundDescendantRelation)
foundIdent = true;
+ } else if (component->pseudoType() == CSSSelector::PseudoHost) {
+ const CSSSelectorList* list = component->selectorList();
+ if (list) {
ojan 2014/03/22 00:32:23 Nit: typically we write this as follows: if (cons
+ ASSERT(list->hasOneSelector());
esprehn 2014/03/22 01:25:34 Why does this have to have one selector? You can w
+ InvalidationSetMode hostMode = supportsClassDescendantInvalidation(*list->first());
+ if (hostMode == UseSubtreeStyleChange)
+ return foundDescendantRelation ? UseLocalStyleChange : UseSubtreeStyleChange;
+ if (hostMode == AddFeatures)
+ foundIdent = true;
+ }
} else if (!isSkippableComponentForInvalidation(*component)) {
return foundDescendantRelation ? UseLocalStyleChange : UseSubtreeStyleChange;
}
@@ -163,19 +173,37 @@ RuleFeatureSet::InvalidationSetMode RuleFeatureSet::updateClassInvalidationSets(
AtomicString id;
AtomicString tagName;
+ const CSSSelector* current = extractInvalidationSetFeatures(selector, classes, id, tagName);
+ if (!current || !(current = current->tagHistory()))
ojan 2014/03/22 00:32:23 Nit: In contrast to the above case, I find setting
esprehn 2014/03/22 01:25:34 Don't do assignments inside || or &&
+ return AddFeatures;
+
+ addFeaturesToInvalidationSets(*current, classes, id, tagName);
+ return AddFeatures;
+}
+
+const CSSSelector* RuleFeatureSet::extractInvalidationSetFeatures(const CSSSelector& selector, Vector<AtomicString>& classes, AtomicString& id, AtomicString& tagName)
+{
const CSSSelector* lastSelector = &selector;
for (; lastSelector; lastSelector = lastSelector->tagHistory()) {
extractClassIdOrTag(*lastSelector, classes, id, tagName);
- if (lastSelector->m_match == CSSSelector::Class)
+ if (lastSelector->m_match == CSSSelector::Class) {
ensureClassInvalidationSet(lastSelector->value());
+ } else if (lastSelector->pseudoType() == CSSSelector::PseudoHost) {
+ const CSSSelectorList* list = lastSelector->selectorList();
+ if (list)
ojan 2014/03/22 00:32:23 Ditto first comment.
+ extractInvalidationSetFeatures(*list->first(), classes, id, tagName);
+ }
+
if (lastSelector->relation() != CSSSelector::SubSelector)
break;
}
+ return lastSelector;
+}
- if (!lastSelector)
- return AddFeatures;
-
- for (const CSSSelector* current = lastSelector->tagHistory(); current; current = current->tagHistory()) {
+void RuleFeatureSet::addFeaturesToInvalidationSets(const CSSSelector& selector, const Vector<AtomicString>& classes, AtomicString id, AtomicString tagName)
+{
+ const CSSSelector* current = &selector;
+ for (; current; current = current->tagHistory()) {
if (current->m_match == CSSSelector::Class) {
DescendantInvalidationSet& invalidationSet = ensureClassInvalidationSet(current->value());
if (!id.isEmpty())
@@ -185,9 +213,11 @@ RuleFeatureSet::InvalidationSetMode RuleFeatureSet::updateClassInvalidationSets(
for (Vector<AtomicString>::const_iterator it = classes.begin(); it != classes.end(); ++it) {
invalidationSet.addClass(*it);
}
+ } else if (current->pseudoType() == CSSSelector::PseudoHost) {
+ if (current->selectorList())
ojan 2014/03/22 00:32:23 Nit: extra space after the if.
+ addFeaturesToInvalidationSets(*current->selectorList()->first(), classes, id, tagName);
}
}
- return AddFeatures;
}
void RuleFeatureSet::addAttributeInASelector(const AtomicString& attributeName)
« no previous file with comments | « Source/core/css/RuleFeature.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698