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

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

Issue 2220873002: Add a fast-path for independent inherited properties (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix for shadow roots Created 4 years, 4 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 20681097384728f6e84ccc056967ab3512b3b711..360c0ce5d37c2aab02f567ac1ffded0576710fdd 100644
--- a/third_party/WebKit/Source/core/style/ComputedStyle.cpp
+++ b/third_party/WebKit/Source/core/style/ComputedStyle.cpp
@@ -65,6 +65,8 @@ struct SameSizeAsBorderValue {
static_assert(sizeof(BorderValue) == sizeof(SameSizeAsBorderValue), "BorderValue should stay small");
+// Since different compilers/architectures pack ComputedStyle differently,
+// re-create the same structure for an accurate size comparison.
struct SameSizeAsComputedStyle : public RefCounted<SameSizeAsComputedStyle> {
void* dataRefs[7];
void* ownPtrs[1];
@@ -198,8 +200,15 @@ StyleRecalcChange ComputedStyle::stylePropagationDiff(const ComputedStyle* oldSt
|| oldStyle->justifyItems() != newStyle->justifyItems()) // TODO (lajava): We must avoid this Reattach.
return Reattach;
- if (!oldStyle->inheritedEqual(*newStyle)
- || !oldStyle->loadingCustomFontsEqual(*newStyle))
+ bool independentEqual = oldStyle->independentInheritedEqual(*newStyle);
+ bool nonIndependentEqual = oldStyle->nonIndependentInheritedEqual(*newStyle);
+ if (!independentEqual || !nonIndependentEqual) {
+ if (nonIndependentEqual && !oldStyle->hasExplicitlyInheritedProperties())
+ return IndependentInherit;
+ return Inherit;
+ }
+
+ if (!oldStyle->loadingCustomFontsEqual(*newStyle))
return Inherit;
if (*oldStyle == *newStyle)
@@ -211,6 +220,15 @@ StyleRecalcChange ComputedStyle::stylePropagationDiff(const ComputedStyle* oldSt
return NoInherit;
}
+// TODO(sashab): Generate this function.
+void ComputedStyle::propagateIndependentInheritedProperties(const ComputedStyle& parentStyle)
+{
+ if (m_nonInheritedData.m_isPointerEventsInherited)
+ setPointerEvents(parentStyle.pointerEvents());
+ if (m_nonInheritedData.m_isVisibilityInherited)
+ setVisibility(parentStyle.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".
@@ -343,6 +361,11 @@ 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_nonInheritedData.m_isPointerEventsInherited = other.m_nonInheritedData.m_isPointerEventsInherited;
+ m_nonInheritedData.m_isVisibilityInherited = other.m_nonInheritedData.m_isVisibilityInherited;
+
if (m_svgStyle != other.m_svgStyle)
m_svgStyle.access()->copyNonInheritedFromCached(other.m_svgStyle.get());
DCHECK_EQ(zoom(), initialZoom());
@@ -422,7 +445,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