mirror of
https://github.com/servo/servo.git
synced 2025-08-04 21:20:23 +01:00
Make stylo support moz-prefixed cursor values.
MozReview-Commit-ID: AfV0recnoXw
This commit is contained in:
parent
8850a01b81
commit
285ff8214e
4 changed files with 65 additions and 40 deletions
|
@ -13,7 +13,7 @@ path = "lib.rs"
|
||||||
doctest = false
|
doctest = false
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
gecko = ["nsstring_vendor", "rayon/unstable", "num_cpus"]
|
gecko = ["nsstring_vendor", "rayon/unstable", "num_cpus", "style_traits/gecko"]
|
||||||
use_bindgen = ["bindgen", "regex"]
|
use_bindgen = ["bindgen", "regex"]
|
||||||
servo = ["serde/unstable", "serde", "serde_derive", "heapsize", "heapsize_derive",
|
servo = ["serde/unstable", "serde", "serde_derive", "heapsize", "heapsize_derive",
|
||||||
"style_traits/servo", "servo_atoms", "servo_config", "html5ever-atoms",
|
"style_traits/servo", "servo_atoms", "servo_config", "html5ever-atoms",
|
||||||
|
|
|
@ -3832,6 +3832,11 @@ clip-path
|
||||||
Cursor::AllScroll => structs::NS_STYLE_CURSOR_ALL_SCROLL,
|
Cursor::AllScroll => structs::NS_STYLE_CURSOR_ALL_SCROLL,
|
||||||
Cursor::ZoomIn => structs::NS_STYLE_CURSOR_ZOOM_IN,
|
Cursor::ZoomIn => structs::NS_STYLE_CURSOR_ZOOM_IN,
|
||||||
Cursor::ZoomOut => structs::NS_STYLE_CURSOR_ZOOM_OUT,
|
Cursor::ZoomOut => structs::NS_STYLE_CURSOR_ZOOM_OUT,
|
||||||
|
// note: the following properties are gecko-only.
|
||||||
|
Cursor::MozGrab => structs::NS_STYLE_CURSOR_GRAB,
|
||||||
|
Cursor::MozGrabbing => structs::NS_STYLE_CURSOR_GRABBING,
|
||||||
|
Cursor::MozZoomIn => structs::NS_STYLE_CURSOR_ZOOM_IN,
|
||||||
|
Cursor::MozZoomOut => structs::NS_STYLE_CURSOR_ZOOM_OUT,
|
||||||
}
|
}
|
||||||
} as u8;
|
} as u8;
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,7 @@ path = "lib.rs"
|
||||||
[features]
|
[features]
|
||||||
servo = ["heapsize", "heapsize_derive", "serde", "serde_derive",
|
servo = ["heapsize", "heapsize_derive", "serde", "serde_derive",
|
||||||
"cssparser/heapsize", "cssparser/serde"]
|
"cssparser/heapsize", "cssparser/serde"]
|
||||||
|
gecko = []
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
app_units = "0.4"
|
app_units = "0.4"
|
||||||
|
|
|
@ -7,21 +7,30 @@
|
||||||
use super::ToCss;
|
use super::ToCss;
|
||||||
|
|
||||||
macro_rules! define_cursor {
|
macro_rules! define_cursor {
|
||||||
($( $css: expr => $variant: ident = $value: expr, )+) => {
|
(
|
||||||
|
common properties = [
|
||||||
|
$( $c_css: expr => $c_variant: ident = $c_value: expr, )+
|
||||||
|
]
|
||||||
|
gecko properties = [
|
||||||
|
$( $g_css: expr => $g_variant: ident = $g_value: expr, )+
|
||||||
|
]
|
||||||
|
) => {
|
||||||
/// https://drafts.csswg.org/css-ui/#cursor
|
/// https://drafts.csswg.org/css-ui/#cursor
|
||||||
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
|
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
|
||||||
#[cfg_attr(feature = "servo", derive(Deserialize, Serialize, HeapSizeOf))]
|
#[cfg_attr(feature = "servo", derive(Deserialize, Serialize, HeapSizeOf))]
|
||||||
#[repr(u8)]
|
#[repr(u8)]
|
||||||
#[allow(missing_docs)]
|
#[allow(missing_docs)]
|
||||||
pub enum Cursor {
|
pub enum Cursor {
|
||||||
$( $variant = $value ),+
|
$( $c_variant = $c_value, )+
|
||||||
|
$( #[cfg(feature = "gecko")] $g_variant = $g_value, )+
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Cursor {
|
impl Cursor {
|
||||||
/// Given a CSS keyword, get the corresponding cursor enum.
|
/// 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<Cursor, ()> {
|
||||||
match_ignore_ascii_case! { &keyword,
|
match_ignore_ascii_case! { &keyword,
|
||||||
$( $css => Ok(Cursor::$variant), )+
|
$( $c_css => Ok(Cursor::$c_variant), )+
|
||||||
|
$( #[cfg(feature = "gecko")] $g_css => Ok(Cursor::$g_variant), )+
|
||||||
_ => Err(())
|
_ => Err(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -30,7 +39,8 @@ macro_rules! define_cursor {
|
||||||
impl ToCss for Cursor {
|
impl ToCss for Cursor {
|
||||||
fn to_css<W>(&self, dest: &mut W) -> ::std::fmt::Result where W: ::std::fmt::Write {
|
fn to_css<W>(&self, dest: &mut W) -> ::std::fmt::Result where W: ::std::fmt::Write {
|
||||||
match *self {
|
match *self {
|
||||||
$( Cursor::$variant => dest.write_str($css) ),+
|
$( Cursor::$c_variant => dest.write_str($c_css), )+
|
||||||
|
$( #[cfg(feature = "gecko")] Cursor::$g_variant => dest.write_str($g_css), )+
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -39,39 +49,48 @@ macro_rules! define_cursor {
|
||||||
|
|
||||||
|
|
||||||
define_cursor! {
|
define_cursor! {
|
||||||
"none" => None = 0,
|
common properties = [
|
||||||
"default" => Default = 1,
|
"none" => None = 0,
|
||||||
"pointer" => Pointer = 2,
|
"default" => Default = 1,
|
||||||
"context-menu" => ContextMenu = 3,
|
"pointer" => Pointer = 2,
|
||||||
"help" => Help = 4,
|
"context-menu" => ContextMenu = 3,
|
||||||
"progress" => Progress = 5,
|
"help" => Help = 4,
|
||||||
"wait" => Wait = 6,
|
"progress" => Progress = 5,
|
||||||
"cell" => Cell = 7,
|
"wait" => Wait = 6,
|
||||||
"crosshair" => Crosshair = 8,
|
"cell" => Cell = 7,
|
||||||
"text" => Text = 9,
|
"crosshair" => Crosshair = 8,
|
||||||
"vertical-text" => VerticalText = 10,
|
"text" => Text = 9,
|
||||||
"alias" => Alias = 11,
|
"vertical-text" => VerticalText = 10,
|
||||||
"copy" => Copy = 12,
|
"alias" => Alias = 11,
|
||||||
"move" => Move = 13,
|
"copy" => Copy = 12,
|
||||||
"no-drop" => NoDrop = 14,
|
"move" => Move = 13,
|
||||||
"not-allowed" => NotAllowed = 15,
|
"no-drop" => NoDrop = 14,
|
||||||
"grab" => Grab = 16,
|
"not-allowed" => NotAllowed = 15,
|
||||||
"grabbing" => Grabbing = 17,
|
"grab" => Grab = 16,
|
||||||
"e-resize" => EResize = 18,
|
"grabbing" => Grabbing = 17,
|
||||||
"n-resize" => NResize = 19,
|
"e-resize" => EResize = 18,
|
||||||
"ne-resize" => NeResize = 20,
|
"n-resize" => NResize = 19,
|
||||||
"nw-resize" => NwResize = 21,
|
"ne-resize" => NeResize = 20,
|
||||||
"s-resize" => SResize = 22,
|
"nw-resize" => NwResize = 21,
|
||||||
"se-resize" => SeResize = 23,
|
"s-resize" => SResize = 22,
|
||||||
"sw-resize" => SwResize = 24,
|
"se-resize" => SeResize = 23,
|
||||||
"w-resize" => WResize = 25,
|
"sw-resize" => SwResize = 24,
|
||||||
"ew-resize" => EwResize = 26,
|
"w-resize" => WResize = 25,
|
||||||
"ns-resize" => NsResize = 27,
|
"ew-resize" => EwResize = 26,
|
||||||
"nesw-resize" => NeswResize = 28,
|
"ns-resize" => NsResize = 27,
|
||||||
"nwse-resize" => NwseResize = 29,
|
"nesw-resize" => NeswResize = 28,
|
||||||
"col-resize" => ColResize = 30,
|
"nwse-resize" => NwseResize = 29,
|
||||||
"row-resize" => RowResize = 31,
|
"col-resize" => ColResize = 30,
|
||||||
"all-scroll" => AllScroll = 32,
|
"row-resize" => RowResize = 31,
|
||||||
"zoom-in" => ZoomIn = 33,
|
"all-scroll" => AllScroll = 32,
|
||||||
"zoom-out" => ZoomOut = 34,
|
"zoom-in" => ZoomIn = 33,
|
||||||
|
"zoom-out" => ZoomOut = 34,
|
||||||
|
]
|
||||||
|
// gecko only properties
|
||||||
|
gecko properties = [
|
||||||
|
"-moz-grab" => MozGrab = 35,
|
||||||
|
"-moz-grabbing" => MozGrabbing = 36,
|
||||||
|
"-moz-zoom-in" => MozZoomIn = 37,
|
||||||
|
"-moz-zoom-out" => MozZoomOut = 38,
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue