style: Add support for parsing the content-visibility property from the CSS Contain specification

Add initial parsing support for the CSS `content-visibility` attribute.
Currently these parsed values have no effect.

Differential Revision: https://phabricator.services.mozilla.com/D140834
This commit is contained in:
Martin Robinson 2023-06-06 23:56:59 +02:00 committed by Oriol Brufau
parent 8016c434b0
commit eb96b29af0
7 changed files with 44 additions and 6 deletions

View file

@ -120,5 +120,4 @@ COUNTED_UNKNOWN_PROPERTIES = [
"-webkit-columns",
"-webkit-column-rule-color",
"-webkit-shape-margin",
"content-visibility",
]

View file

@ -462,6 +462,7 @@ class Longhand(Property):
"Clear",
"ColumnCount",
"Contain",
"ContentVisibility",
"Display",
"FillRule",
"Float",

View file

@ -613,6 +613,16 @@ ${helpers.predefined_type(
spec="https://drafts.csswg.org/css-contain/#contain-property",
)}
${helpers.predefined_type(
"content-visibility",
"ContentVisibility",
"computed::ContentVisibility::Visible",
engines="gecko",
spec="https://drafts.csswg.org/css-contain/#content-visibility",
gecko_pref="layout.css.content-visibility.enabled",
animation_value_type="none",
)}
${helpers.predefined_type(
"appearance",
"Appearance",

View file

@ -13,9 +13,9 @@ use crate::values::specified::box_ as specified;
pub use crate::values::specified::box_::{
AnimationName, AnimationTimeline, Appearance, BreakBetween, BreakWithin,
Clear as SpecifiedClear, Contain, Display, Float as SpecifiedFloat, Overflow, OverflowAnchor,
OverflowClipBox, OverscrollBehavior, ScrollSnapAlign, ScrollSnapAxis, ScrollSnapStrictness,
ScrollSnapType, ScrollbarGutter, TouchAction, TransitionProperty, WillChange,
Clear as SpecifiedClear, Contain, ContentVisibility, Display, Float as SpecifiedFloat, Overflow,
OverflowAnchor, OverflowClipBox, OverscrollBehavior, ScrollSnapAlign, ScrollSnapAxis,
ScrollSnapStrictness, ScrollSnapType, ScrollbarGutter, TouchAction, TransitionProperty, WillChange,
};
/// A computed value for the `vertical-align` property.

View file

@ -45,7 +45,7 @@ pub use self::border::{BorderCornerRadius, BorderRadius, BorderSpacing};
pub use self::border::{BorderImageRepeat, BorderImageSideWidth};
pub use self::border::{BorderImageSlice, BorderImageWidth};
pub use self::box_::{AnimationIterationCount, AnimationName, AnimationTimeline, Contain};
pub use self::box_::{Appearance, BreakBetween, BreakWithin, Clear, Float};
pub use self::box_::{Appearance, BreakBetween, BreakWithin, Clear, ContentVisibility, Float};
pub use self::box_::{Display, Overflow, OverflowAnchor, TransitionProperty};
pub use self::box_::{OverflowClipBox, OverscrollBehavior, Perspective, Resize, ScrollbarGutter};
pub use self::box_::{ScrollSnapAlign, ScrollSnapAxis, ScrollSnapStrictness, ScrollSnapType};

View file

@ -1450,6 +1450,34 @@ impl Parse for Contain {
}
}
#[allow(missing_docs)]
#[cfg_attr(feature = "servo", derive(Deserialize, Serialize))]
#[derive(
Clone,
Copy,
Debug,
Eq,
MallocSizeOf,
Parse,
PartialEq,
SpecifiedValueInfo,
ToComputedValue,
ToCss,
ToResolvedValue,
ToShmem,
)]
#[repr(u8)]
pub enum ContentVisibility {
/// `auto` variant, the element turns on layout containment, style containment, and paint
/// containment. In addition, if the element is not relevant to the user (such as by being
/// offscreen) it also skips its content
Auto,
/// `hidden` variant, the element skips its content
Hidden,
/// 'visible' variant, no effect
Visible,
}
/// A specified value for the `perspective` property.
pub type Perspective = GenericPerspective<NonNegativeLength>;

View file

@ -38,7 +38,7 @@ pub use self::border::{BorderImageRepeat, BorderImageSideWidth};
pub use self::border::{BorderRadius, BorderSideWidth, BorderSpacing, BorderStyle};
pub use self::box_::{AnimationIterationCount, AnimationName, AnimationTimeline, Contain, Display};
pub use self::box_::{Appearance, BreakBetween, BreakWithin};
pub use self::box_::{Clear, Float, Overflow, OverflowAnchor};
pub use self::box_::{Clear, ContentVisibility, Float, Overflow, OverflowAnchor};
pub use self::box_::{OverflowClipBox, OverscrollBehavior, Perspective, Resize, ScrollbarGutter};
pub use self::box_::{ScrollSnapAlign, ScrollSnapAxis, ScrollSnapStrictness, ScrollSnapType};
pub use self::box_::{TouchAction, TransitionProperty, VerticalAlign, WillChange};