/* This Source Code Form is subject to the terms of the Mozilla Public *License,v.2.0.IfacopyoftheMPLwasnotdistributedwiththis
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
//! Generic types for counters-related CSS values.
#[cfg(feature = "servo")] usecrate::computed_values::list_style_type::T as ListStyleType; #[cfg(feature = "gecko")] usecrate::counter_style::CounterStyle; usecrate::values::specified::Attr; usecrate::values::CustomIdent; use std::fmt::{self, Write}; use std::ops::Deref; use style_traits::{CssWriter, ToCss};
/// A name / value pair for counters. #[derive(
Clone,
Debug,
MallocSizeOf,
PartialEq,
SpecifiedValueInfo,
ToComputedValue,
ToResolvedValue,
ToShmem,
)] #[repr(C)] pubstruct GenericCounterPair<Integer> { /// The name of the counter. pub name: CustomIdent, /// The value of the counter / increment / etc. pub value: Integer, /// If true, then this represents `reversed(name)`. /// NOTE: It can only be true on `counter-reset` values. pub is_reversed: bool,
} pubuseself::GenericCounterPair as CounterPair;
/// A generic value for the `counter-increment` property. #[derive(
Clone,
Debug,
Default,
MallocSizeOf,
PartialEq,
SpecifiedValueInfo,
ToComputedValue,
ToCss,
ToResolvedValue,
ToShmem,
)] #[repr(transparent)] pubstruct GenericCounterIncrement<I>(#[css(field_bound)] pub GenericCounters<I>); pubuseself::GenericCounterIncrement as CounterIncrement;
impl<I> CounterIncrement<I> { /// Returns a new value for `counter-increment`. #[inline] pubfn new(counters: Vec<CounterPair<I>>) -> Self {
CounterIncrement(Counters(counters.into()))
}
}
impl<I> Deref for CounterIncrement<I> { type Target = [CounterPair<I>];
/// A generic value for the `counter-set` property. #[derive(
Clone,
Debug,
Default,
MallocSizeOf,
PartialEq,
SpecifiedValueInfo,
ToComputedValue,
ToCss,
ToResolvedValue,
ToShmem,
)] #[repr(transparent)] pubstruct GenericCounterSet<I>(#[css(field_bound)] pub GenericCounters<I>); pubuseself::GenericCounterSet as CounterSet;
impl<I> CounterSet<I> { /// Returns a new value for `counter-set`. #[inline] pubfn new(counters: Vec<CounterPair<I>>) -> Self {
CounterSet(Counters(counters.into()))
}
}
impl<I> Deref for CounterSet<I> { type Target = [CounterPair<I>];
/// A generic value for the `counter-reset` property. #[derive(
Clone,
Debug,
Default,
MallocSizeOf,
PartialEq,
SpecifiedValueInfo,
ToComputedValue,
ToCss,
ToResolvedValue,
ToShmem,
)] #[repr(transparent)] pubstruct GenericCounterReset<I>(#[css(field_bound)] pub GenericCounters<I>); pubuseself::GenericCounterReset as CounterReset;
impl<I> CounterReset<I> { /// Returns a new value for `counter-reset`. #[inline] pubfn new(counters: Vec<CounterPair<I>>) -> Self {
CounterReset(Counters(counters.into()))
}
}
impl<I> Deref for CounterReset<I> { type Target = [CounterPair<I>];
/// The non-normal, non-none values of the content property. #[derive(
Clone, Debug, Eq, MallocSizeOf, PartialEq, SpecifiedValueInfo, ToComputedValue, ToShmem,
)] #[repr(C)] pubstruct 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) inself.items.iter().enumerate() { if i == self.alt_start {
dest.write_str(" /")?;
} if i != 0 {
dest.write_str(" ")?;
}
item.to_css(dest)?;
}
Ok(())
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.