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

Unified Diff: Source/core/layout/style/LayoutStyle.cpp

Issue 921843004: Stop explicit inheritance if LayoutStyle doesn't change. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Corrected and documented flag copying/comparisons Created 5 years, 10 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/layout/style/LayoutStyle.h ('k') | Source/core/layout/style/SVGLayoutStyle.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/layout/style/LayoutStyle.cpp
diff --git a/Source/core/layout/style/LayoutStyle.cpp b/Source/core/layout/style/LayoutStyle.cpp
index 3915a94c7683873de695056165c52574f38d721e..c8ccbabb210fb9e9201e95b894d2535f23a29cf9 100644
--- a/Source/core/layout/style/LayoutStyle.cpp
+++ b/Source/core/layout/style/LayoutStyle.cpp
@@ -188,14 +188,15 @@ StyleRecalcChange LayoutStyle::stylePropagationDiff(const LayoutStyle* oldStyle,
|| oldStyle->alignItems() != newStyle->alignItems())
return Reattach;
- if (oldStyle->inheritedNotEqual(*newStyle)
- || oldStyle->hasExplicitlyInheritedProperties()
- || newStyle->hasExplicitlyInheritedProperties())
+ if (oldStyle->inheritedNotEqual(*newStyle))
return Inherit;
if (*oldStyle == *newStyle)
return diffPseudoStyles(*oldStyle, *newStyle);
+ if (oldStyle->hasExplicitlyInheritedProperties())
+ return Inherit;
+
return NoInherit;
}
@@ -230,14 +231,16 @@ void LayoutStyle::inheritFrom(const LayoutStyle& inheritParent, IsAtShadowBounda
m_svgStyle.access()->inheritFrom(inheritParent.m_svgStyle.get());
}
-void LayoutStyle::copyNonInheritedFrom(const LayoutStyle& other)
+void LayoutStyle::copyNonInheritedFromCached(const LayoutStyle& other)
{
m_box = other.m_box;
visual = other.visual;
m_background = other.m_background;
surround = other.surround;
rareNonInheritedData = other.rareNonInheritedData;
+
// The flags are copied one-by-one because noninherited_flags contains a bunch of stuff other than real style data.
+ // See comments for each skipped flag below.
noninherited_flags.effectiveDisplay = other.noninherited_flags.effectiveDisplay;
noninherited_flags.originalDisplay = other.noninherited_flags.originalDisplay;
noninherited_flags.overflowX = other.noninherited_flags.overflowX;
@@ -248,13 +251,42 @@ void LayoutStyle::copyNonInheritedFrom(const LayoutStyle& other)
noninherited_flags.floating = other.noninherited_flags.floating;
noninherited_flags.tableLayout = other.noninherited_flags.tableLayout;
noninherited_flags.unicodeBidi = other.noninherited_flags.unicodeBidi;
+ noninherited_flags.hasViewportUnits = other.noninherited_flags.hasViewportUnits;
noninherited_flags.pageBreakBefore = other.noninherited_flags.pageBreakBefore;
noninherited_flags.pageBreakAfter = other.noninherited_flags.pageBreakAfter;
noninherited_flags.pageBreakInside = other.noninherited_flags.pageBreakInside;
- noninherited_flags.explicitInheritance = other.noninherited_flags.explicitInheritance;
- noninherited_flags.hasViewportUnits = other.noninherited_flags.hasViewportUnits;
+
+ // Correctly set during selector matching:
+ // noninherited_flags.styleType
+ // noninherited_flags.pseudoBits
+
+ // Set correctly while computing style for children:
+ // noninherited_flags.explicitInheritance
+
+ // unique() styles are not cacheable.
+ ASSERT(!other.noninherited_flags.unique);
+
+ // The following flags are set during matching before we decide that we get a
+ // match in the MatchedPropertiesCache which in turn calls this method. The
+ // reason why we don't copy these flags is that they're already correctly set
+ // and that they may differ between elements which have the same set of matched
+ // properties. For instance, given the rule:
+ //
+ // :-webkit-any(:hover, :focus) { background-color: green }"
+ //
+ // A hovered element, and a focused element may use the same cached matched
+ // properties here, but the affectedBy flags will be set differently based on
+ // the matching order of the :-webkit-any components.
+ //
+ // noninherited_flags.emptyState
+ // noninherited_flags.affectedByFocus
+ // noninherited_flags.affectedByHover
+ // noninherited_flags.affectedByActive
+ // noninherited_flags.affectedByDrag
+ // noninherited_flags.isLink
+
if (m_svgStyle != other.m_svgStyle)
- m_svgStyle.access()->copyNonInheritedFrom(other.m_svgStyle.get());
+ m_svgStyle.access()->copyNonInheritedFromCached(other.m_svgStyle.get());
ASSERT(zoom() == initialZoom());
}
« no previous file with comments | « Source/core/layout/style/LayoutStyle.h ('k') | Source/core/layout/style/SVGLayoutStyle.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698