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

Unified Diff: third_party/WebKit/Source/core/style/ComputedStyle.cpp

Issue 2117143003: Add a fast-path for independent inherited properties (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@computedstyle_cleanup_rename_final_member_fields
Patch Set: Small rename Created 4 years, 5 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/style/ComputedStyle.cpp
diff --git a/third_party/WebKit/Source/core/style/ComputedStyle.cpp b/third_party/WebKit/Source/core/style/ComputedStyle.cpp
index b0b2204dec5d9fe9f107349381a05cb29b66ccee..bcae818fc14c33897e17ee2d142165df0d94e7d3 100644
--- a/third_party/WebKit/Source/core/style/ComputedStyle.cpp
+++ b/third_party/WebKit/Source/core/style/ComputedStyle.cpp
@@ -76,6 +76,10 @@ struct SameSizeAsComputedStyle : public RefCounted<SameSizeAsComputedStyle> {
struct NonInheritedData {
unsigned m_bitfields[3];
} m_nonInheritedData;
+
+ struct IsInheritedFlags {
+ unsigned m_bitfields[1];
+ } m_isInheritedFlags;
};
static_assert(sizeof(ComputedStyle) == sizeof(SameSizeAsComputedStyle), "ComputedStyle should stay small");
@@ -160,6 +164,7 @@ ALWAYS_INLINE ComputedStyle::ComputedStyle(const ComputedStyle& o)
, m_svgStyle(o.m_svgStyle)
, m_inheritedData(o.m_inheritedData)
, m_nonInheritedData(o.m_nonInheritedData)
+ , m_isInheritedFlags(o.m_isInheritedFlags)
{
}
@@ -197,6 +202,11 @@ StyleRecalcChange ComputedStyle::stylePropagationDiff(const ComputedStyle* oldSt
|| oldStyle->justifyItems() != newStyle->justifyItems()) // TODO (lajava): We must avoid this Reattach.
return Reattach;
+ if (!oldStyle->independentInheritedEqual(*newStyle)
+ && oldStyle->nonIndependentInheritedEqual(*newStyle)
+ && !oldStyle->hasExplicitlyInheritedProperties())
+ return IndependentInherit;
+
if (!oldStyle->inheritedEqual(*newStyle)
|| !oldStyle->loadingCustomFontsEqual(*newStyle))
return Inherit;
@@ -210,6 +220,15 @@ StyleRecalcChange ComputedStyle::stylePropagationDiff(const ComputedStyle* oldSt
return NoInherit;
}
+// TODO(sashab): Generate this function.
+void ComputedStyle::propagateIndependentInheritedProperties(const ComputedStyle& parent, ComputedStyle& child)
+{
+ if (child.m_isInheritedFlags.m_isPointerEventsInherited)
+ child.setPointerEvents(parent.pointerEvents());
+ if (child.m_isInheritedFlags.m_isVisibilityInherited)
+ child.setVisibility(parent.visibility());
+}
+
ItemPosition ComputedStyle::resolveAlignment(const ComputedStyle& parentStyle, const ComputedStyle& childStyle, ItemPosition resolvedAutoPositionForLayoutObject)
{
// The auto keyword computes to the parent's align-items computed value, or to "stretch", if not set or "auto".
@@ -341,6 +360,10 @@ void ComputedStyle::copyNonInheritedFromCached(const ComputedStyle& other)
// m_nonInheritedData.m_affectedByDrag
// m_nonInheritedData.m_isLink
+ // Any properties that are inherited on a style are also inherited on elements
+ // that share this style.
+ m_isInheritedFlags = other.m_isInheritedFlags;
+
if (m_svgStyle != other.m_svgStyle)
m_svgStyle.access()->copyNonInheritedFromCached(other.m_svgStyle.get());
DCHECK_EQ(zoom(), initialZoom());
@@ -420,7 +443,18 @@ void ComputedStyle::removeCachedPseudoStyle(PseudoId pid)
bool ComputedStyle::inheritedEqual(const ComputedStyle& other) const
{
- return m_inheritedData == other.m_inheritedData
+ return independentInheritedEqual(other)
+ && nonIndependentInheritedEqual(other);
+}
+
+bool ComputedStyle::independentInheritedEqual(const ComputedStyle& other) const
+{
+ return m_inheritedData.compareEqualIndependent(other.m_inheritedData);
+}
+
+bool ComputedStyle::nonIndependentInheritedEqual(const ComputedStyle& other) const
+{
+ return m_inheritedData.compareEqualNonIndependent(other.m_inheritedData)
&& m_styleInheritedData == other.m_styleInheritedData
&& m_svgStyle->inheritedEqual(*other.m_svgStyle)
&& m_rareInheritedData == other.m_rareInheritedData;

Powered by Google App Engine
This is Rietveld 408576698