diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-12 05:35:29 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-12 05:35:29 +0000 |
commit | 59203c63bb777a3bacec32fb8830fba33540e809 (patch) | |
tree | 58298e711c0ff0575818c30485b44a2f21bf28a0 /servo/components/style/values/generics/counters.rs | |
parent | Adding upstream version 126.0.1. (diff) | |
download | firefox-59203c63bb777a3bacec32fb8830fba33540e809.tar.xz firefox-59203c63bb777a3bacec32fb8830fba33540e809.zip |
Adding upstream version 127.0.upstream/127.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'servo/components/style/values/generics/counters.rs')
-rw-r--r-- | servo/components/style/values/generics/counters.rs | 37 |
1 files changed, 36 insertions, 1 deletions
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<Image> { + /// The actual content items. Note that, past the alt marker, only some subset (strings, + /// attr(), counter()) + pub items: thin_vec::ThinVec<GenericContentItem<Image>>, + /// The index at which alt text starts, always non-zero. If equal to items.len(), no alt text + /// exists. + pub alt_start: usize, +} + +impl<Image> ToCss for GenericContentItems<Image> +where + Image: ToCss, +{ + fn to_css<W>(&self, dest: &mut CssWriter<W>) -> 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<Image> { /// `none` reserved keyword. None, /// Content items. - Items(#[css(iterable)] crate::OwnedSlice<GenericContentItem<Image>>), + Items(GenericContentItems<Image>), } pub use self::GenericContent as Content; |