Changeset 291546 in webkit
- Timestamp:
- Mar 20, 2022 9:37:43 AM (4 months ago)
- Location:
- trunk
- Files:
-
- 2 added
- 9 edited
-
LayoutTests/imported/w3c/ChangeLog (modified) (1 diff)
-
LayoutTests/imported/w3c/web-platform-tests/css/css-logical/animation-004-expected.txt (modified) (1 diff)
-
LayoutTests/imported/w3c/web-platform-tests/css/css-logical/logicalprops-with-deferred-writing-mode-expected.txt (added)
-
LayoutTests/imported/w3c/web-platform-tests/css/css-logical/logicalprops-with-deferred-writing-mode.html (added)
-
Source/WebCore/ChangeLog (modified) (1 diff)
-
Source/WebCore/css/CSSComputedStyleDeclaration.cpp (modified) (3 diffs)
-
Source/WebCore/css/CSSProperties.json (modified) (8 diffs)
-
Source/WebCore/css/parser/CSSParser.cpp (modified) (1 diff)
-
Source/WebCore/style/PropertyCascade.cpp (modified) (5 diffs)
-
Source/WebCore/style/PropertyCascade.h (modified) (5 diffs)
-
Source/WebCore/style/StyleBuilder.cpp (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/imported/w3c/ChangeLog
r291537 r291546 1 2022-03-20 Oriol Brufau <obrufau@igalia.com> 2 3 Fix CSS cascade regarding logical properties 4 https://bugs.webkit.org/show_bug.cgi?id=236199 5 6 Reviewed by Darin Adler. 7 8 Expect animation-004.html to pass. 9 Add new test logicalprops-with-deferred-writing-mode.html 10 11 * web-platform-tests/css/css-logical/animation-004-expected.txt: 12 * web-platform-tests/css/css-logical/logicalprops-with-deferred-writing-mode-expected.txt: Added. 13 * web-platform-tests/css/css-logical/logicalprops-with-deferred-writing-mode.html: Added. 14 1 15 2022-03-19 Oriol Brufau <obrufau@igalia.com> 2 16 -
trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-logical/animation-004-expected.txt
r289167 r291546 12 12 PASS The number of interpolating properties can be increased when the writing-mode is changed 13 13 PASS The number of interpolating properties can be decreased when the writing-mode is changed 14 FAIL Transitions update when the writing-mode is changed through a CSS variable assert_equals: expected "50px" but got "0px" 14 PASS Transitions update when the writing-mode is changed through a CSS variable 15 15 PASS Transitions update when the direction is changed 16 16 PASS Transitions from logical to physical update when the direction is changed -
trunk/Source/WebCore/ChangeLog
r291545 r291546 1 2022-03-20 Oriol Brufau <obrufau@igalia.com> 2 3 Fix CSS cascade regarding logical properties 4 https://bugs.webkit.org/show_bug.cgi?id=236199 5 6 Reviewed by Darin Adler. 7 8 The CSS cascade was trying to resolve logical properties into physical 9 ones too early. This failed if we still didn't know the direction or 10 writing-mode, e.g. because they were set to a variable or to a CSS-wide 11 keyword. 12 13 This patch keeps logical properties as-is during the cascade. They are 14 only resolved when finally applied. Also, both logical properties and 15 their physical equivalents are now set to apply in parse order, since 16 'height: 0px; block-size: 1px' and 'block-size: 1px; height: 0px' can be 17 different, the order matters. 18 19 Tests: imported/w3c/web-platform-tests/css/css-logical/animation-004.html 20 imported/w3c/web-platform-tests/css/css-logical/logicalprops-with-deferred-writing-mode.html 21 22 * css/CSSComputedStyleDeclaration.cpp: 23 (WebCore::ComputedStyleExtractor::valueForPropertyInStyle): 24 * css/CSSProperties.json: 25 * css/parser/CSSParser.cpp: 26 (WebCore::CSSParser::parseValueWithVariableReferences): 27 * style/PropertyCascade.cpp: 28 (WebCore::Style::shouldApplyPropertyInParseOrder): 29 (WebCore::Style::PropertyCascade::PropertyCascade): 30 (WebCore::Style::PropertyCascade::set): 31 (WebCore::Style::PropertyCascade::setDeferred): 32 (WebCore::Style::PropertyCascade::resolveDirectionAndWritingMode const): Deleted. 33 (WebCore::Style::PropertyCascade::direction const): Deleted. 34 * style/PropertyCascade.h: 35 (WebCore::Style::PropertyCascade::areDeferredInOrder const): 36 * style/StyleBuilder.cpp: 37 (WebCore::Style::Builder::Builder): 38 (WebCore::Style::Builder::applyProperty): 39 (WebCore::Style::directionFromStyle): Deleted. 40 1 41 2022-03-20 Alan Bujtas <zalan@apple.com> 2 42 -
trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp
r291420 r291546 4035 4035 case CSSPropertyBorderBlockColor: 4036 4036 return getCSSPropertyValuesFor2SidesShorthand(borderBlockColorShorthand()); 4037 case CSSPropertyBorderBlockEnd: 4038 return getCSSPropertyValuesForShorthandProperties(borderBlockEndShorthand()); 4039 case CSSPropertyBorderBlockStart: 4040 return getCSSPropertyValuesForShorthandProperties(borderBlockStartShorthand()); 4037 4041 case CSSPropertyBorderBlockStyle: 4038 4042 return getCSSPropertyValuesFor2SidesShorthand(borderBlockStyleShorthand()); … … 4055 4059 case CSSPropertyBorderInlineColor: 4056 4060 return getCSSPropertyValuesFor2SidesShorthand(borderInlineColorShorthand()); 4061 case CSSPropertyBorderInlineEnd: 4062 return getCSSPropertyValuesForShorthandProperties(borderInlineEndShorthand()); 4063 case CSSPropertyBorderInlineStart: 4064 return getCSSPropertyValuesForShorthandProperties(borderInlineStartShorthand()); 4057 4065 case CSSPropertyBorderInlineStyle: 4058 4066 return getCSSPropertyValuesFor2SidesShorthand(borderInlineStyleShorthand()); … … 4206 4214 4207 4215 /* Directional properties are resolved by resolveDirectionAwareProperty() before the switch. */ 4208 case CSSPropertyBorderBlockEnd:4209 4216 case CSSPropertyBorderBlockEndColor: 4210 4217 case CSSPropertyBorderBlockEndStyle: 4211 4218 case CSSPropertyBorderBlockEndWidth: 4212 case CSSPropertyBorderBlockStart:4213 4219 case CSSPropertyBorderBlockStartColor: 4214 4220 case CSSPropertyBorderBlockStartStyle: 4215 4221 case CSSPropertyBorderBlockStartWidth: 4216 case CSSPropertyBorderEndEndRadius: 4217 case CSSPropertyBorderEndStartRadius: 4218 case CSSPropertyBorderInlineEnd: 4222 case CSSPropertyBorderEndEndRadius: 4223 case CSSPropertyBorderEndStartRadius: 4219 4224 case CSSPropertyBorderInlineEndColor: 4220 4225 case CSSPropertyBorderInlineEndStyle: 4221 4226 case CSSPropertyBorderInlineEndWidth: 4222 case CSSPropertyBorderInlineStart:4223 4227 case CSSPropertyBorderInlineStartColor: 4224 4228 case CSSPropertyBorderInlineStartStyle: -
trunk/Source/WebCore/css/CSSProperties.json
r291536 r291546 1343 1343 "border-block-end-style", 1344 1344 "border-block-end-color" 1345 ], 1346 "logical-property-group": { 1347 "name": "border", 1348 "resolver": "block-end" 1349 } 1345 ] 1350 1346 }, 1351 1347 "specification": { … … 1424 1420 "border-block-start-style", 1425 1421 "border-block-start-color" 1426 ], 1427 "logical-property-group": { 1428 "name": "border", 1429 "resolver": "block-start" 1430 } 1422 ] 1431 1423 }, 1432 1424 "specification": { … … 1526 1518 "border-bottom-style", 1527 1519 "border-bottom-color" 1528 ], 1529 "logical-property-group": { 1530 "name": "border", 1531 "resolver": "bottom" 1532 } 1520 ] 1533 1521 }, 1534 1522 "specification": { … … 1771 1759 "border-inline-end-style", 1772 1760 "border-inline-end-color" 1773 ], 1774 "logical-property-group": { 1775 "name": "border", 1776 "resolver": "inline-end" 1777 } 1761 ] 1778 1762 }, 1779 1763 "specification": { … … 1852 1836 "border-inline-start-style", 1853 1837 "border-inline-start-color" 1854 ], 1855 "logical-property-group": { 1856 "name": "border", 1857 "resolver": "inline-start" 1858 } 1838 ] 1859 1839 }, 1860 1840 "specification": { … … 1954 1934 "border-left-style", 1955 1935 "border-left-color" 1956 ], 1957 "logical-property-group": { 1958 "name": "border", 1959 "resolver": "left" 1960 } 1936 ] 1961 1937 }, 1962 1938 "specification": { … … 2039 2015 "border-right-style", 2040 2016 "border-right-color" 2041 ], 2042 "logical-property-group": { 2043 "name": "border", 2044 "resolver": "right" 2045 } 2017 ] 2046 2018 }, 2047 2019 "specification": { … … 2163 2135 "border-top-style", 2164 2136 "border-top-color" 2165 ], 2166 "logical-property-group": { 2167 "name": "border", 2168 "resolver": "top" 2169 } 2137 ] 2170 2138 }, 2171 2139 "specification": { -
trunk/Source/WebCore/css/parser/CSSParser.cpp
r288134 r291546 214 214 215 215 for (auto& property : parsedProperties) { 216 CSSPropertyID currentId = property.id(); 217 if (CSSProperty::isDirectionAwareProperty(currentId)) 218 currentId = CSSProperty::resolveDirectionAwareProperty(currentId, direction, writingMode); 219 if (currentId == propID) 216 if (property.id() == propID) 220 217 return property.value(); 221 218 } -
trunk/Source/WebCore/style/PropertyCascade.cpp
r291260 r291546 69 69 return true; 70 70 default: 71 return false;72 } 73 } 74 75 PropertyCascade::PropertyCascade(const MatchResult& matchResult, CascadeLevel maximumCascadeLevel, IncludedProperties includedProperties , Direction direction)71 return CSSProperty::isInLogicalPropertyGroup(propertyID); 72 } 73 } 74 75 PropertyCascade::PropertyCascade(const MatchResult& matchResult, CascadeLevel maximumCascadeLevel, IncludedProperties includedProperties) 76 76 : m_matchResult(matchResult) 77 77 , m_includedProperties(includedProperties) 78 78 , m_maximumCascadeLevel(maximumCascadeLevel) 79 , m_direction(direction)80 79 { 81 80 buildCascade(); … … 87 86 , m_maximumCascadeLevel(maximumCascadeLevel) 88 87 , m_maximumCascadeLayerPriorityForRollback(maximumCascadeLayerPriorityForRollback) 89 , m_direction(parent.direction())90 , m_directionIsUnresolved(false)91 88 { 92 89 buildCascade(); … … 133 130 void PropertyCascade::set(CSSPropertyID id, CSSValue& cssValue, const MatchedProperties& matchedProperties, CascadeLevel cascadeLevel) 134 131 { 135 if (CSSProperty::isDirectionAwareProperty(id)) { 136 auto direction = this->direction(); 137 id = CSSProperty::resolveDirectionAwareProperty(id, direction.textDirection, direction.writingMode); 138 } 139 132 ASSERT(!CSSProperty::isDirectionAwareProperty(id)); 140 133 ASSERT(!shouldApplyPropertyInParseOrder(id)); 141 134 … … 168 161 void PropertyCascade::setDeferred(CSSPropertyID id, CSSValue& cssValue, const MatchedProperties& matchedProperties, CascadeLevel cascadeLevel) 169 162 { 170 ASSERT(!CSSProperty::isDirectionAwareProperty(id));171 163 ASSERT(shouldApplyPropertyInParseOrder(id)); 172 164 … … 305 297 } 306 298 307 PropertyCascade::Direction PropertyCascade::resolveDirectionAndWritingMode(Direction inheritedDirection) const 308 { 309 Direction result = inheritedDirection; 310 311 bool hadImportantWritingMode = false; 312 bool hadImportantDirection = false; 313 314 for (auto cascadeLevel : { CascadeLevel::UserAgent, CascadeLevel::User, CascadeLevel::Author }) { 315 for (const auto& matchedProperties : declarationsForCascadeLevel(m_matchResult, cascadeLevel)) { 316 for (unsigned i = 0, count = matchedProperties.properties->propertyCount(); i < count; ++i) { 317 auto property = matchedProperties.properties->propertyAt(i); 318 if (!property.value()->isPrimitiveValue() || property.value()->isCSSWideKeyword()) 319 continue; 320 switch (property.id()) { 321 case CSSPropertyWritingMode: 322 if (!hadImportantWritingMode || property.isImportant()) { 323 result.writingMode = downcast<CSSPrimitiveValue>(*property.value()); 324 hadImportantWritingMode = property.isImportant(); 325 } 326 break; 327 case CSSPropertyDirection: 328 if (!hadImportantDirection || property.isImportant()) { 329 result.textDirection = downcast<CSSPrimitiveValue>(*property.value()); 330 hadImportantDirection = property.isImportant(); 331 } 332 break; 333 default: 334 break; 335 } 336 } 337 } 338 } 339 340 return result; 341 } 342 343 PropertyCascade::Direction PropertyCascade::direction() const 344 { 345 if (m_directionIsUnresolved) { 346 m_direction = resolveDirectionAndWritingMode(m_direction); 347 m_directionIsUnresolved = false; 348 } 349 return m_direction; 350 } 351 352 } 353 } 299 } 300 } -
trunk/Source/WebCore/style/PropertyCascade.h
r291260 r291546 41 41 enum IncludedProperties { All, InheritedOnly }; 42 42 43 struct Direction { 44 TextDirection textDirection; 45 WritingMode writingMode; 46 }; 47 48 PropertyCascade(const MatchResult&, CascadeLevel, IncludedProperties, Direction); 43 PropertyCascade(const MatchResult&, CascadeLevel, IncludedProperties); 49 44 PropertyCascade(const PropertyCascade&, CascadeLevel, std::optional<CascadeLayerPriority> maximumCascadeLayerPriorityForRollback = { }); 50 45 … … 64 59 65 60 bool hasDeferredProperty(CSSPropertyID) const; 61 bool areDeferredInOrder(CSSPropertyID, CSSPropertyID) const; 66 62 const Property& deferredProperty(CSSPropertyID) const; 67 63 … … 71 67 const Vector<Property, 8>& deferredProperties() const { return m_deferredProperties; } 72 68 const HashMap<AtomString, Property>& customProperties() const { return m_customProperties; } 73 74 Direction direction() const;75 69 76 70 private: … … 84 78 static void setPropertyInternal(Property&, CSSPropertyID, CSSValue&, const MatchedProperties&, CascadeLevel); 85 79 86 Direction resolveDirectionAndWritingMode(Direction inheritedDirection) const;87 88 80 const MatchResult& m_matchResult; 89 81 const IncludedProperties m_includedProperties; 90 82 const CascadeLevel m_maximumCascadeLevel; 91 83 const std::optional<CascadeLayerPriority> m_maximumCascadeLayerPriorityForRollback; 92 mutable Direction m_direction;93 mutable bool m_directionIsUnresolved { true };94 84 95 85 Property m_properties[numCSSProperties + 2]; … … 118 108 } 119 109 110 inline bool PropertyCascade::areDeferredInOrder(CSSPropertyID id1, CSSPropertyID id2) const 111 { 112 ASSERT(hasDeferredProperty(id1)); 113 ASSERT(hasDeferredProperty(id2)); 114 return m_deferredPropertiesIndices.get(id1) < m_deferredPropertiesIndices.get(id2); 115 } 116 120 117 inline const PropertyCascade::Property& PropertyCascade::deferredProperty(CSSPropertyID id) const 121 118 { -
trunk/Source/WebCore/style/StyleBuilder.cpp
r291260 r291546 49 49 static const CSSPropertyID firstLowPriorityProperty = static_cast<CSSPropertyID>(lastHighPriorityProperty + 1); 50 50 51 inline PropertyCascade::Direction directionFromStyle(const RenderStyle& style)52 {53 return { style.direction(), style.writingMode() };54 }55 56 51 inline bool isValidVisitedLinkProperty(CSSPropertyID id) 57 52 { … … 82 77 83 78 Builder::Builder(RenderStyle& style, BuilderContext&& context, const MatchResult& matchResult, CascadeLevel cascadeLevel, PropertyCascade::IncludedProperties includedProperties) 84 : m_cascade(matchResult, cascadeLevel, includedProperties , directionFromStyle(style))79 : m_cascade(matchResult, cascadeLevel, includedProperties) 85 80 , m_state(*this, style, WTFMove(context)) 86 81 { … … 274 269 275 270 if (CSSProperty::isDirectionAwareProperty(id)) { 276 auto direction = m_cascade.direction();277 CSSPropertyID newId = CSSProperty::resolveDirectionAwareProperty(id, direction.textDirection, direction.writingMode);271 auto& style = m_state.style(); 272 CSSPropertyID newId = CSSProperty::resolveDirectionAwareProperty(id, style.direction(), style.writingMode()); 278 273 ASSERT(newId != id); 279 274 return applyProperty(newId, valueToApply.get(), linkMatchMask); … … 321 316 applyRollbackCascadeProperty(property, linkMatchMask); 322 317 return; 318 } else if (CSSProperty::isInLogicalPropertyGroup(id)) { 319 ASSERT(!CSSProperty::isDirectionAwareProperty(id)); 320 auto& style = m_state.style(); 321 auto logicalId = CSSProperty::unresolvePhysicalProperty(id, style.direction(), style.writingMode()); 322 bool hasPhysical = rollbackCascade->hasDeferredProperty(id); 323 bool hasLogical = rollbackCascade->hasDeferredProperty(logicalId); 324 if (hasPhysical || hasLogical) { 325 if (hasLogical && (!hasPhysical || rollbackCascade->areDeferredInOrder(id, logicalId))) 326 id = logicalId; 327 auto& property = rollbackCascade->deferredProperty(id); 328 applyRollbackCascadeProperty(property, linkMatchMask); 329 return; 330 } 323 331 } else if (rollbackCascade->hasDeferredProperty(id)) { 324 332 auto& property = rollbackCascade->deferredProperty(id);
Note: See TracChangeset
for help on using the changeset viewer.