use crate::values::specified::ui::CursorKind;
use std::fmt::{self, Write};
use style_traits::{CssWriter, ToCss};
#[derive(
Clone,
Debug,
MallocSizeOf,
PartialEq,
SpecifiedValueInfo,
ToComputedValue,
ToResolvedValue,
ToShmem,
)]
#[repr(C)]
pub struct GenericCursor<Image> {
pub images: crate::OwnedSlice<Image>,
pub keyword: CursorKind,
}
pub use self::GenericCursor as Cursor;
impl<Image> Cursor<Image> {
#[inline]
pub fn auto() -> Self {
Self {
images: Default::default(),
keyword: CursorKind::Auto,
}
}
}
impl<Image: ToCss> ToCss for Cursor<Image> {
fn to_css<W>(&self, dest: &mut CssWriter<W>) -> fmt::Result
where
W: Write,
{
for image in &*self.images {
image.to_css(dest)?;
dest.write_str(", ")?;
}
self.keyword.to_css(dest)
}
}
#[derive(Clone, Debug, MallocSizeOf, PartialEq, ToComputedValue, ToResolvedValue, ToShmem)]
#[repr(C)]
pub struct GenericCursorImage<Image, Number> {
pub image: Image,
pub has_hotspot: bool,
pub hotspot_x: Number,
pub hotspot_y: Number,
}
pub use self::GenericCursorImage as CursorImage;
impl<Image: ToCss, Number: ToCss> ToCss for CursorImage<Image, Number> {
fn to_css<W>(&self, dest: &mut CssWriter<W>) -> fmt::Result
where
W: Write,
{
self.image.to_css(dest)?;
if self.has_hotspot {
dest.write_char(' ')?;
self.hotspot_x.to_css(dest)?;
dest.write_char(' ')?;
self.hotspot_y.to_css(dest)?;
}
Ok(())
}
}
#[derive(
Animate,
Clone,
ComputeSquaredDistance,
Copy,
Debug,
MallocSizeOf,
PartialEq,
SpecifiedValueInfo,
ToAnimatedValue,
ToAnimatedZero,
ToComputedValue,
ToCss,
ToResolvedValue,
ToShmem,
)]
#[repr(C, u8)]
pub enum GenericScrollbarColor<Color> {
Auto,
Colors {
thumb: Color,
track: Color,
},
}
pub use self::GenericScrollbarColor as ScrollbarColor;
impl<Color> Default for ScrollbarColor<Color> {
#[inline]
fn default() -> Self {
ScrollbarColor::Auto
}
}