aboutsummaryrefslogtreecommitdiffstats
path: root/components/style_traits/cursor.rs
diff options
context:
space:
mode:
authorAnthony Ramine <n.oxyde@gmail.com>2016-02-14 19:37:00 +0100
committerAnthony Ramine <n.oxyde@gmail.com>2016-02-16 00:50:01 +0100
commit290694b27ece24dabb4e01f4283294cf350857e9 (patch)
tree9d8a0db1c06b153135d717a13c0a54093b675884 /components/style_traits/cursor.rs
parentc929dbe2530f979ce6e84d5a25ea47318ff0910e (diff)
downloadservo-290694b27ece24dabb4e01f4283294cf350857e9.tar.gz
servo-290694b27ece24dabb4e01f4283294cf350857e9.zip
Move util::cursor to style_traits
Diffstat (limited to 'components/style_traits/cursor.rs')
-rw-r--r--components/style_traits/cursor.rs74
1 files changed, 74 insertions, 0 deletions
diff --git a/components/style_traits/cursor.rs b/components/style_traits/cursor.rs
new file mode 100644
index 00000000000..7f139fd498e
--- /dev/null
+++ b/components/style_traits/cursor.rs
@@ -0,0 +1,74 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+//! A list of common mouse cursors per CSS3-UI § 8.1.1.
+
+use cssparser::ToCss;
+use std::ascii::AsciiExt;
+
+macro_rules! define_cursor {
+ ($( $css: expr => $variant: ident = $value: expr, )+) => {
+ #[derive(Clone, Copy, Debug, Deserialize, Eq, HeapSizeOf, PartialEq, Serialize)]
+ #[repr(u8)]
+ pub enum Cursor {
+ $( $variant = $value ),+
+ }
+
+ impl Cursor {
+ pub fn from_css_keyword(keyword: &str) -> Result<Cursor, ()> {
+ match_ignore_ascii_case! { keyword,
+ $( concat!($css) => Ok(Cursor::$variant), )+
+ _ => Err(())
+ }
+ }
+ }
+
+ impl ToCss for Cursor {
+ fn to_css<W>(&self, dest: &mut W) -> ::std::fmt::Result where W: ::std::fmt::Write {
+ match *self {
+ $( Cursor::$variant => dest.write_str($css) ),+
+ }
+ }
+ }
+ }
+}
+
+
+define_cursor! {
+ "none" => NoCursor = 0,
+ "default" => DefaultCursor = 1,
+ "pointer" => PointerCursor = 2,
+ "context-menu" => ContextMenuCursor = 3,
+ "help" => HelpCursor = 4,
+ "progress" => ProgressCursor = 5,
+ "wait" => WaitCursor = 6,
+ "cell" => CellCursor = 7,
+ "crosshair" => CrosshairCursor = 8,
+ "text" => TextCursor = 9,
+ "vertical-text" => VerticalTextCursor = 10,
+ "alias" => AliasCursor = 11,
+ "copy" => CopyCursor = 12,
+ "move" => MoveCursor = 13,
+ "no-drop" => NoDropCursor = 14,
+ "not-allowed" => NotAllowedCursor = 15,
+ "grab" => GrabCursor = 16,
+ "grabbing" => GrabbingCursor = 17,
+ "e-resize" => EResizeCursor = 18,
+ "n-resize" => NResizeCursor = 19,
+ "ne-resize" => NeResizeCursor = 20,
+ "nw-resize" => NwResizeCursor = 21,
+ "s-resize" => SResizeCursor = 22,
+ "se-resize" => SeResizeCursor = 23,
+ "sw-resize" => SwResizeCursor = 24,
+ "w-resize" => WResizeCursor = 25,
+ "ew-resize" => EwResizeCursor = 26,
+ "ns-resize" => NsResizeCursor = 27,
+ "nesw-resize" => NeswResizeCursor = 28,
+ "nwse-resize" => NwseResizeCursor = 29,
+ "col-resize" => ColResizeCursor = 30,
+ "row-resize" => RowResizeCursor = 31,
+ "all-scroll" => AllScrollCursor = 32,
+ "zoom-in" => ZoomInCursor = 33,
+ "zoom-out" => ZoomOutCursor = 34,
+}