Bug 1356072 - Make stylo support moz-prefixed cursor values. draft
authorKuoE0 <kuoe0.tw@gmail.com>
Thu, 27 Apr 2017 16:28:08 +0800
changeset 572573 7c8577a8e82dc3a4c680f3b7ff476a3189ad8b32
parent 571131 2e7c10a9b86e30691f67855f6c8f98d984508d7c
child 572574 f4536961c689b990aca79dc31fb34184768120ff
push id57114
push userbmo:kuoe0@mozilla.com
push dateThu, 04 May 2017 10:00:18 +0000
bugs1356072
milestone55.0a1
Bug 1356072 - Make stylo support moz-prefixed cursor values. MozReview-Commit-ID: AfV0recnoXw
servo/components/style/Cargo.toml
servo/components/style/properties/gecko.mako.rs
servo/components/style_traits/Cargo.toml
servo/components/style_traits/cursor.rs
--- a/servo/components/style/Cargo.toml
+++ b/servo/components/style/Cargo.toml
@@ -8,17 +8,17 @@ publish = false
 build = "build.rs"
 
 [lib]
 name = "style"
 path = "lib.rs"
 doctest = false
 
 [features]
-gecko = ["nsstring_vendor", "rayon/unstable", "num_cpus"]
+gecko = ["nsstring_vendor", "rayon/unstable", "num_cpus", "style_traits/gecko"]
 use_bindgen = ["bindgen", "regex"]
 servo = ["serde/unstable", "serde", "serde_derive", "heapsize", "heapsize_derive",
          "style_traits/servo", "servo_atoms", "servo_config", "html5ever-atoms",
          "cssparser/heapsize", "cssparser/serde", "encoding", "smallvec/heapsizeof",
          "rayon/unstable", "servo_url"]
 testing = []
 gecko_debug = ["nsstring_vendor/gecko_debug"]
 
--- a/servo/components/style/properties/gecko.mako.rs
+++ b/servo/components/style/properties/gecko.mako.rs
@@ -3827,16 +3827,24 @@ clip-path
                 Cursor::NsResize => structs::NS_STYLE_CURSOR_NS_RESIZE,
                 Cursor::NeswResize => structs::NS_STYLE_CURSOR_NESW_RESIZE,
                 Cursor::NwseResize => structs::NS_STYLE_CURSOR_NWSE_RESIZE,
                 Cursor::ColResize => structs::NS_STYLE_CURSOR_COL_RESIZE,
                 Cursor::RowResize => structs::NS_STYLE_CURSOR_ROW_RESIZE,
                 Cursor::AllScroll => structs::NS_STYLE_CURSOR_ALL_SCROLL,
                 Cursor::ZoomIn => structs::NS_STYLE_CURSOR_ZOOM_IN,
                 Cursor::ZoomOut => structs::NS_STYLE_CURSOR_ZOOM_OUT,
+                #[cfg(feature = "gecko")]
+                Cursor::MozGrab => structs::NS_STYLE_CURSOR_GRAB,
+                #[cfg(feature = "gecko")]
+                Cursor::MozGrabbing => structs::NS_STYLE_CURSOR_GRABBING,
+                #[cfg(feature = "gecko")]
+                Cursor::MozZoomIn => structs::NS_STYLE_CURSOR_ZOOM_IN,
+                #[cfg(feature = "gecko")]
+                Cursor::MozZoomOut => structs::NS_STYLE_CURSOR_ZOOM_OUT,
             }
         } as u8;
 
         unsafe {
             Gecko_SetCursorArrayLength(&mut self.gecko, v.images.len());
         }
         for i in 0..v.images.len() {
             let image = &v.images[i];
--- a/servo/components/style_traits/Cargo.toml
+++ b/servo/components/style_traits/Cargo.toml
@@ -7,16 +7,17 @@ publish = false
 
 [lib]
 name = "style_traits"
 path = "lib.rs"
 
 [features]
 servo = ["heapsize", "heapsize_derive", "serde", "serde_derive",
          "cssparser/heapsize", "cssparser/serde"]
+gecko = []
 
 [dependencies]
 app_units = "0.4"
 cssparser = "0.13"
 euclid = "0.11"
 heapsize = {version = "0.3.0", optional = true}
 heapsize_derive = {version = "0.1", optional = true}
 serde = {version = "0.9", optional = true}
--- a/servo/components/style_traits/cursor.rs
+++ b/servo/components/style_traits/cursor.rs
@@ -2,76 +2,95 @@
  * 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 super::ToCss;
 
 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
         #[derive(Clone, Copy, Debug, Eq, PartialEq)]
         #[cfg_attr(feature = "servo", derive(Deserialize, Serialize, HeapSizeOf))]
         #[repr(u8)]
         #[allow(missing_docs)]
         pub enum Cursor {
-            $( $variant = $value ),+
+            $( $c_variant = $c_value, )+
+            $( #[cfg(feature = "gecko")] $g_variant = $g_value, )+
         }
 
         impl Cursor {
             /// Given a CSS keyword, get the corresponding cursor enum.
             pub fn from_css_keyword(keyword: &str) -> Result<Cursor, ()> {
                 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(())
                 }
             }
         }
 
         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) ),+
