mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
style: Move cursor property out of mako
This commit is contained in:
parent
671b69c0b7
commit
4ee9eb8563
17 changed files with 413 additions and 360 deletions
|
@ -20,43 +20,42 @@ macro_rules! define_cursor {
|
|||
#[cfg_attr(feature = "servo", derive(Deserialize, Serialize))]
|
||||
#[repr(u8)]
|
||||
#[allow(missing_docs)]
|
||||
pub enum Cursor {
|
||||
pub enum CursorKind {
|
||||
$( $c_variant = $c_value, )+
|
||||
$( #[cfg(feature = "gecko")] $g_variant = $g_value, )+
|
||||
}
|
||||
|
||||
impl Cursor {
|
||||
impl CursorKind {
|
||||
/// Given a CSS keyword, get the corresponding cursor enum.
|
||||
pub fn from_css_keyword(keyword: &str) -> Result<Cursor, ()> {
|
||||
pub fn from_css_keyword(keyword: &str) -> Result<Self, ()> {
|
||||
match_ignore_ascii_case! { &keyword,
|
||||
$( $c_css => Ok(Cursor::$c_variant), )+
|
||||
$( #[cfg(feature = "gecko")] $g_css => Ok(Cursor::$g_variant), )+
|
||||
$( $c_css => Ok(CursorKind::$c_variant), )+
|
||||
$( #[cfg(feature = "gecko")] $g_css => Ok(CursorKind::$g_variant), )+
|
||||
_ => Err(())
|
||||
}
|
||||
}
|
||||
|
||||
/// From the C u8 value, get the corresponding Cursor enum.
|
||||
pub fn from_u8(value: u8) -> Result<Cursor, ()> {
|
||||
pub fn from_u8(value: u8) -> Result<Self, ()> {
|
||||
match value {
|
||||
$( $c_value => Ok(Cursor::$c_variant), )+
|
||||
$( #[cfg(feature = "gecko")] $g_value => Ok(Cursor::$g_variant), )+
|
||||
$( $c_value => Ok(CursorKind::$c_variant), )+
|
||||
$( #[cfg(feature = "gecko")] $g_value => Ok(CursorKind::$g_variant), )+
|
||||
_ => Err(())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl ToCss for Cursor {
|
||||
impl ToCss for CursorKind {
|
||||
fn to_css<W>(&self, dest: &mut W) -> ::std::fmt::Result where W: ::std::fmt::Write {
|
||||
match *self {
|
||||
$( Cursor::$c_variant => dest.write_str($c_css), )+
|
||||
$( #[cfg(feature = "gecko")] Cursor::$g_variant => dest.write_str($g_css), )+
|
||||
$( CursorKind::$c_variant => dest.write_str($c_css), )+
|
||||
$( #[cfg(feature = "gecko")] CursorKind::$g_variant => dest.write_str($g_css), )+
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
define_cursor! {
|
||||
common properties = [
|
||||
"none" => None = 0,
|
||||
|
@ -94,12 +93,13 @@ define_cursor! {
|
|||
"all-scroll" => AllScroll = 32,
|
||||
"zoom-in" => ZoomIn = 33,
|
||||
"zoom-out" => ZoomOut = 34,
|
||||
"auto" => Auto = 35,
|
||||
]
|
||||
// gecko only properties
|
||||
gecko properties = [
|
||||
"-moz-grab" => MozGrab = 35,
|
||||
"-moz-grabbing" => MozGrabbing = 36,
|
||||
"-moz-zoom-in" => MozZoomIn = 37,
|
||||
"-moz-zoom-out" => MozZoomOut = 38,
|
||||
"-moz-grab" => MozGrab = 36,
|
||||
"-moz-grabbing" => MozGrabbing = 37,
|
||||
"-moz-zoom-in" => MozZoomIn = 38,
|
||||
"-moz-zoom-out" => MozZoomOut = 39,
|
||||
]
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue