[CSS Cascade Layers] Support 'revert-layer' value
https://bugs.webkit.org/show_bug.cgi?id=232236
<rdar://problem/84879369>
Reviewed by Simon Fraser.
LayoutTests/imported/w3c:
- web-platform-tests/css/css-cascade/revert-layer-008-expected.txt:
Source/WebCore:
'revert-layer' keyword rolls back the value computed by the cascade to the one coming from the layer below.
https://www.w3.org/TR/css-cascade-5/#revert-layer
- css/CSSPrimitiveValue.h:
- css/CSSValue.cpp:
(WebCore::CSSValue::isRevertLayerValue const):
- css/CSSValue.h:
- css/CSSValueKeywords.in:
Add a 'revert-layer' keyword.
- css/parser/CSSParserIdioms.h:
(WebCore::isCSSWideKeyword):
Make the keyword CSS-wide.
(WebCore::isValidCustomIdentifier):
(WebCore::Style::operator--):
Add decrement operator.
(WebCore::Style::allCascadeLevels): Deleted.
- style/ElementRuleCollector.cpp:
(WebCore::Style::ElementRuleCollector::addElementStyleProperties):
(WebCore::Style::ElementRuleCollector::transferMatchedRules):
Pass the casdade layer priority so it is available when resolving the cascade.
(WebCore::Style::ElementRuleCollector::addElementInlineStyleProperties):
Add a bit indicating if the properties came from a style attribute. This is needed for correct resolution of !important with cascade layers.
- style/ElementRuleCollector.h:
- style/PropertyCascade.cpp:
(WebCore::Style::PropertyCascade::PropertyCascade):
Specify cascade levels in terms of the maximum level instead of an OptionSet of levels. This makes things simpler.
Make it a member.
Provide maximum cascade layer priority when constructing rollback cascade.
(WebCore::Style::PropertyCascade::buildCascade):
(WebCore::Style::PropertyCascade::setPropertyInternal):
(WebCore::Style::PropertyCascade::addMatch):
Ignore properties with cascade level higher than the maximum.
(WebCore::Style::PropertyCascade::addImportantMatches):
Take cascade layers into accouny when sorting important matches.
(WebCore::Style::PropertyCascade::propertyCascadeForRollback const): Deleted.
Move rollback cascades to Builder.
(WebCore::Style::PropertyCascade::maximumCascadeLevel const):
(WebCore::Style::PropertyCascade::maximumCascadeLayerPriority const):
(WebCore::Style::Builder::Builder):
Specify cascade levels in terms of the maximum level instead of an OptionSet of levels.
(WebCore::Style::Builder::applyCascadeProperty):
(WebCore::Style::Builder::applyProperty):
Construct rollback cascade for 'revert-layer' case too. This is similar to 'revert'.
(WebCore::Style::Builder::ensureRollbackCascadeForRevert):
(WebCore::Style::Builder::ensureRollbackCascadeForRevertLayer):
Make the rollback cascades and store them into a HashMap.
(WebCore::Style::Builder::makeRollbackCascadeKey):
- style/StyleBuilder.h:
- style/StyleBuilderState.h:
- style/StyleResolver.cpp:
(WebCore::Style::Resolver::styleForKeyframe):
(WebCore::Style::Resolver::styleForPage):
(WebCore::Style::Resolver::applyMatchedProperties):
Adopt to the new interface.
LayoutTests: