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

Unified Diff: third_party/WebKit/Source/core/css/resolver/MatchedPropertiesCache.cpp

Issue 2895283003: DCHECK style is cacheable in ComputedStyle::CopyNonInheritedFromCached. (Closed)
Patch Set: Address comments Created 3 years, 7 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/resolver/MatchedPropertiesCache.cpp
diff --git a/third_party/WebKit/Source/core/css/resolver/MatchedPropertiesCache.cpp b/third_party/WebKit/Source/core/css/resolver/MatchedPropertiesCache.cpp
index bfb82c11512373e37858899761c350ae954dea29..4a2cc79092c3b7a2746b3c92a0547645acae7ee0 100644
--- a/third_party/WebKit/Source/core/css/resolver/MatchedPropertiesCache.cpp
+++ b/third_party/WebKit/Source/core/css/resolver/MatchedPropertiesCache.cpp
@@ -117,25 +117,35 @@ void MatchedPropertiesCache::ClearViewportDependent() {
cache_.RemoveAll(to_remove);
}
-bool MatchedPropertiesCache::IsCacheable(const StyleResolverState& state) {
- const ComputedStyle& style = *state.Style();
- const ComputedStyle& parent_style = *state.ParentStyle();
-
- if (style.Unique() ||
- (style.StyleType() != kPseudoIdNone && parent_style.Unique()))
+bool MatchedPropertiesCache::IsStyleCacheable(const ComputedStyle& style) {
+ // unique() styles are not cacheable.
+ if (style.Unique())
return false;
if (style.Zoom() != ComputedStyle::InitialZoom())
return false;
if (style.GetWritingMode() != ComputedStyle::InitialWritingMode() ||
style.Direction() != ComputedStyle::InitialDirection())
return false;
+ // styles with non inherited properties that reference variables are not
+ // cacheable.
+ if (style.HasVariableReferenceFromNonInheritedProperty())
+ return false;
+ return true;
+}
+
+bool MatchedPropertiesCache::IsCacheable(const StyleResolverState& state) {
+ const ComputedStyle& style = *state.Style();
+ const ComputedStyle& parent_style = *state.ParentStyle();
+
+ if (!IsStyleCacheable(style))
+ return false;
+ if (style.StyleType() != kPseudoIdNone && parent_style.Unique())
+ return false;
// The cache assumes static knowledge about which properties are inherited.
// Without a flat tree parent, StyleBuilder::ApplyProperty will not
// SetHasExplicitlyInheritedProperties on the parent style.
if (!state.ParentNode() || parent_style.HasExplicitlyInheritedProperties())
return false;
- if (style.HasVariableReferenceFromNonInheritedProperty())
- return false;
return true;
}

Powered by Google App Engine
This is Rietveld 408576698