+                    $( Cursor::$c_variant => dest.write_str($c_css), )+
+                    $( #[cfg(feature = "gecko")] Cursor::$g_variant => dest.write_str($g_css), )+
                 }
             }
         }
     }
 }
 
 
 define_cursor! {
-    "none" => None = 0,
-    "default" => Default = 1,
-    "pointer" => Pointer = 2,
-    "context-menu" => ContextMenu = 3,
-    "help" => Help = 4,
-    "progress" => Progress = 5,
-    "wait" => Wait = 6,
-    "cell" => Cell = 7,
-    "crosshair" => Crosshair = 8,
-    "text" => Text = 9,
-    "vertical-text" => VerticalText = 10,
-    "alias" => Alias = 11,
-    "copy" => Copy = 12,
-    "move" => Move = 13,
-    "no-drop" => NoDrop = 14,
-    "not-allowed" => NotAllowed = 15,
-    "grab" => Grab = 16,
-    "grabbing" => Grabbing = 17,
-    "e-resize" => EResize = 18,
-    "n-resize" => NResize = 19,
-    "ne-resize" => NeResize = 20,
-    "nw-resize" => NwResize = 21,
-    "s-resize" => SResize = 22,
-    "se-resize" => SeResize = 23,
-    "sw-resize" => SwResize = 24,
-    "w-resize" => WResize = 25,
-    "ew-resize" => EwResize = 26,
-    "ns-resize" => NsResize = 27,
-    "nesw-resize" => NeswResize = 28,
-    "nwse-resize" => NwseResize = 29,
-    "col-resize" => ColResize = 30,
-    "row-resize" => RowResize = 31,
-    "all-scroll" => AllScroll = 32,
-    "zoom-in" => ZoomIn = 33,
-    "zoom-out" => ZoomOut = 34,
+    common properties = [
+        "none" => None = 0,
+        "default" => Default = 1,
+        "pointer" => Pointer = 2,
+        "context-menu" => ContextMenu = 3,
+        "help" => Help = 4,
+        "progress" => Progress = 5,
+        "wait" => Wait = 6,
+        "cell" => Cell = 7,
+        "crosshair" => Crosshair = 8,
+        "text" => Text = 9,
+        "vertical-text" => VerticalText = 10,
+        "alias" => Alias = 11,
+        "copy" => Copy = 12,
+        "move" => Move = 13,
+        "no-drop" => NoDrop = 14,
+        "not-allowed" => NotAllowed = 15,
+        "grab" => Grab = 16,
+        "grabbing" => Grabbing = 17,
+        "e-resize" => EResize = 18,
+        "n-resize" => NResize = 19,
+        "ne-resize" => NeResize = 20,
+        "nw-resize" => NwResize = 21,
+        "s-resize" => SResize = 22,
+        "se-resize" => SeResize = 23,
+        "sw-resize" => SwResize = 24,
+        "w-resize" => WResize = 25,
+        "ew-resize" => EwResize = 26,
+        "ns-resize" => NsResize = 27,
+        "nesw-resize" => NeswResize = 28,
+        "nwse-resize" => NwseResize = 29,
+        "col-resize" => ColResize = 30,
+        "row-resize" => RowResize = 31,
+        "all-scroll" => AllScroll = 32,
+        "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,
+    ]
 }