Index: third_party/WebKit/Source/core/style/ComputedStyle.h |
diff --git a/third_party/WebKit/Source/core/style/ComputedStyle.h b/third_party/WebKit/Source/core/style/ComputedStyle.h |
index 24caa7832faab720800d3a4962d6fdf33afcfbe8..eb0d434633e5b44f33c252af34f610503f9ef663 100644 |
--- a/third_party/WebKit/Source/core/style/ComputedStyle.h |
+++ b/third_party/WebKit/Source/core/style/ComputedStyle.h |
@@ -163,11 +163,24 @@ protected: |
struct InheritedData { |
bool operator==(const InheritedData& other) const |
{ |
+ return compareEqualIndependent(other) |
+ && compareEqualNonIndependent(other); |
+ } |
+ |
+ bool operator!=(const InheritedData& other) const { return !(*this == other); } |
+ |
+ inline bool compareEqualIndependent(const InheritedData& other) const |
+ { |
+ return (m_visibility == other.m_visibility) |
esprehn
2016/07/19 03:46:26
add a comment that these must match the .in file a
sashab
2016/07/19 06:32:38
Nice, yup done. Also added a TODO to generate this
|
+ && (m_pointerEvents == other.m_pointerEvents); |
+ } |
+ |
+ inline bool compareEqualNonIndependent(const InheritedData& other) const |
+ { |
return (m_emptyCells == other.m_emptyCells) |
&& (m_captionSide == other.m_captionSide) |
&& (m_listStyleType == other.m_listStyleType) |
&& (m_listStylePosition == other.m_listStylePosition) |
- && (m_visibility == other.m_visibility) |
&& (m_textAlign == other.m_textAlign) |
&& (m_textTransform == other.m_textTransform) |
&& (m_textUnderline == other.m_textUnderline) |
@@ -178,13 +191,10 @@ protected: |
&& (m_boxDirection == other.m_boxDirection) |
&& (m_rtlOrdering == other.m_rtlOrdering) |
&& (m_printColorAdjust == other.m_printColorAdjust) |
- && (m_pointerEvents == other.m_pointerEvents) |
&& (m_insideLink == other.m_insideLink) |
&& (m_writingMode == other.m_writingMode); |
} |
- bool operator!=(const InheritedData& other) const { return !(*this == other); } |
- |
unsigned m_emptyCells : 1; // EEmptyCells |
unsigned m_captionSide : 2; // ECaptionSide |
unsigned m_listStyleType : 7; // EListStyleType |
@@ -287,6 +297,35 @@ protected: |
// 66 bits |
} m_nonInheritedData; |
+ // For each inherited property, store a 1 if the stored value was inherited |
+ // from its parent, or 0 if it is explicitly set on this element. |
+ // Each bit in this struct corresponds to a single inherited property; |
+ // eventually, all properties will have a bit in here to store whether they |
+ // were inherited from their parent or not. |
+ // Since two ComputedStyles are equal if their nonInheritedData is equal |
+ // regardless of the isInherited flags, this struct is stored separately |
+ // to avoid too many subset comparison functions. |
+ // TODO(sashab): Move isInheritedFlags closer to inheritedData so that it's |
+ // clear which inherited properties have a flag stored and which don't. |
+ struct IsInheritedFlags { |
+ bool operator==(const IsInheritedFlags& other) const |
+ { |
+ return m_isPointerEventsInherited == other.m_isPointerEventsInherited |
+ && m_isVisibilityInherited == other.m_isVisibilityInherited; |
+ } |
+ |
+ bool operator!=(const IsInheritedFlags& other) const { return !(*this == other); } |
+ |
+ // Keep this list of fields in sync with: |
+ // - setBitDefaults() |
+ // - The ComputedStyle setter, which must take an extra boolean parameter and set this |
+ // - propagateIndependentInheritedProperties() in ComputedStyle.cpp |
+ // - The compareEqual() methods in the corresponding class |
+ // InheritedFlags |
+ unsigned m_isPointerEventsInherited : 1; |
esprehn
2016/07/19 03:46:26
no m_ on public fields, ComputedStyle is a huge me
sashab
2016/07/19 06:32:39
?? Oh, they are all called m_, so I just changed t
|
+ unsigned m_isVisibilityInherited : 1; |
esprehn
2016/07/19 03:46:26
why can't we put this in NonInheritedFlags to avoi
sashab
2016/07/19 06:32:38
Yeah, that's a good point. Originally I didn't do
|
+ } m_isInheritedFlags; |
+ |
// !END SYNC! |
protected: |
@@ -336,6 +375,10 @@ protected: |
m_nonInheritedData.m_affectedByDrag = false; |
m_nonInheritedData.m_isLink = false; |
m_nonInheritedData.m_hasRemUnits = false; |
+ |
+ // All independently inherited properties default to being inherited. |
+ m_isInheritedFlags.m_isPointerEventsInherited = true; |
+ m_isInheritedFlags.m_isVisibilityInherited = true; |
} |
private: |
@@ -365,6 +408,10 @@ public: |
// Computes how the style change should be propagated down the tree. |
static StyleRecalcChange stylePropagationDiff(const ComputedStyle* oldStyle, const ComputedStyle* newStyle); |
+ // Copies the values of any independent inherited properties from parent to |
+ // child that are not explicitly set in child. |
+ static void propagateIndependentInheritedProperties(const ComputedStyle& parent, ComputedStyle& child); |
Timothy Loh
2016/07/19 01:29:32
Why static?
sashab
2016/07/19 03:31:35
Done.
|
+ |
ContentPosition resolvedJustifyContentPosition(const StyleContentAlignmentData& normalValueBehavior) const; |
ContentDistributionType resolvedJustifyContentDistribution(const StyleContentAlignmentData& normalValueBehavior) const; |
ContentPosition resolvedAlignContentPosition(const StyleContentAlignmentData& normalValueBehavior) const; |
@@ -1622,6 +1669,10 @@ public: |
bool inheritedEqual(const ComputedStyle&) const; |
bool nonInheritedEqual(const ComputedStyle&) const; |
bool loadingCustomFontsEqual(const ComputedStyle&) const; |
+ |
+ inline bool independentInheritedEqual(const ComputedStyle&) const; |
+ inline bool nonIndependentInheritedEqual(const ComputedStyle&) const; |
+ |
bool inheritedDataShared(const ComputedStyle&) const; |
bool isDisplayReplacedType() const { return isDisplayReplacedType(display()); } |
@@ -1682,6 +1733,10 @@ public: |
void addPaintImage(StyleImage*); |
+ // Inherited setters. |
+ void setPointerEventsIsInherited(bool isInherited) { m_isInheritedFlags.m_isPointerEventsInherited = isInherited; } |
+ void setVisibilityIsInherited(bool isInherited) { m_isInheritedFlags.m_isVisibilityInherited = isInherited; } |
+ |
// Initial values for all the properties |
static EBorderCollapse initialBorderCollapse() { return BorderCollapseSeparate; } |
static EBorderStyle initialBorderStyle() { return BorderStyleNone; } |