Commit bd928558 authored by napper's avatar napper Committed by Commit bot

Made CSS white-space property use IndependentInherit

Made CSS white-space property use IndependentInherit, which is part
of the process of making property inheritance faster. This change
adds 1 bit to the size of ComputedStyle but significantly reduces the
time for a recalc for independent-only changes involving whitespace.

Tested using:
third_party/WebKit/LayoutTests/fast/css/invalidation/independent-inheritance-fast-path.html

BUG=622138

Review-Url: https://codereview.chromium.org/2538983002
Cr-Commit-Position: refs/heads/master@{#435559}
parent 3f8531a6
......@@ -14,6 +14,7 @@ var independent_properties = [
// Property name, Value 1, Value 2
["pointerEvents", "auto", "all"],
["visibility", "visible", "hidden"],
["whiteSpace", "normal", "nowrap"],
];
independent_properties.forEach(function(test_data)
......
......@@ -440,7 +440,7 @@ column-width interpolable, converter=convertComputedLength<float>, custom_all
-webkit-user-drag
-webkit-user-modify inherited
user-select inherited
white-space inherited
white-space inherited, independent
widows interpolable, inherited, type_name=short
width interpolable, initial=initialSize, converter=convertLengthSizing, typedom_types=[Length], keywords=[auto], supports_percentage
will-change custom_all
......
......@@ -239,6 +239,8 @@ void ComputedStyle::propagateIndependentInheritedProperties(
setPointerEvents(parentStyle.pointerEvents());
if (m_nonInheritedData.m_isVisibilityInherited)
setVisibility(parentStyle.visibility());
if (m_nonInheritedData.m_isWhiteSpaceInherited)
setWhiteSpace(parentStyle.whiteSpace());
}
StyleSelfAlignmentData resolvedSelfAlignment(
......@@ -426,6 +428,8 @@ void ComputedStyle::copyNonInheritedFromCached(const ComputedStyle& other) {
other.m_nonInheritedData.m_isPointerEventsInherited;
m_nonInheritedData.m_isVisibilityInherited =
other.m_nonInheritedData.m_isVisibilityInherited;
m_nonInheritedData.m_isWhiteSpaceInherited =
other.m_nonInheritedData.m_isWhiteSpaceInherited;
if (m_svgStyle != other.m_svgStyle)
m_svgStyle.access()->copyNonInheritedFromCached(other.m_svgStyle.get());
......
......@@ -210,7 +210,8 @@ class CORE_EXPORT ComputedStyle : public ComputedStyleBase,
// These must match the properties tagged 'independent' in
// CSSProperties.in.
// TODO(sashab): Generate this function.
return (m_pointerEvents == other.m_pointerEvents);
return (m_pointerEvents == other.m_pointerEvents) &&
(m_whiteSpace == other.m_whiteSpace);
}
inline bool compareEqualNonIndependent(const InheritedData& other) const {
......@@ -219,7 +220,6 @@ class CORE_EXPORT ComputedStyle : public ComputedStyleBase,
(m_hasSimpleUnderline == other.m_hasSimpleUnderline) &&
(m_cursorStyle == other.m_cursorStyle) &&
(m_direction == other.m_direction) &&
(m_whiteSpace == other.m_whiteSpace) &&
(m_borderCollapse == other.m_borderCollapse) &&
(m_boxDirection == other.m_boxDirection) &&
(m_rtlOrdering == other.m_rtlOrdering) &&
......@@ -348,6 +348,7 @@ class CORE_EXPORT ComputedStyle : public ComputedStyleBase,
// InheritedFlags
unsigned m_isPointerEventsInherited : 1;
unsigned m_isVisibilityInherited : 1;
unsigned m_isWhiteSpaceInherited : 1;
// If you add more style bits here, you will also need to update
// ComputedStyle::copyNonInheritedFromCached() 68 bits
......@@ -406,6 +407,7 @@ class CORE_EXPORT ComputedStyle : public ComputedStyleBase,
// All independently inherited properties default to being inherited.
m_nonInheritedData.m_isPointerEventsInherited = true;
m_nonInheritedData.m_isVisibilityInherited = true;
m_nonInheritedData.m_isWhiteSpaceInherited = true;
}
private:
......@@ -2283,6 +2285,9 @@ class CORE_EXPORT ComputedStyle : public ComputedStyleBase,
void setWhiteSpace(EWhiteSpace v) {
m_inheritedData.m_whiteSpace = static_cast<unsigned>(v);
}
void setWhiteSpaceIsInherited(bool isInherited) {
m_nonInheritedData.m_isWhiteSpaceInherited = isInherited;
}
// word-break inherited (aka -epub-word-break)
static EWordBreak initialWordBreak() { return NormalWordBreak; }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment