From d8dcc52c9adf713c31941ac7df9697310af8b421 Mon Sep 17 00:00:00 2001 From: Daisuke Akatsuka Date: Wed, 5 Jul 2017 13:11:58 +0900 Subject: [PATCH] implements nsStyleImageRequest type properties animatable --- components/style/gecko/url.rs | 14 ++++++++++++++ components/style/properties/gecko.mako.rs | 18 ++++++++++++++++++ .../style/properties/longhand/list.mako.rs | 2 +- 3 files changed, 33 insertions(+), 1 deletion(-) diff --git a/components/style/gecko/url.rs b/components/style/gecko/url.rs index bafab1c31d9a..dca3f6f0db79 100644 --- a/components/style/gecko/url.rs +++ b/components/style/gecko/url.rs @@ -7,6 +7,7 @@ use gecko_bindings::structs::{ServoBundledURI, URLExtraData}; use gecko_bindings::structs::mozilla::css::URLValueData; use gecko_bindings::structs::root::mozilla::css::ImageValue; +use gecko_bindings::structs::root::nsStyleImageRequest; use gecko_bindings::sugar::refptr::RefPtr; use parser::ParserContext; use std::fmt; @@ -62,6 +63,19 @@ impl SpecifiedUrl { }) } + /// Convert from nsStyleImageRequest to SpecifiedUrl. + pub unsafe fn from_image_request(image_request: &nsStyleImageRequest) -> Result { + if image_request.mImageValue.mRawPtr.is_null() { + return Err(()); + } + + let image_value = image_request.mImageValue.mRawPtr.as_ref().unwrap(); + let ref url_value_data = image_value._base; + let mut result = try!(Self::from_url_value_data(url_value_data)); + result.build_image_value(); + Ok(result) + } + /// Returns true if this URL looks like a fragment. /// See https://drafts.csswg.org/css-values/#local-urls pub fn is_fragment(&self) -> bool { diff --git a/components/style/properties/gecko.mako.rs b/components/style/properties/gecko.mako.rs index 70169b8020bd..a2e74b907954 100644 --- a/components/style/properties/gecko.mako.rs +++ b/components/style/properties/gecko.mako.rs @@ -3413,6 +3413,24 @@ fn static_assert() { unsafe { Gecko_CopyListStyleImageFrom(&mut self.gecko, &other.gecko); } } + pub fn clone_list_style_image(&self) -> longhands::list_style_image::computed_value::T { + use values::specified::url::SpecifiedUrl; + use values::{Either, None_}; + + longhands::list_style_image::computed_value::T( + match self.gecko.mListStyleImage.mRawPtr.is_null() { + true => Either::Second(None_), + false => { + unsafe { + let ref gecko_image_request = *self.gecko.mListStyleImage.mRawPtr; + Either::First(SpecifiedUrl::from_image_request(gecko_image_request) + .expect("mListStyleImage could not convert to SpecifiedUrl")) + } + } + } + ) + } + pub fn set_list_style_type(&mut self, v: longhands::list_style_type::computed_value::T, device: &Device) { use gecko_bindings::bindings::Gecko_SetCounterStyleToString; use nsstring::{nsACString, nsCString}; diff --git a/components/style/properties/longhand/list.mako.rs b/components/style/properties/longhand/list.mako.rs index 6c7e8251df7f..d675e9b589b5 100644 --- a/components/style/properties/longhand/list.mako.rs +++ b/components/style/properties/longhand/list.mako.rs @@ -100,7 +100,7 @@ ${helpers.single_keyword("list-style-position", "outside inside", animation_valu % endif -<%helpers:longhand name="list-style-image" animation_value_type="none" +<%helpers:longhand name="list-style-image" animation_value_type="discrete" boxed="${product == 'gecko'}" spec="https://drafts.csswg.org/css-lists/#propdef-list-style-image"> use values::computed::ComputedValueAsSpecified;