Support list-style-image in stylo. r=manishearth draft
authorCameron McCormack <cam@mcc.id.au>
Sun, 16 Oct 2016 11:03:58 +0800
changeset 425808 1e9c6e1751dcc581270a3eef051f1fdcba7c1bf1
parent 425807 1ac6af7a64b26bed2506ce204821c92e19844917
child 425948 dfc819b1b45968b92dc68995012346328c4c32f3
push id32513
push userbmo:cam@mcc.id.au
push dateMon, 17 Oct 2016 05:26:21 +0000
reviewersmanishearth
milestone52.0a1
Support list-style-image in stylo. r=manishearth MozReview-Commit-ID: HyGWZevQYEo
servo/components/style/properties/gecko.mako.rs
--- a/servo/components/style/properties/gecko.mako.rs
+++ b/servo/components/style/properties/gecko.mako.rs
@@ -12,18 +12,20 @@
 use app_units::Au;
 use custom_properties::ComputedValuesMap;
 % for style_struct in data.style_structs:
 use gecko_bindings::structs::${style_struct.gecko_ffi_name};
 use gecko_bindings::bindings::Gecko_Construct_${style_struct.gecko_ffi_name};
 use gecko_bindings::bindings::Gecko_CopyConstruct_${style_struct.gecko_ffi_name};
 use gecko_bindings::bindings::Gecko_Destroy_${style_struct.gecko_ffi_name};
 % endfor
-use gecko_bindings::bindings::{Gecko_CopyMozBindingFrom, Gecko_CopyListStyleTypeFrom};
-use gecko_bindings::bindings::{Gecko_SetMozBinding, Gecko_SetListStyleType};
+use gecko_bindings::bindings::{Gecko_CopyMozBindingFrom, Gecko_CopyListStyleImageFrom};
+use gecko_bindings::bindings::Gecko_CopyListStyleTypeFrom;
+use gecko_bindings::bindings::{Gecko_SetMozBinding, Gecko_SetListStyleImage};
+use gecko_bindings::bindings::{Gecko_SetListStyleImageNone, Gecko_SetListStyleType};
 use gecko_bindings::bindings::{Gecko_SetNullImageValue, Gecko_SetGradientImageValue};
 use gecko_bindings::bindings::{Gecko_SetUrlImageValue};
 use gecko_bindings::bindings::{Gecko_EnsureImageLayersLength, Gecko_CreateGradient};
 use gecko_bindings::bindings::{Gecko_CopyImageValueFrom, Gecko_CopyFontFamilyFrom};
 use gecko_bindings::bindings::{Gecko_FontFamilyList_AppendGeneric, Gecko_FontFamilyList_AppendNamed};
 use gecko_bindings::bindings::{Gecko_FontFamilyList_Clear};
 use gecko_bindings::bindings::ServoComputedValuesBorrowedOrNull;
 use gecko_bindings::structs;
@@ -458,18 +460,17 @@ impl Debug for ${style_struct.gecko_stru
     force_stub += ["animation-name", "animation-duration",
                   "animation-timing-function", "animation-iteration-count",
                   "animation-direction", "animation-play-state",
                   "animation-fill-mode", "animation-delay"]
 
     # These are part of shorthands so we must include them in stylo builds,
     # but we haven't implemented the stylo glue for the longhand
     # so we generate a stub
-    force_stub += ["list-style-image", # box
-                   "flex-basis", # position
+    force_stub += ["flex-basis", # position
 
                    # transition
                    "transition-duration", "transition-timing-function",
                    "transition-property", "transition-delay",
                    ]
 
     # Types used with predefined_type()-defined properties that we can auto-generate.
     predefined_types = {
@@ -1453,17 +1454,48 @@ fn static_assert() {
         match servo {
             T::scroll => structs::NS_STYLE_IMAGELAYER_ATTACHMENT_SCROLL as u8,
             T::fixed => structs::NS_STYLE_IMAGELAYER_ATTACHMENT_FIXED as u8,
             T::local => structs::NS_STYLE_IMAGELAYER_ATTACHMENT_LOCAL as u8,
         }
     </%self:simple_image_array_property>
 </%self:impl_trait>
 
-<%self:impl_trait style_struct_name="List" skip_longhands="list-style-type" skip_additionals="*">
+<%self:impl_trait style_struct_name="List"
+                  skip_longhands="list-style-image list-style-type"
+                  skip_additionals="*">
+
+    pub fn set_list_style_image(&mut self, image: longhands::list_style_image::computed_value::T) {
+        use values::computed::UrlOrNone;
+        match image {
+            UrlOrNone::None => {
+                unsafe {
+                    Gecko_SetListStyleImageNone(&mut self.gecko);
+                }
+            }
+            UrlOrNone::Url(ref url, ref extra_data) => {
+                unsafe {
+                    Gecko_SetListStyleImage(&mut self.gecko,
+                                            url.as_str().as_ptr(),
+                                            url.as_str().len() as u32,
+                                            extra_data.base.as_raw(),
+                                            extra_data.referrer.as_raw(),
+                                            extra_data.principal.as_raw());
+                }
+                // We don't need to record this struct as uncacheable, like when setting
+                // background-image to a url() value, since only properties in reset structs
+                // are re-used from the applicable declaration cache, and the List struct
+                // is an inherited struct.
+            }
+        }
+    }
+
+    pub fn copy_list_style_image_from(&mut self, other: &Self) {
+        unsafe { Gecko_CopyListStyleImageFrom(&mut self.gecko, &other.gecko); }
+    }
 
     ${impl_keyword_setter("list_style_type", "__LIST_STYLE_TYPE__",
                            data.longhands_by_name["list-style-type"].keyword)}
     pub fn copy_list_style_type_from(&mut self, other: &Self) {
         unsafe {
             Gecko_CopyListStyleTypeFrom(&mut self.gecko, &other.gecko);
         }
     }