- Revision
- 201875
- Author
- [email protected]
- Date
- 2016-06-09 11:33:02 -0700 (Thu, 09 Jun 2016)
Log Message
Writing-mode-dependent properties don't apply if their value is a variable
https://bugs.webkit.org/show_bug.cgi?id=158449
<rdar://problem/26662478>
Reviewed by Simon Fraser.
Source/WebCore:
Test: fast/css/variables/direction-dependent-variable-properties.html
* css/CSSParser.cpp:
(WebCore::CSSParser::parseVariableDependentValue):
* css/CSSParser.h:
* css/StyleResolver.cpp:
(WebCore::StyleResolver::resolvedVariableValue):
CSSVariableDependentValue stores the unresolved (direction-dependent) property ID,
because the property that it resolves to cannot be determined until style resolution time.
Plumb the requisite direction and writing mode information into parseVariableDependentValue
at style resolution time so that the property can be resolved to the correct
non-direction-dependent property for each use of the value.
LayoutTests:
* fast/css/variables/direction-dependent-variable-properties-expected.html: Added.
* fast/css/variables/direction-dependent-variable-properties.html: Added.
Add a test ensuring that direction-dependent properties work correctly,
including flipping when the direction is flipped.
Modified Paths
Added Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (201874 => 201875)
--- trunk/LayoutTests/ChangeLog 2016-06-09 18:27:32 UTC (rev 201874)
+++ trunk/LayoutTests/ChangeLog 2016-06-09 18:33:02 UTC (rev 201875)
@@ -1,3 +1,16 @@
+2016-06-09 Tim Horton <[email protected]>
+
+ Writing-mode-dependent properties don't apply if their value is a variable
+ https://bugs.webkit.org/show_bug.cgi?id=158449
+ <rdar://problem/26662478>
+
+ Reviewed by Simon Fraser.
+
+ * fast/css/variables/direction-dependent-variable-properties-expected.html: Added.
+ * fast/css/variables/direction-dependent-variable-properties.html: Added.
+ Add a test ensuring that direction-dependent properties work correctly,
+ including flipping when the direction is flipped.
+
2016-06-09 Ryan Haddad <[email protected]>
Marking editing/selection/selection-in-iframe-removed-crash.html as flaky on Mac
Added: trunk/LayoutTests/fast/css/variables/direction-dependent-variable-properties-expected.html (0 => 201875)
--- trunk/LayoutTests/fast/css/variables/direction-dependent-variable-properties-expected.html (rev 0)
+++ trunk/LayoutTests/fast/css/variables/direction-dependent-variable-properties-expected.html 2016-06-09 18:33:02 UTC (rev 201875)
@@ -0,0 +1,33 @@
+<head>
+<style>
+.first {
+ padding-left: 50px;
+ padding-right: 25px;
+ height: 50px;
+ margin: 20px;
+}
+
+.second {
+ padding-left: 25px;
+ padding-right: 50px;
+ height: 50px;
+ margin: 20px;
+}
+
+.inner {
+ width: 50px;
+ height: 50px;
+ background-color: blue;
+}
+
+div {
+ display: inline-block;
+ background-color: green;
+}
+</style>
+</head>
+<body>
+ <div class="first"><div class="inner"></div></div>
+ <div class="second"><div class="inner"></div></div>
+</body>
+</html>
\ No newline at end of file
Added: trunk/LayoutTests/fast/css/variables/direction-dependent-variable-properties.html (0 => 201875)
--- trunk/LayoutTests/fast/css/variables/direction-dependent-variable-properties.html (rev 0)
+++ trunk/LayoutTests/fast/css/variables/direction-dependent-variable-properties.html 2016-06-09 18:33:02 UTC (rev 201875)
@@ -0,0 +1,31 @@
+<head>
+<style>
+body {
+ --large: 50px;
+ --small: 25px;
+}
+
+.first {
+ -webkit-padding-start: var(--large);
+ -webkit-padding-end: var(--small);
+ height: 50px;
+ margin: 20px;
+}
+
+.inner {
+ width: 50px;
+ height: 50px;
+ background-color: blue;
+}
+
+div {
+ display: inline-block;
+ background-color: green;
+}
+</style>
+</head>
+<body>
+ <div class="first"><div class="inner"></div></div>
+ <span dir="rtl"><div class="first"><div class="inner"></div></div></span>
+</body>
+</html>
\ No newline at end of file
Modified: trunk/Source/WebCore/ChangeLog (201874 => 201875)
--- trunk/Source/WebCore/ChangeLog 2016-06-09 18:27:32 UTC (rev 201874)
+++ trunk/Source/WebCore/ChangeLog 2016-06-09 18:33:02 UTC (rev 201875)
@@ -1,3 +1,24 @@
+2016-06-09 Tim Horton <[email protected]>
+
+ Writing-mode-dependent properties don't apply if their value is a variable
+ https://bugs.webkit.org/show_bug.cgi?id=158449
+ <rdar://problem/26662478>
+
+ Reviewed by Simon Fraser.
+
+ Test: fast/css/variables/direction-dependent-variable-properties.html
+
+ * css/CSSParser.cpp:
+ (WebCore::CSSParser::parseVariableDependentValue):
+ * css/CSSParser.h:
+ * css/StyleResolver.cpp:
+ (WebCore::StyleResolver::resolvedVariableValue):
+ CSSVariableDependentValue stores the unresolved (direction-dependent) property ID,
+ because the property that it resolves to cannot be determined until style resolution time.
+ Plumb the requisite direction and writing mode information into parseVariableDependentValue
+ at style resolution time so that the property can be resolved to the correct
+ non-direction-dependent property for each use of the value.
+
2016-06-09 Ryan Haddad <[email protected]>
Attempt to fix the iOS build.
Modified: trunk/Source/WebCore/css/CSSParser.cpp (201874 => 201875)
--- trunk/Source/WebCore/css/CSSParser.cpp 2016-06-09 18:27:32 UTC (rev 201874)
+++ trunk/Source/WebCore/css/CSSParser.cpp 2016-06-09 18:33:02 UTC (rev 201875)
@@ -1856,13 +1856,19 @@
addProperty(longhands[i], value.copyRef(), important);
}
-RefPtr<CSSValue> CSSParser::parseVariableDependentValue(CSSPropertyID propID, const CSSVariableDependentValue& dependentValue, const CustomPropertyValueMap& customProperties)
+RefPtr<CSSValue> CSSParser::parseVariableDependentValue(CSSPropertyID propID, const CSSVariableDependentValue& dependentValue, const CustomPropertyValueMap& customProperties, TextDirection direction, WritingMode writingMode)
{
m_valueList.reset(new CSSParserValueList());
if (!dependentValue.valueList().buildParserValueListSubstitutingVariables(m_valueList.get(), customProperties))
return nullptr;
- if (!parseValue(dependentValue.propertyID(), false))
+
+ CSSPropertyID dependentValuePropertyID = dependentValue.propertyID();
+ if (CSSProperty::isDirectionAwareProperty(dependentValuePropertyID))
+ dependentValuePropertyID = CSSProperty::resolveDirectionAwareProperty(dependentValuePropertyID, direction, writingMode);
+
+ if (!parseValue(dependentValuePropertyID, false))
return nullptr;
+
for (auto& property : m_parsedProperties) {
if (property.id() == propID)
return property.value();
Modified: trunk/Source/WebCore/css/CSSParser.h (201874 => 201875)
--- trunk/Source/WebCore/css/CSSParser.h 2016-06-09 18:27:32 UTC (rev 201874)
+++ trunk/Source/WebCore/css/CSSParser.h 2016-06-09 18:33:02 UTC (rev 201875)
@@ -499,7 +499,7 @@
void setCustomPropertyName(const AtomicString& propertyName) { m_customPropertyName = propertyName; }
- RefPtr<CSSValue> parseVariableDependentValue(CSSPropertyID, const CSSVariableDependentValue&, const CustomPropertyValueMap& customProperties);
+ RefPtr<CSSValue> parseVariableDependentValue(CSSPropertyID, const CSSVariableDependentValue&, const CustomPropertyValueMap& customProperties, TextDirection, WritingMode);
private:
bool is8BitSource() { return m_is8BitSource; }
Modified: trunk/Source/WebCore/css/StyleResolver.cpp (201874 => 201875)
--- trunk/Source/WebCore/css/StyleResolver.cpp 2016-06-09 18:27:32 UTC (rev 201874)
+++ trunk/Source/WebCore/css/StyleResolver.cpp 2016-06-09 18:33:02 UTC (rev 201875)
@@ -1698,7 +1698,7 @@
RefPtr<CSSValue> StyleResolver::resolvedVariableValue(CSSPropertyID propID, const CSSVariableDependentValue& value)
{
CSSParser parser(m_state.document());
- return parser.parseVariableDependentValue(propID, value, m_state.style()->customProperties());
+ return parser.parseVariableDependentValue(propID, value, m_state.style()->customProperties(), m_state.style()->direction(), m_state.style()->writingMode());
}
RefPtr<StyleImage> StyleResolver::styleImage(CSSPropertyID property, CSSValue& value)