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

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

Issue 1418133013: CSS: Reduce style invalidation with sibling combinators (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 2 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/RuleFeature.cpp
diff --git a/third_party/WebKit/Source/core/css/RuleFeature.cpp b/third_party/WebKit/Source/core/css/RuleFeature.cpp
index a9e3b6a2b3e7359f49baf14755563356930353b5..536eaf8acac3565c2bdc1d9ffd61116072cc95b6 100644
--- a/third_party/WebKit/Source/core/css/RuleFeature.cpp
+++ b/third_party/WebKit/Source/core/css/RuleFeature.cpp
@@ -319,7 +319,7 @@ InvalidationSet* RuleFeatureSet::invalidationSetForSelector(const CSSSelector& s
void RuleFeatureSet::updateInvalidationSets(const RuleData& ruleData)
{
InvalidationSetFeatures features;
- auto result = extractInvalidationSetFeatures(ruleData.selector(), features, false);
+ auto result = extractInvalidationSetFeatures(ruleData.selector(), features, false, true);
rune 2015/10/27 09:05:28 Would increase readability to use enums instead of
Eric Willigers 2015/10/28 00:13:07 I changed the code to use two enums.
if (result.first) {
features.forceSubtree = result.second == ForceSubtree;
@@ -358,7 +358,7 @@ void RuleFeatureSet::updateInvalidationSetsForContentAttribute(const RuleData& r
}
std::pair<const CSSSelector*, RuleFeatureSet::UseFeaturesType>
-RuleFeatureSet::extractInvalidationSetFeatures(const CSSSelector& selector, InvalidationSetFeatures& features, bool negated)
+RuleFeatureSet::extractInvalidationSetFeatures(const CSSSelector& selector, InvalidationSetFeatures& features, bool negated, bool rightmost)
{
bool foundFeatures = false;
for (const CSSSelector* current = &selector; current; current = current->tagHistory()) {
@@ -366,7 +366,8 @@ RuleFeatureSet::extractInvalidationSetFeatures(const CSSSelector& selector, Inva
foundFeatures |= extractInvalidationSetFeature(*current, features);
// Initialize the entry in the invalidation set map, if supported.
if (InvalidationSet* invalidationSet = invalidationSetForSelector(*current, InvalidateDescendants)) {
- invalidationSet->setInvalidatesSelf();
+ if (rightmost)
+ invalidationSet->setInvalidatesSelf();
} else {
if (requiresSubtreeInvalidation(*current)) {
// Fall back to use subtree invalidations, even for features in the
@@ -381,7 +382,7 @@ RuleFeatureSet::extractInvalidationSetFeatures(const CSSSelector& selector, Inva
const CSSSelector* subSelector = selectorList->first();
bool allSubSelectorsHaveFeatures = !!subSelector;
for (; subSelector; subSelector = CSSSelectorList::next(*subSelector)) {
- auto result = extractInvalidationSetFeatures(*subSelector, features, current->pseudoType() == CSSSelector::PseudoNot);
+ auto result = extractInvalidationSetFeatures(*subSelector, features, current->pseudoType() == CSSSelector::PseudoNot, rightmost);
if (result.first) {
// A non-null selector return means the sub-selector contained a
// selector which requiresSubtreeInvalidation(). Return the rightmost
@@ -498,7 +499,7 @@ void RuleFeatureSet::addFeaturesToInvalidationSets(const CSSSelector* selector,
}
localFeatures = InvalidationSetFeatures();
- auto result = extractInvalidationSetFeatures(*lastCompoundSelectorInAdjacentChain, localFeatures, false);
+ auto result = extractInvalidationSetFeatures(*lastCompoundSelectorInAdjacentChain, localFeatures, false, false);
ASSERT(result.first);
localFeatures.forceSubtree = result.second == ForceSubtree;
siblingFeatures = &localFeatures;
« no previous file with comments | « third_party/WebKit/Source/core/css/RuleFeature.h ('k') | third_party/WebKit/Source/core/css/RuleFeatureSetTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698