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..063c252567c56aeb086e56740c7fa94561aed9d7 100644 |
--- a/third_party/WebKit/Source/core/style/ComputedStyle.cpp |
+++ b/third_party/WebKit/Source/core/style/ComputedStyle.cpp |
@@ -64,6 +64,8 @@ struct SameSizeAsBorderValue { |
static_assert(sizeof(BorderValue) == sizeof(SameSizeAsBorderValue), "BorderValue should stay small"); |
+// Since different platforms pack ComputedStyle differently, re-create the same |
Timothy Loh
2016/07/19 01:29:32
Are you sure this gets packed differently on diffe
sashab
2016/07/19 03:31:35
Done.
|
+// structure for an accurate size comparison. |
struct SameSizeAsComputedStyle : public RefCounted<SameSizeAsComputedStyle> { |
void* dataRefs[7]; |
void* ownPtrs[1]; |
@@ -76,6 +78,10 @@ struct SameSizeAsComputedStyle : public RefCounted<SameSizeAsComputedStyle> { |
struct NonInheritedData { |
unsigned m_bitfields[3]; |
} m_nonInheritedData; |
+ |
+ struct IsInheritedFlags { |
+ unsigned m_bitfields[1]; |
+ } m_isInheritedFlags; |
esprehn
2016/07/19 03:46:26
merge this into m_nonInheritedData and it doesn't
sashab
2016/07/19 06:32:38
Woo done. :)
|
}; |
static_assert(sizeof(ComputedStyle) == sizeof(SameSizeAsComputedStyle), "ComputedStyle should stay small"); |
@@ -160,6 +166,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 +204,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) |
esprehn
2016/07/19 03:46:26
this is a duplicate check with the inheritedEqual
sashab
2016/07/19 06:32:38
Unfortunately that doesn't quite work... See new c
|
+ && !oldStyle->hasExplicitlyInheritedProperties()) |
+ return IndependentInherit; |
+ |
if (!oldStyle->inheritedEqual(*newStyle) |
|| !oldStyle->loadingCustomFontsEqual(*newStyle)) |
return Inherit; |
@@ -210,6 +222,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) |
esprehn
2016/07/19 03:46:26
I do wonder how fast this will be if there's a ton
sashab
2016/07/19 06:32:38
Yeah, that's why the TODO to generate :)
|
+ 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 +362,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 +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; |