mirror of
https://github.com/servo/servo.git
synced 2025-10-04 02:29:12 +01:00
style: Fix style attribute important and revert-layer behavior
By modeling it as a separate layer that behaves somewhat specially. See https://github.com/w3c/csswg-drafts/issues/6872. The remaining revert-layer tests that we fail are because either we don't implement a feature (like @property) or because it's used in keyframes (where revert is a bit unspecified and we have existing issues with it). Differential Revision: https://phabricator.services.mozilla.com/D133373
This commit is contained in:
parent
5c0f044d39
commit
50510715a2
5 changed files with 67 additions and 31 deletions
|
@ -28,9 +28,25 @@ pub struct LayerOrder(u16);
|
|||
impl LayerOrder {
|
||||
/// The order of the root layer.
|
||||
pub const fn root() -> Self {
|
||||
Self(std::u16::MAX - 1)
|
||||
}
|
||||
|
||||
/// The order of the style attribute layer.
|
||||
pub const fn style_attribute() -> Self {
|
||||
Self(std::u16::MAX)
|
||||
}
|
||||
|
||||
/// Returns whether this layer is for the style attribute, which behaves
|
||||
/// differently in terms of !important, see
|
||||
/// https://github.com/w3c/csswg-drafts/issues/6872
|
||||
///
|
||||
/// (This is a bit silly, mind-you, but it's needed so that revert-layer
|
||||
/// behaves correctly).
|
||||
#[inline]
|
||||
pub fn is_style_attribute_layer(&self) -> bool {
|
||||
*self == Self::style_attribute()
|
||||
}
|
||||
|
||||
/// The first cascade layer order.
|
||||
pub const fn first() -> Self {
|
||||
Self(0)
|
||||
|
@ -39,7 +55,7 @@ impl LayerOrder {
|
|||
/// Increment the cascade layer order.
|
||||
#[inline]
|
||||
pub fn inc(&mut self) {
|
||||
if self.0 != std::u16::MAX {
|
||||
if self.0 != std::u16::MAX - 1 {
|
||||
self.0 += 1;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue