Changeset 285624 in webkit
- Timestamp:
- Nov 11, 2021 4:24:18 AM (8 months ago)
- Location:
- trunk
- Files:
-
- 21 edited
-
LayoutTests/ChangeLog (modified) (1 diff)
-
LayoutTests/TestExpectations (modified) (1 diff)
-
LayoutTests/imported/w3c/ChangeLog (modified) (1 diff)
-
LayoutTests/imported/w3c/web-platform-tests/css/css-cascade/revert-layer-008-expected.txt (modified) (1 diff)
-
LayoutTests/imported/w3c/web-platform-tests/css/css-will-change/parsing/will-change-invalid-expected.txt (modified) (1 diff)
-
Source/WebCore/ChangeLog (modified) (1 diff)
-
Source/WebCore/css/CSSPrimitiveValue.h (modified) (1 diff)
-
Source/WebCore/css/CSSValue.cpp (modified) (1 diff)
-
Source/WebCore/css/CSSValue.h (modified) (1 diff)
-
Source/WebCore/css/CSSValueKeywords.in (modified) (1 diff)
-
Source/WebCore/css/parser/CSSParserIdioms.h (modified) (1 diff)
-
Source/WebCore/style/CascadeLevel.h (modified) (1 diff)
-
Source/WebCore/style/ElementRuleCollector.cpp (modified) (4 diffs)
-
Source/WebCore/style/ElementRuleCollector.h (modified) (1 diff)
-
Source/WebCore/style/MatchResult.h (modified) (4 diffs)
-
Source/WebCore/style/PropertyCascade.cpp (modified) (7 diffs)
-
Source/WebCore/style/PropertyCascade.h (modified) (5 diffs)
-
Source/WebCore/style/StyleBuilder.cpp (modified) (5 diffs)
-
Source/WebCore/style/StyleBuilder.h (modified) (3 diffs)
-
Source/WebCore/style/StyleBuilderState.h (modified) (2 diffs)
-
Source/WebCore/style/StyleResolver.cpp (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r285623 r285624 1 2021-11-11 Antti Koivisto <antti@apple.com> 2 3 [CSS Cascade Layers] Support 'revert-layer' value 4 https://bugs.webkit.org/show_bug.cgi?id=232236 5 <rdar://problem/84879369> 6 7 Reviewed by Simon Fraser. 8 9 * TestExpectations: 10 1 11 2021-11-10 Sergio Villar Senin <svillar@igalia.com> 2 12 -
trunk/LayoutTests/TestExpectations
r285623 r285624 2150 2150 imported/w3c/web-platform-tests/css/css-cascade/important-prop.html [ ImageOnlyFailure ] 2151 2151 webkit.org/b/187093 [ Debug ] imported/w3c/web-platform-tests/css/css-cascade/all-prop-initial-xml.html [ Skip ] 2152 webkit.org/b/232236 imported/w3c/web-platform-tests/css/css-cascade/revert-layer-001.html [ ImageOnlyFailure ]2153 webkit.org/b/232236 imported/w3c/web-platform-tests/css/css-cascade/revert-layer-002.html [ ImageOnlyFailure ]2154 webkit.org/b/232236 imported/w3c/web-platform-tests/css/css-cascade/revert-layer-003.html [ ImageOnlyFailure ]2155 webkit.org/b/232236 imported/w3c/web-platform-tests/css/css-cascade/revert-layer-004.html [ ImageOnlyFailure ]2156 webkit.org/b/232236 imported/w3c/web-platform-tests/css/css-cascade/revert-layer-005.html [ ImageOnlyFailure ]2157 webkit.org/b/232236 imported/w3c/web-platform-tests/css/css-cascade/revert-layer-006.html [ ImageOnlyFailure ]2158 webkit.org/b/232236 imported/w3c/web-platform-tests/css/css-cascade/revert-layer-007.html [ ImageOnlyFailure ]2159 2152 2160 2153 webkit.org/b/148801 imported/w3c/web-platform-tests/css/css-color/t422-rgba-onscreen-b.xht [ ImageOnlyFailure ] -
trunk/LayoutTests/imported/w3c/ChangeLog
r285621 r285624 1 2021-11-11 Antti Koivisto <antti@apple.com> 2 3 [CSS Cascade Layers] Support 'revert-layer' value 4 https://bugs.webkit.org/show_bug.cgi?id=232236 5 <rdar://problem/84879369> 6 7 Reviewed by Simon Fraser. 8 9 * web-platform-tests/css/css-cascade/revert-layer-008-expected.txt: 10 * web-platform-tests/css/css-will-change/parsing/will-change-invalid: 11 1 12 2021-11-11 Antoine Quint <graouts@webkit.org> 2 13 -
trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-cascade/revert-layer-008-expected.txt
r285493 r285624 1 1 2 FAIL 'revert-layer' should revert font-size to 20px and trigger a smooth transition assert_equals: expected "15px" but got "10px" 2 PASS 'revert-layer' should revert font-size to 20px and trigger a smooth transition 3 3 -
trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-will-change/parsing/will-change-invalid-expected.txt
r285499 r285624 48 48 PASS e.style['will-change'] = "revert, none" should not set the property value 49 49 PASS e.style['will-change'] = "revert, all" should not set the property value 50 FAIL e.style['will-change'] = "transform, revert-layer" should not set the property value assert_equals: expected "" but got "transform, revert-layer" 51 FAIL e.style['will-change'] = "revert-layer, transform" should not set the property value assert_equals: expected "" but got "revert-layer, transform" 50 PASS e.style['will-change'] = "transform, revert-layer" should not set the property value 51 PASS e.style['will-change'] = "revert-layer, transform" should not set the property value 52 52 PASS e.style['will-change'] = "revert-layer, initial" should not set the property value 53 53 PASS e.style['will-change'] = "revert-layer, inherit" should not set the property value 54 54 PASS e.style['will-change'] = "revert-layer, unset" should not set the property value 55 55 PASS e.style['will-change'] = "revert-layer, revert" should not set the property value 56 FAIL e.style['will-change'] = "revert-layer, revert-layer" should not set the property value assert_equals: expected "" but got "revert-layer, revert-layer" 56 PASS e.style['will-change'] = "revert-layer, revert-layer" should not set the property value 57 57 PASS e.style['will-change'] = "revert-layer, default" should not set the property value 58 58 PASS e.style['will-change'] = "revert-layer, will-change" should not set the property value -
trunk/Source/WebCore/ChangeLog
r285623 r285624 1 2021-11-11 Antti Koivisto <antti@apple.com> 2 3 [CSS Cascade Layers] Support 'revert-layer' value 4 https://bugs.webkit.org/show_bug.cgi?id=232236 5 <rdar://problem/84879369> 6 7 Reviewed by Simon Fraser. 8 9 'revert-layer' keyword rolls back the value computed by the cascade to the one coming from the layer below. 10 11 https://www.w3.org/TR/css-cascade-5/#revert-layer 12 13 * css/CSSPrimitiveValue.h: 14 * css/CSSValue.cpp: 15 (WebCore::CSSValue::isRevertLayerValue const): 16 * css/CSSValue.h: 17 * css/CSSValueKeywords.in: 18 19 Add a 'revert-layer' keyword. 20 21 * css/parser/CSSParserIdioms.h: 22 (WebCore::isCSSWideKeyword): 23 24 Make the keyword CSS-wide. 25 26 (WebCore::isValidCustomIdentifier): 27 * style/CascadeLevel.h: 28 (WebCore::Style::operator--): 29 30 Add decrement operator. 31 32 (WebCore::Style::allCascadeLevels): Deleted. 33 * style/ElementRuleCollector.cpp: 34 (WebCore::Style::ElementRuleCollector::addElementStyleProperties): 35 (WebCore::Style::ElementRuleCollector::transferMatchedRules): 36 37 Pass the casdade layer priority so it is available when resolving the cascade. 38 39 (WebCore::Style::ElementRuleCollector::addElementInlineStyleProperties): 40 41 Add a bit indicating if the properties came from a style attribute. This is needed for correct resolution of !important with cascade layers. 42 43 * style/ElementRuleCollector.h: 44 * style/PropertyCascade.cpp: 45 (WebCore::Style::PropertyCascade::PropertyCascade): 46 47 Specify cascade levels in terms of the maximum level instead of an OptionSet of levels. This makes things simpler. 48 Make it a member. 49 Provide maximum cascade layer priority when constructing rollback cascade. 50 51 (WebCore::Style::PropertyCascade::buildCascade): 52 (WebCore::Style::PropertyCascade::setPropertyInternal): 53 (WebCore::Style::PropertyCascade::addMatch): 54 55 Ignore properties with cascade level higher than the maximum. 56 57 (WebCore::Style::PropertyCascade::addImportantMatches): 58 59 Take cascade layers into accouny when sorting important matches. 60 61 (WebCore::Style::PropertyCascade::propertyCascadeForRollback const): Deleted. 62 63 Move rollback cascades to Builder. 64 65 * style/PropertyCascade.h: 66 (WebCore::Style::PropertyCascade::maximumCascadeLevel const): 67 (WebCore::Style::PropertyCascade::maximumCascadeLayerPriority const): 68 * style/StyleBuilder.cpp: 69 (WebCore::Style::Builder::Builder): 70 71 Specify cascade levels in terms of the maximum level instead of an OptionSet of levels. 72 73 (WebCore::Style::Builder::applyCascadeProperty): 74 (WebCore::Style::Builder::applyProperty): 75 76 Construct rollback cascade for 'revert-layer' case too. This is similar to 'revert'. 77 78 (WebCore::Style::Builder::ensureRollbackCascadeForRevert): 79 (WebCore::Style::Builder::ensureRollbackCascadeForRevertLayer): 80 81 Make the rollback cascades and store them into a HashMap. 82 83 (WebCore::Style::Builder::makeRollbackCascadeKey): 84 * style/StyleBuilder.h: 85 * style/StyleBuilderState.h: 86 * style/StyleResolver.cpp: 87 (WebCore::Style::Resolver::styleForKeyframe): 88 (WebCore::Style::Resolver::styleForPage): 89 (WebCore::Style::Resolver::applyMatchedProperties): 90 91 Adopt to the new interface. 92 1 93 2021-11-10 Sergio Villar Senin <svillar@igalia.com> 2 94 -
trunk/Source/WebCore/css/CSSPrimitiveValue.h
r285493 r285624 121 121 bool isUnsetValue() const { return valueID() == CSSValueUnset; } 122 122 bool isRevertValue() const { return valueID() == CSSValueRevert; } 123 bool isRevertLayerValue() const { return valueID() == CSSValueRevertLayer; } 123 124 bool isCSSWideKeyword() const; 124 125 -
trunk/Source/WebCore/css/CSSValue.cpp
r285493 r285624 511 511 } 512 512 513 bool CSSValue::isRevertLayerValue() const 514 { 515 return is<CSSPrimitiveValue>(*this) && downcast<CSSPrimitiveValue>(*this).isRevertLayerValue(); 516 } 517 513 518 bool CSSValue::isCSSWideKeyword() const 514 519 { -
trunk/Source/WebCore/css/CSSValue.h
r285493 r285624 112 112 bool isUnsetValue() const; 113 113 bool isRevertValue() const; 114 bool isRevertLayerValue() const; 114 115 bool isCSSWideKeyword() const; 115 116 bool treatAsInitialValue(CSSPropertyID) const; -
trunk/Source/WebCore/css/CSSValueKeywords.in
r285615 r285624 6 6 unset 7 7 revert 8 revert-layer 8 9 9 10 // -
trunk/Source/WebCore/css/parser/CSSParserIdioms.h
r285493 r285624 61 61 bool isValueAllowedInMode(unsigned short, CSSParserMode); 62 62 63 staticinline bool isCSSWideKeyword(CSSValueID valueID)63 inline bool isCSSWideKeyword(CSSValueID valueID) 64 64 { 65 return valueID == CSSValueInitial || valueID == CSSValueInherit || valueID == CSSValueUnset || valueID == CSSValueRevert; 65 switch (valueID) { 66 case CSSValueInitial: 67 case CSSValueInherit: 68 case CSSValueUnset: 69 case CSSValueRevert: 70 case CSSValueRevertLayer: 71 return true; 72 default: 73 return false; 74 }; 66 75 } 67 76 68 staticinline bool isValidCustomIdentifier(CSSValueID valueID)77 inline bool isValidCustomIdentifier(CSSValueID valueID) 69 78 { 70 79 // "default" is obsolete as a CSS-wide keyword but is still not allowed as a custom identifier. -
trunk/Source/WebCore/style/CascadeLevel.h
r285493 r285624 37 37 }; 38 38 39 static constexpr OptionSet<CascadeLevel> allCascadeLevels() { return { CascadeLevel::UserAgent, CascadeLevel::User, CascadeLevel::Author }; } 39 inline CascadeLevel& operator--(CascadeLevel& level) 40 { 41 switch (level) { 42 case CascadeLevel::Author: 43 return level = CascadeLevel::User; 44 case CascadeLevel::User: 45 return level = CascadeLevel::UserAgent; 46 case CascadeLevel::UserAgent: 47 ASSERT_NOT_REACHED(); 48 return level; 49 } 50 } 40 51 41 52 } -
trunk/Source/WebCore/style/ElementRuleCollector.cpp
r285622 r285624 125 125 } 126 126 127 inline void ElementRuleCollector::addElementStyleProperties(const StyleProperties* propertySet, bool isCacheable )127 inline void ElementRuleCollector::addElementStyleProperties(const StyleProperties* propertySet, bool isCacheable, FromStyleAttribute fromStyleAttribute) 128 128 { 129 129 if (!propertySet || propertySet->isEmpty()) … … 133 133 m_result.isCacheable = false; 134 134 135 addMatchedProperties({ propertySet }, DeclarationOrigin::Author); 135 auto matchedProperty = MatchedProperties { propertySet }; 136 matchedProperty.fromStyleAttribute = fromStyleAttribute; 137 addMatchedProperties(WTFMove(matchedProperty), DeclarationOrigin::Author); 136 138 } 137 139 … … 202 204 addMatchedProperties({ 203 205 &matchedRule.ruleData->styleRule().properties(), 204 static_cast<uint 16_t>(matchedRule.ruleData->linkMatchType()),206 static_cast<uint8_t>(matchedRule.ruleData->linkMatchType()), 205 207 matchedRule.ruleData->propertyAllowlist(), 206 matchedRule.styleScopeOrdinal 208 matchedRule.styleScopeOrdinal, 209 FromStyleAttribute::No, 210 matchedRule.cascadeLayerPriority 207 211 }, declarationOrigin); 208 212 } … … 567 571 // FIXME: Media control shadow trees seem to have problems with caching. 568 572 bool isInlineStyleCacheable = !inlineStyle->isMutable() && !element().isInShadowTree(); 569 addElementStyleProperties(inlineStyle, isInlineStyleCacheable );573 addElementStyleProperties(inlineStyle, isInlineStyleCacheable, FromStyleAttribute::Yes); 570 574 } 571 575 -
trunk/Source/WebCore/style/ElementRuleCollector.h
r285622 r285624 98 98 99 99 private: 100 void addElementStyleProperties(const StyleProperties*, bool isCacheable = true );100 void addElementStyleProperties(const StyleProperties*, bool isCacheable = true, FromStyleAttribute = FromStyleAttribute::No); 101 101 102 102 void matchUARules(const RuleSet&); -
trunk/Source/WebCore/style/MatchResult.h
r285574 r285624 26 26 27 27 #include "PropertyAllowlist.h" 28 #include "RuleSet.h" 28 29 #include "SelectorChecker.h" 29 30 #include "StyleProperties.h" … … 33 34 namespace WebCore::Style { 34 35 36 enum class FromStyleAttribute : bool { No, Yes }; 37 35 38 struct MatchedProperties { 36 39 RefPtr<const StyleProperties> properties; 37 uint 16_t linkMatchType { SelectorChecker::MatchAll };40 uint8_t linkMatchType { SelectorChecker::MatchAll }; 38 41 PropertyAllowlist allowlistType { PropertyAllowlist::None }; 39 42 ScopeOrdinal styleScopeOrdinal { ScopeOrdinal::Element }; 43 FromStyleAttribute fromStyleAttribute { FromStyleAttribute::No }; 44 CascadeLayerPriority cascadeLayerPriority { RuleSet::cascadeLayerPriorityForUnlayered }; 40 45 }; 41 46 … … 67 72 && a.linkMatchType == b.linkMatchType 68 73 && a.allowlistType == b.allowlistType 69 && a.styleScopeOrdinal == b.styleScopeOrdinal; 74 && a.styleScopeOrdinal == b.styleScopeOrdinal 75 && a.fromStyleAttribute == b.fromStyleAttribute 76 && a.cascadeLayerPriority == b.cascadeLayerPriority; 70 77 } 71 78 … … 77 84 inline void add(Hasher& hasher, const MatchedProperties& matchedProperties) 78 85 { 79 add(hasher, matchedProperties.properties.get(), matchedProperties.linkMatchType, matchedProperties.allowlistType, matchedProperties.styleScopeOrdinal); 86 add(hasher, 87 matchedProperties.properties.get(), 88 matchedProperties.linkMatchType, 89 matchedProperties.allowlistType, 90 matchedProperties.styleScopeOrdinal, 91 matchedProperties.fromStyleAttribute, 92 matchedProperties.cascadeLayerPriority 93 ); 80 94 } 81 95 -
trunk/Source/WebCore/style/PropertyCascade.cpp
r285493 r285624 72 72 } 73 73 74 PropertyCascade::PropertyCascade(const MatchResult& matchResult, OptionSet<CascadeLevel> cascadeLevels, IncludedProperties includedProperties, Direction direction)74 PropertyCascade::PropertyCascade(const MatchResult& matchResult, CascadeLevel maximumCascadeLevel, IncludedProperties includedProperties, Direction direction) 75 75 : m_matchResult(matchResult) 76 76 , m_includedProperties(includedProperties) 77 , m_maximumCascadeLevel(maximumCascadeLevel) 77 78 , m_direction(direction) 78 79 { 79 buildCascade( cascadeLevels);80 } 81 82 PropertyCascade::PropertyCascade(const PropertyCascade& parent, OptionSet<CascadeLevel> cascadeLevels)80 buildCascade(); 81 } 82 83 PropertyCascade::PropertyCascade(const PropertyCascade& parent, CascadeLevel maximumCascadeLevel, CascadeLayerPriority maximumCascadeLayerPriority) 83 84 : m_matchResult(parent.m_matchResult) 84 85 , m_includedProperties(parent.m_includedProperties) 86 , m_maximumCascadeLevel(maximumCascadeLevel) 87 , m_maximumCascadeLayerPriority(maximumCascadeLayerPriority) 85 88 , m_direction(parent.direction()) 86 89 , m_directionIsUnresolved(false) 87 90 { 88 buildCascade( cascadeLevels);91 buildCascade(); 89 92 } 90 93 91 94 PropertyCascade::~PropertyCascade() = default; 92 95 93 void PropertyCascade::buildCascade( OptionSet<CascadeLevel> cascadeLevels)96 void PropertyCascade::buildCascade() 94 97 { 95 98 OptionSet<CascadeLevel> cascadeLevelsWithImportant; 96 99 97 for (auto cascadeLevel : cascadeLevels) { 100 for (auto cascadeLevel : { CascadeLevel::UserAgent, CascadeLevel::User, CascadeLevel::Author }) { 101 if (cascadeLevel > m_maximumCascadeLevel) 102 break; 98 103 bool hasImportant = addNormalMatches(cascadeLevel); 99 104 if (hasImportant) … … 114 119 property.level = cascadeLevel; 115 120 property.styleScopeOrdinal = matchedProperties.styleScopeOrdinal; 121 property.cascadeLayerPriority = matchedProperties.cascadeLayerPriority; 122 116 123 if (matchedProperties.linkMatchType == SelectorChecker::MatchAll) { 117 124 property.cssValue[0] = &cssValue; … … 171 178 bool PropertyCascade::addMatch(const MatchedProperties& matchedProperties, CascadeLevel cascadeLevel, bool important) 172 179 { 180 if (matchedProperties.cascadeLayerPriority > m_maximumCascadeLayerPriority && cascadeLevel == m_maximumCascadeLevel && matchedProperties.styleScopeOrdinal == ScopeOrdinal::Element) 181 return false; 182 173 183 auto& styleProperties = *matchedProperties.properties; 174 184 auto propertyAllowlist = matchedProperties.allowlistType; … … 238 248 void PropertyCascade::addImportantMatches(CascadeLevel cascadeLevel) 239 249 { 240 struct I ndexAndOrdinal{250 struct ImportantMatch { 241 251 unsigned index; 242 252 ScopeOrdinal ordinal; 253 CascadeLayerPriority layerPriority; 254 FromStyleAttribute fromStyleAttribute; 243 255 }; 244 Vector<I ndexAndOrdinal> importantMatches;245 bool hasMatchesFromOtherScopes = false;256 Vector<ImportantMatch> importantMatches; 257 bool hasMatchesFromOtherScopesOrLayers = false; 246 258 247 259 auto& matchedDeclarations = declarationsForCascadeLevel(m_matchResult, cascadeLevel); … … 253 265 continue; 254 266 255 importantMatches.append({ i, matchedProperties.styleScopeOrdinal });256 257 if (matchedProperties.styleScopeOrdinal != ScopeOrdinal::Element )258 hasMatchesFromOtherScopes = true;267 importantMatches.append({ i, matchedProperties.styleScopeOrdinal, matchedProperties.cascadeLayerPriority, matchedProperties.fromStyleAttribute }); 268 269 if (matchedProperties.styleScopeOrdinal != ScopeOrdinal::Element || matchedProperties.cascadeLayerPriority != RuleSet::cascadeLayerPriorityForUnlayered) 270 hasMatchesFromOtherScopesOrLayers = true; 259 271 } 260 272 … … 262 274 return; 263 275 264 if (hasMatchesFromOtherScopes) { 265 // For !important properties a later shadow tree wins. 276 if (hasMatchesFromOtherScopesOrLayers) { 266 277 // Match results are sorted in reverse tree context order so this is not needed for normal properties. 267 std::stable_sort(importantMatches.begin(), importantMatches.end(), [] (const IndexAndOrdinal& a, const IndexAndOrdinal& b) { 268 return a.ordinal < b.ordinal; 278 std::stable_sort(importantMatches.begin(), importantMatches.end(), [] (auto& a, auto& b) { 279 // For !important properties a later shadow tree wins. 280 if (a.ordinal != b.ordinal) 281 return a.ordinal < b.ordinal; 282 // Lower priority layer wins, except if style attribute is involved. 283 if (a.fromStyleAttribute != b.fromStyleAttribute) 284 return a.fromStyleAttribute == FromStyleAttribute::No; 285 return a.layerPriority > b.layerPriority; 269 286 }); 270 287 } … … 272 289 for (auto& match : importantMatches) 273 290 addMatch(matchedDeclarations[match.index], cascadeLevel, true); 274 }275 276 const PropertyCascade* PropertyCascade::propertyCascadeForRollback(CascadeLevel cascadeLevel) const277 {278 switch (cascadeLevel) {279 case CascadeLevel::Author:280 if (!m_authorRollbackCascade) {281 auto cascadeLevels = OptionSet<CascadeLevel> { CascadeLevel::UserAgent, CascadeLevel::User };282 m_authorRollbackCascade = makeUnique<const PropertyCascade>(*this, cascadeLevels);283 }284 return m_authorRollbackCascade.get();285 286 case CascadeLevel::User:287 if (!m_userRollbackCascade) {288 auto cascadeLevels = OptionSet<CascadeLevel> { CascadeLevel::UserAgent };289 m_userRollbackCascade = makeUnique<const PropertyCascade>(*this, cascadeLevels);290 }291 return m_userRollbackCascade.get();292 293 case CascadeLevel::UserAgent:294 return nullptr;295 }296 ASSERT_NOT_REACHED();297 return nullptr;298 291 } 299 292 -
trunk/Source/WebCore/style/PropertyCascade.h
r285574 r285624 47 47 }; 48 48 49 PropertyCascade(const MatchResult&, OptionSet<CascadeLevel>, IncludedProperties, Direction);50 PropertyCascade(const PropertyCascade&, OptionSet<CascadeLevel>);49 PropertyCascade(const MatchResult&, CascadeLevel, IncludedProperties, Direction); 50 PropertyCascade(const PropertyCascade&, CascadeLevel, CascadeLayerPriority maximumCascadeLayerPriority = RuleSet::cascadeLayerPriorityForUnlayered); 51 51 52 52 ~PropertyCascade(); … … 56 56 CascadeLevel level; 57 57 ScopeOrdinal styleScopeOrdinal; 58 CascadeLayerPriority cascadeLayerPriority; 58 59 CSSValue* cssValue[3]; // Values for link match states MatchDefault, MatchLink and MatchVisited 59 60 }; … … 70 71 Direction direction() const; 71 72 72 const PropertyCascade* propertyCascadeForRollback(CascadeLevel) const; 73 auto maximumCascadeLevel() const { return m_maximumCascadeLevel; } 74 auto maximumCascadeLayerPriority() const { return m_maximumCascadeLayerPriority; } 73 75 74 76 private: 75 void buildCascade( OptionSet<CascadeLevel>);77 void buildCascade(); 76 78 bool addNormalMatches(CascadeLevel); 77 79 void addImportantMatches(CascadeLevel); … … 86 88 const MatchResult& m_matchResult; 87 89 const IncludedProperties m_includedProperties; 90 const CascadeLevel m_maximumCascadeLevel; 91 const CascadeLayerPriority m_maximumCascadeLayerPriority { RuleSet::cascadeLayerPriorityForUnlayered }; 88 92 mutable Direction m_direction; 89 93 mutable bool m_directionIsUnresolved { true }; … … 94 98 Vector<Property, 8> m_deferredProperties; 95 99 HashMap<AtomString, Property> m_customProperties; 96 97 mutable std::unique_ptr<const PropertyCascade> m_authorRollbackCascade;98 mutable std::unique_ptr<const PropertyCascade> m_userRollbackCascade;99 100 }; 100 101 -
trunk/Source/WebCore/style/StyleBuilder.cpp
r285493 r285624 81 81 } 82 82 83 Builder::Builder(RenderStyle& style, BuilderContext&& context, const MatchResult& matchResult, OptionSet<CascadeLevel> cascadeLevels, PropertyCascade::IncludedProperties includedProperties)84 : m_cascade(matchResult, cascadeLevel s, includedProperties, directionFromStyle(style))83 Builder::Builder(RenderStyle& style, BuilderContext&& context, const MatchResult& matchResult, CascadeLevel cascadeLevel, PropertyCascade::IncludedProperties includedProperties) 84 : m_cascade(matchResult, cascadeLevel, includedProperties, directionFromStyle(style)) 85 85 , m_state(*this, style, WTFMove(context)) 86 86 { … … 120 120 121 121 ASSERT(!m_state.fontDirty()); 122 }123 124 void Builder::applyPropertyValue(CSSPropertyID propertyID, CSSValue* value)125 {126 if (!value)127 return;128 129 applyProperty(propertyID, *value, SelectorChecker::MatchDefault);130 131 m_state.updateFont();132 122 } 133 123 … … 246 236 m_state.m_cascadeLevel = property.level; 247 237 m_state.m_styleScopeOrdinal = property.styleScopeOrdinal; 238 m_state.m_cascadeLayerPriority = property.cascadeLayerPriority; 248 239 249 240 auto applyWithLinkMatch = [&](SelectorChecker::LinkMatchMask linkMatch) { … … 296 287 bool isUnset = valueToApply->isUnsetValue() || customPropertyValueID == CSSValueUnset; 297 288 bool isRevert = valueToApply->isRevertValue() || customPropertyValueID == CSSValueRevert; 298 299 if (isRevert) { 300 if (auto* rollback = m_cascade.propertyCascadeForRollback(m_state.m_cascadeLevel)) { 289 bool isRevertLayer = valueToApply->isRevertLayerValue() || customPropertyValueID == CSSValueRevertLayer; 290 291 if (isRevert || isRevertLayer) { 292 auto* rollbackCascade = isRevert 293 ? ensureRollbackCascadeForRevert(m_state.m_cascadeLevel) 294 : ensureRollbackCascadeForRevertLayer(m_state.m_cascadeLevel, m_state.m_cascadeLayerPriority); 295 296 if (rollbackCascade) { 301 297 // With the rollback cascade built, we need to obtain the property and apply it. If the property is 302 // not present, then we behave like "unset." Otherwise we apply the property instead of 303 // our own. 298 // not present, then we behave like "unset." Otherwise we apply the property instead of our own. 299 SetForScope cascadeLevelScope(m_state.m_cascadeLevel, rollbackCascade->maximumCascadeLevel()); 300 SetForScope cascadeLayerPriorityScope(m_state.m_cascadeLayerPriority, rollbackCascade->maximumCascadeLayerPriority()); 304 301 if (customPropertyValue) { 305 if (customPropertyRegistered && customPropertyRegistered->inherits && rollback ->hasCustomProperty(customPropertyValue->name())) {306 auto property = rollback ->customProperty(customPropertyValue->name());302 if (customPropertyRegistered && customPropertyRegistered->inherits && rollbackCascade->hasCustomProperty(customPropertyValue->name())) { 303 auto property = rollbackCascade->customProperty(customPropertyValue->name()); 307 304 if (property.cssValue[linkMatchMask]) 308 305 applyProperty(property.id, *property.cssValue[linkMatchMask], linkMatchMask); 309 306 return; 310 307 } 311 } else if (rollback ->hasProperty(id)) {312 auto& property = rollback ->property(id);308 } else if (rollbackCascade->hasProperty(id)) { 309 auto& property = rollbackCascade->property(id); 313 310 if (property.cssValue[linkMatchMask]) 314 311 applyProperty(property.id, *property.cssValue[linkMatchMask], linkMatchMask); … … 374 371 } 375 372 376 } 377 } 373 const PropertyCascade* Builder::ensureRollbackCascadeForRevert(CascadeLevel rollbackCascadeLevel) 374 { 375 if (rollbackCascadeLevel == CascadeLevel::UserAgent) 376 return nullptr; 377 378 auto key = makeRollbackCascadeKey(rollbackCascadeLevel, RuleSet::cascadeLayerPriorityForUnlayered); 379 return m_rollbackCascades.ensure(key, [&] { 380 return makeUnique<const PropertyCascade>(m_cascade, --rollbackCascadeLevel, RuleSet::cascadeLayerPriorityForUnlayered); 381 }).iterator->value.get(); 382 } 383 384 const PropertyCascade* Builder::ensureRollbackCascadeForRevertLayer(CascadeLevel cascadeLevel, CascadeLayerPriority rollbackLayerPriority) 385 { 386 if (!rollbackLayerPriority) 387 return nullptr; 388 389 auto key = makeRollbackCascadeKey(cascadeLevel, rollbackLayerPriority); 390 return m_rollbackCascades.ensure(key, [&] { 391 return makeUnique<const PropertyCascade>(m_cascade, cascadeLevel, rollbackLayerPriority - 1); 392 }).iterator->value.get(); 393 } 394 395 auto Builder::makeRollbackCascadeKey(CascadeLevel cascadeLevel, CascadeLayerPriority cascadeLayerPriority) -> RollbackCascadeKey 396 { 397 return { static_cast<unsigned>(cascadeLevel), static_cast<unsigned>(cascadeLayerPriority) }; 398 } 399 400 } 401 } -
trunk/Source/WebCore/style/StyleBuilder.h
r285493 r285624 36 36 WTF_MAKE_FAST_ALLOCATED; 37 37 public: 38 Builder(RenderStyle&, BuilderContext&&, const MatchResult&, OptionSet<CascadeLevel>, PropertyCascade::IncludedProperties = PropertyCascade::IncludedProperties::All);38 Builder(RenderStyle&, BuilderContext&&, const MatchResult&, CascadeLevel, PropertyCascade::IncludedProperties = PropertyCascade::IncludedProperties::All); 39 39 ~Builder(); 40 40 … … 45 45 void applyProperty(CSSPropertyID propertyID) { applyProperties(propertyID, propertyID); } 46 46 void applyCustomProperty(const String& name); 47 48 void applyPropertyValue(CSSPropertyID, CSSValue*);49 47 50 48 BuilderState& state() { return m_state; } … … 64 62 RefPtr<CSSValue> resolvedVariableValue(CSSPropertyID, const CSSValue&); 65 63 64 const PropertyCascade* ensureRollbackCascadeForRevert(CascadeLevel); 65 const PropertyCascade* ensureRollbackCascadeForRevertLayer(CascadeLevel, CascadeLayerPriority); 66 67 using RollbackCascadeKey = std::pair<unsigned, unsigned>; 68 RollbackCascadeKey makeRollbackCascadeKey(CascadeLevel, CascadeLayerPriority); 69 66 70 const PropertyCascade m_cascade; 71 // Rollback cascades are build on demand to resolve 'revert' and 'revert-layer' keywords. 72 HashMap<RollbackCascadeKey, std::unique_ptr<const PropertyCascade>> m_rollbackCascades; 73 67 74 BuilderState m_state; 68 75 }; -
trunk/Source/WebCore/style/StyleBuilderState.h
r285493 r285624 30 30 #include "CascadeLevel.h" 31 31 #include "RenderStyle.h" 32 #include "RuleSet.h" 32 33 #include "SelectorChecker.h" 33 34 #include <wtf/Bitmap.h> … … 137 138 CascadeLevel m_cascadeLevel { }; 138 139 ScopeOrdinal m_styleScopeOrdinal { }; 140 CascadeLayerPriority m_cascadeLayerPriority { }; 139 141 SelectorChecker::LinkMatchMask m_linkMatch { }; 140 142 -
trunk/Source/WebCore/style/StyleResolver.cpp
r285493 r285624 284 284 state.setParentStyle(RenderStyle::clonePtr(context.parentStyle ? *context.parentStyle : *elementStyle)); 285 285 286 Builder builder(*state.style(), builderContext(state), result, { CascadeLevel::Author });286 Builder builder(*state.style(), builderContext(state), result, CascadeLevel::Author); 287 287 builder.applyAllProperties(); 288 288 … … 437 437 auto& result = collector.matchResult(); 438 438 439 Builder builder(*state.style(), builderContext(state), result, { CascadeLevel::Author });439 Builder builder(*state.style(), builderContext(state), result, CascadeLevel::Author); 440 440 builder.applyAllProperties(); 441 441 … … 556 556 // can look at them later to figure out if this is a styled form control or not. 557 557 auto userAgentStyle = RenderStyle::clonePtr(style); 558 Builder builder(*userAgentStyle, builderContext(state), matchResult, { CascadeLevel::UserAgent });558 Builder builder(*userAgentStyle, builderContext(state), matchResult, CascadeLevel::UserAgent); 559 559 builder.applyAllProperties(); 560 560 … … 562 562 } 563 563 564 Builder builder(*state.style(), builderContext(state), matchResult, allCascadeLevels(), includedProperties);564 Builder builder(*state.style(), builderContext(state), matchResult, CascadeLevel::Author, includedProperties); 565 565 566 566 // High priority properties may affect resolution of other properties (they are mostly font related).
Note: See TracChangeset
for help on using the changeset viewer.