From 59203c63bb777a3bacec32fb8830fba33540e809 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 12 Jun 2024 07:35:29 +0200 Subject: Adding upstream version 127.0. Signed-off-by: Daniel Baumann --- servo/components/style/values/generics/counters.rs | 37 +++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) (limited to 'servo/components/style/values/generics/counters.rs') diff --git a/servo/components/style/values/generics/counters.rs b/servo/components/style/values/generics/counters.rs index 3f23c74b33..d6db48f9c4 100644 --- a/servo/components/style/values/generics/counters.rs +++ b/servo/components/style/values/generics/counters.rs @@ -203,6 +203,41 @@ fn is_decimal(counter_type: &CounterStyleType) -> bool { *counter_type == CounterStyle::decimal() } +/// The non-normal, non-none values of the content property. +#[derive( + Clone, Debug, Eq, MallocSizeOf, PartialEq, SpecifiedValueInfo, ToComputedValue, ToShmem, +)] +#[repr(C)] +pub struct GenericContentItems { + /// The actual content items. Note that, past the alt marker, only some subset (strings, + /// attr(), counter()) + pub items: thin_vec::ThinVec>, + /// The index at which alt text starts, always non-zero. If equal to items.len(), no alt text + /// exists. + pub alt_start: usize, +} + +impl ToCss for GenericContentItems +where + Image: ToCss, +{ + fn to_css(&self, dest: &mut CssWriter) -> fmt::Result + where + W: Write, + { + for (i, item) in self.items.iter().enumerate() { + if i == self.alt_start { + dest.write_str(" /")?; + } + if i != 0 { + dest.write_str(" ")?; + } + item.to_css(dest)?; + } + Ok(()) + } +} + /// The specified value for the `content` property. /// /// https://drafts.csswg.org/css-content/#propdef-content @@ -216,7 +251,7 @@ pub enum GenericContent { /// `none` reserved keyword. None, /// Content items. - Items(#[css(iterable)] crate::OwnedSlice>), + Items(GenericContentItems), } pub use self::GenericContent as Content; -- cgit v1.2.3