aboutsummaryrefslogtreecommitdiffstats
path: root/components
diff options
context:
space:
mode:
authorMartin Robinson <mrobinson@igalia.com>2023-06-06 23:56:59 +0200
committerOriol Brufau <obrufau@igalia.com>2023-06-09 11:18:07 +0200
commiteb96b29af05e520fc8fe19616d01a784b6d70937 (patch)
tree78e27c12213aaed5699edfaa841281ea78dc0d88 /components
parent8016c434b01afde931f8de909c8b9f839f8b6dd9 (diff)
downloadservo-eb96b29af05e520fc8fe19616d01a784b6d70937.tar.gz
servo-eb96b29af05e520fc8fe19616d01a784b6d70937.zip
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
Diffstat (limited to 'components')
-rw-r--r--components/style/properties/counted_unknown_properties.py1
-rw-r--r--components/style/properties/data.py1
-rw-r--r--components/style/properties/longhands/box.mako.rs10
-rw-r--r--components/style/values/computed/box.rs6
-rw-r--r--components/style/values/computed/mod.rs2
-rw-r--r--components/style/values/specified/box.rs28
-rw-r--r--components/style/values/specified/mod.rs2
7 files changed, 44 insertions, 6 deletions
diff --git a/components/style/properties/counted_unknown_properties.py b/components/style/properties/counted_unknown_properties.py
index fffac5ff589..473f2f599d2 100644
--- a/components/style/properties/counted_unknown_properties.py
+++ b/components/style/properties/counted_unknown_properties.py
@@ -120,5 +120,4 @@ COUNTED_UNKNOWN_PROPERTIES = [
"-webkit-columns",
"-webkit-column-rule-color",
"-webkit-shape-margin",
- "content-visibility",
]
diff --git a/components/style/properties/data.py b/components/style/properties/data.py
index 17d398b0aaa..eb61992c44b 100644
--- a/components/style/properties/data.py
+++ b/components/style/properties/data.py
@@ -462,6 +462,7 @@ class Longhand(Property):
"Clear",
"ColumnCount",
"Contain",
+ "ContentVisibility",
"Display",
"FillRule",
"Float",
diff --git a/components/style/properties/longhands/box.mako.rs b/components/style/properties/longhands/box.mako.rs
index 5e67de1565d..33b28375847 100644
--- a/components/style/properties/longhands/box.mako.rs
+++ b/components/style/properties/longhands/box.mako.rs
@@ -614,6 +614,16 @@ ${helpers.predefined_type(
)}
${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",
"computed::Appearance::None",
diff --git a/components/style/values/computed/box.rs b/components/style/values/computed/box.rs
index 2364ac69045..dd1e4900672 100644
--- a/components/style/values/computed/box.rs
+++ b/components/style/values/computed/box.rs
@@ -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.
diff --git a/components/style/values/computed/mod.rs b/components/style/values/computed/mod.rs
index 74e78887480..68194eb733a 100644
--- a/components/style/values/computed/mod.rs
+++ b/components/style/values/computed/mod.rs
@@ -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};
diff --git a/components/style/values/specified/box.rs b/components/style/values/specified/box.rs
index 83fa2c8bd51..97024dd4245 100644
--- a/components/style/values/specified/box.rs
+++ b/components/style/values/specified/box.rs
@@ -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>;
diff --git a/components/style/values/specified/mod.rs b/components/style/values/specified/mod.rs
index 099b06a48b3..ac622961642 100644
--- a/components/style/values/specified/mod.rs
+++ b/components/style/values/specified/mod.rs
@@ -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};