mirror of
https://github.com/servo/servo.git
synced 2025-08-04 21:20:23 +01:00
Derive ToCss for cursor keywords
This commit is contained in:
parent
c8c6f3482f
commit
d55d726a21
3 changed files with 14 additions and 21 deletions
|
@ -2853,8 +2853,8 @@ impl ServoComputedValuesCursorUtility for ServoComputedValues {
|
||||||
fn get_cursor(&self, default_cursor: Cursor) -> Option<Cursor> {
|
fn get_cursor(&self, default_cursor: Cursor) -> Option<Cursor> {
|
||||||
match (self.get_pointing().pointer_events, self.get_pointing().cursor) {
|
match (self.get_pointing().pointer_events, self.get_pointing().cursor) {
|
||||||
(pointer_events::T::none, _) => None,
|
(pointer_events::T::none, _) => None,
|
||||||
(pointer_events::T::auto, cursor::Keyword::AutoCursor) => Some(default_cursor),
|
(pointer_events::T::auto, cursor::Keyword::Auto) => Some(default_cursor),
|
||||||
(pointer_events::T::auto, cursor::Keyword::SpecifiedCursor(cursor)) => Some(cursor),
|
(pointer_events::T::auto, cursor::Keyword::Cursor(cursor)) => Some(cursor),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4191,8 +4191,8 @@ clip-path
|
||||||
use style_traits::cursor::Cursor;
|
use style_traits::cursor::Cursor;
|
||||||
|
|
||||||
self.gecko.mCursor = match v.keyword {
|
self.gecko.mCursor = match v.keyword {
|
||||||
Keyword::AutoCursor => structs::NS_STYLE_CURSOR_AUTO,
|
Keyword::Auto => structs::NS_STYLE_CURSOR_AUTO,
|
||||||
Keyword::SpecifiedCursor(cursor) => match cursor {
|
Keyword::Cursor(cursor) => match cursor {
|
||||||
Cursor::None => structs::NS_STYLE_CURSOR_NONE,
|
Cursor::None => structs::NS_STYLE_CURSOR_NONE,
|
||||||
Cursor::Default => structs::NS_STYLE_CURSOR_DEFAULT,
|
Cursor::Default => structs::NS_STYLE_CURSOR_DEFAULT,
|
||||||
Cursor::Pointer => structs::NS_STYLE_CURSOR_POINTER,
|
Cursor::Pointer => structs::NS_STYLE_CURSOR_POINTER,
|
||||||
|
|
|
@ -17,17 +17,19 @@
|
||||||
no_viewport_percentage!(SpecifiedValue);
|
no_viewport_percentage!(SpecifiedValue);
|
||||||
|
|
||||||
pub mod computed_value {
|
pub mod computed_value {
|
||||||
|
#[cfg(feature = "gecko")]
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
use style_traits::cursor::Cursor;
|
#[cfg(feature = "gecko")]
|
||||||
use style_traits::ToCss;
|
use style_traits::ToCss;
|
||||||
|
use style_traits::cursor::Cursor;
|
||||||
#[cfg(feature = "gecko")]
|
#[cfg(feature = "gecko")]
|
||||||
use values::specified::url::SpecifiedUrl;
|
use values::specified::url::SpecifiedUrl;
|
||||||
|
|
||||||
#[derive(Clone, PartialEq, Copy, Debug)]
|
|
||||||
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
|
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
|
||||||
|
#[derive(Clone, Copy, Debug, PartialEq, ToCss)]
|
||||||
pub enum Keyword {
|
pub enum Keyword {
|
||||||
AutoCursor,
|
Auto,
|
||||||
SpecifiedCursor(Cursor),
|
Cursor(Cursor),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(feature = "gecko"))]
|
#[cfg(not(feature = "gecko"))]
|
||||||
|
@ -47,15 +49,6 @@
|
||||||
pub keyword: Keyword,
|
pub keyword: Keyword,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ToCss for Keyword {
|
|
||||||
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
|
|
||||||
match *self {
|
|
||||||
Keyword::AutoCursor => dest.write_str("auto"),
|
|
||||||
Keyword::SpecifiedCursor(c) => c.to_css(dest),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(feature = "gecko")]
|
#[cfg(feature = "gecko")]
|
||||||
impl ToCss for Image {
|
impl ToCss for Image {
|
||||||
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
|
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
|
||||||
|
@ -85,7 +78,7 @@
|
||||||
#[cfg(not(feature = "gecko"))]
|
#[cfg(not(feature = "gecko"))]
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn get_initial_value() -> computed_value::T {
|
pub fn get_initial_value() -> computed_value::T {
|
||||||
computed_value::Keyword::AutoCursor
|
computed_value::Keyword::Auto
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "gecko")]
|
#[cfg(feature = "gecko")]
|
||||||
|
@ -93,7 +86,7 @@
|
||||||
pub fn get_initial_value() -> computed_value::T {
|
pub fn get_initial_value() -> computed_value::T {
|
||||||
computed_value::T {
|
computed_value::T {
|
||||||
images: vec![],
|
images: vec![],
|
||||||
keyword: computed_value::Keyword::AutoCursor
|
keyword: computed_value::Keyword::Auto
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -103,9 +96,9 @@
|
||||||
use style_traits::cursor::Cursor;
|
use style_traits::cursor::Cursor;
|
||||||
let ident = try!(input.expect_ident());
|
let ident = try!(input.expect_ident());
|
||||||
if ident.eq_ignore_ascii_case("auto") {
|
if ident.eq_ignore_ascii_case("auto") {
|
||||||
Ok(computed_value::Keyword::AutoCursor)
|
Ok(computed_value::Keyword::Auto)
|
||||||
} else {
|
} else {
|
||||||
Cursor::from_css_keyword(&ident).map(computed_value::Keyword::SpecifiedCursor)
|
Cursor::from_css_keyword(&ident).map(computed_value::Keyword::Cursor)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue