mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
style: Use cbindgen for cursors.
Pretty straight-forward. Differential Revision: https://phabricator.services.mozilla.com/D63777
This commit is contained in:
parent
787ac98d18
commit
18570bf077
4 changed files with 39 additions and 77 deletions
|
@ -21,19 +21,22 @@ use values::specified::ui::CursorKind;
|
|||
ToResolvedValue,
|
||||
ToShmem,
|
||||
)]
|
||||
pub struct Cursor<Image> {
|
||||
#[repr(C)]
|
||||
pub struct GenericCursor<Image> {
|
||||
/// The parsed images for the cursor.
|
||||
pub images: Box<[Image]>,
|
||||
pub images: crate::OwnedSlice<Image>,
|
||||
/// The kind of the cursor [default | help | ...].
|
||||
pub keyword: CursorKind,
|
||||
}
|
||||
|
||||
pub use self::GenericCursor as Cursor;
|
||||
|
||||
impl<Image> Cursor<Image> {
|
||||
/// Set `cursor` to `auto`
|
||||
#[inline]
|
||||
pub fn auto() -> Self {
|
||||
Self {
|
||||
images: vec![].into_boxed_slice(),
|
||||
images: Default::default(),
|
||||
keyword: CursorKind::Auto,
|
||||
}
|
||||
}
|
||||
|
@ -63,24 +66,31 @@ impl<Image: ToCss> ToCss for Cursor<Image> {
|
|||
ToResolvedValue,
|
||||
ToShmem,
|
||||
)]
|
||||
pub struct CursorImage<ImageUrl, Number> {
|
||||
#[repr(C)]
|
||||
pub struct GenericCursorImage<ImageUrl, Number> {
|
||||
/// The url to parse images from.
|
||||
pub url: ImageUrl,
|
||||
/// The <x> and <y> coordinates.
|
||||
pub hotspot: Option<(Number, Number)>,
|
||||
/// Whether the image has a hotspot or not.
|
||||
pub has_hotspot: bool,
|
||||
/// The x coordinate.
|
||||
pub hotspot_x: Number,
|
||||
/// The y coordinate.
|
||||
pub hotspot_y: Number,
|
||||
}
|
||||
|
||||
pub use self::GenericCursorImage as CursorImage;
|
||||
|
||||
impl<ImageUrl: ToCss, Number: ToCss> ToCss for CursorImage<ImageUrl, Number> {
|
||||
fn to_css<W>(&self, dest: &mut CssWriter<W>) -> fmt::Result
|
||||
where
|
||||
W: Write,
|
||||
{
|
||||
self.url.to_css(dest)?;
|
||||
if let Some((ref x, ref y)) = self.hotspot {
|
||||
if self.has_hotspot {
|
||||
dest.write_str(" ")?;
|
||||
x.to_css(dest)?;
|
||||
self.hotspot_x.to_css(dest)?;
|
||||
dest.write_str(" ")?;
|
||||
y.to_css(dest)?;
|
||||
self.hotspot_y.to_css(dest)?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue