diff options
author | Emilio Cobos Álvarez <emilio@crisal.io> | 2023-06-06 16:49:13 +0200 |
---|---|---|
committer | Oriol Brufau <obrufau@igalia.com> | 2023-06-09 10:22:22 +0200 |
commit | 8bb7d98f0ce2fdfa49f71c1379dd2bcde3aeac29 (patch) | |
tree | 962d77a26b4632f822381045d6d23bceaedded89 /components/style/properties/declaration_block.rs | |
parent | 26c10339e332dbfe3607be57d509e25e30267523 (diff) | |
download | servo-8bb7d98f0ce2fdfa49f71c1379dd2bcde3aeac29.tar.gz servo-8bb7d98f0ce2fdfa49f71c1379dd2bcde3aeac29.zip |
style: Add support for the revert-layer keyword
This patch looks bigger than it is, but it's mostly because
of plumbing.
To implement revert-layer we need not only the cascade origin of the
declaration, but the whole cascade level, plus also the layer order.
In order to do this, encapsulate these two things inside a 32-bit
`CascadePriority` struct and plumb it through the rule tree and so on.
This allows us to remove the packing and unpacking of CascadeLevel,
though I kept the ShadowCascadeOrder limit for now in case we need to
reintroduce it.
Fix `!important` behavior of layers while at it (implementing it in
`CascadeLevel::cmp`, spec quote included since it was tricky to find)
since some revert-layer tests were depending on it.
The style attribute test is failing now, but follow-up commit fixes
it, see spec issue.
In terms of the actual keyword implementation, it's sort of
straight-forward: We implement revert and revert-layer in a shared
way, by storing the cascade priority that reverted it.
Differential Revision: https://phabricator.services.mozilla.com/D133372
Diffstat (limited to 'components/style/properties/declaration_block.rs')
-rw-r--r-- | components/style/properties/declaration_block.rs | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/components/style/properties/declaration_block.rs b/components/style/properties/declaration_block.rs index 980d3de11ff..01b390f0fca 100644 --- a/components/style/properties/declaration_block.rs +++ b/components/style/properties/declaration_block.rs @@ -7,15 +7,17 @@ #![deny(missing_docs)] use super::*; +use crate::applicable_declarations::CascadePriority; use crate::context::QuirksMode; use crate::custom_properties::CustomPropertiesBuilder; use crate::error_reporting::{ContextualParseError, ParseErrorReporter}; use crate::parser::ParserContext; use crate::properties::animated_properties::{AnimationValue, AnimationValueMap}; +use crate::rule_tree::CascadeLevel; use crate::selector_parser::SelectorImpl; use crate::shared_lock::Locked; use crate::str::{CssString, CssStringWriter}; -use crate::stylesheets::{CssRuleType, Origin, UrlExtraData}; +use crate::stylesheets::{CssRuleType, Origin, UrlExtraData, layer_rule::LayerOrder}; use crate::values::computed::Context; use cssparser::{parse_important, CowRcStr, DeclarationListParser, ParserInput}; use cssparser::{AtRuleParser, DeclarationParser, Delimiter, ParseErrorKind, Parser}; @@ -898,7 +900,7 @@ impl PropertyDeclarationBlock { for declaration in self.normal_declaration_iter() { if let PropertyDeclaration::Custom(ref declaration) = *declaration { - builder.cascade(declaration, Origin::Author); + builder.cascade(declaration, CascadePriority::new(CascadeLevel::same_tree_author_normal(), LayerOrder::root())); } } |