diff --git a/components/style/gecko/url.rs b/components/style/gecko/url.rs index 191ae082726..1dfc04d100b 100644 --- a/components/style/gecko/url.rs +++ b/components/style/gecko/url.rs @@ -6,6 +6,7 @@ use cssparser::CssStringWriter; use gecko_bindings::structs::{ServoBundledURI, URLExtraData}; +use gecko_bindings::structs::root::mozilla::css::ImageValue; use gecko_bindings::sugar::refptr::RefPtr; use parser::ParserContext; use std::borrow::Cow; @@ -24,6 +25,10 @@ pub struct SpecifiedUrl { /// The URL extra data. pub extra_data: RefPtr, + + /// Cache ImageValue, if any, so that we can reuse it while rematching a + /// a property with this specified url value. + pub image_value: Option>, } impl SpecifiedUrl { @@ -37,6 +42,7 @@ impl SpecifiedUrl { Ok(SpecifiedUrl { serialization: Arc::new(url.into_owned()), extra_data: context.url_data.clone(), + image_value: None, }) } @@ -76,6 +82,21 @@ impl SpecifiedUrl { mExtraData: self.extra_data.get(), } } + + /// Build and carry an image value on request. + pub fn build_image_value(&mut self) { + use gecko_bindings::bindings::Gecko_ImageValue_Create; + + debug_assert_eq!(self.image_value, None); + self.image_value = { + unsafe { + let ptr = Gecko_ImageValue_Create(self.for_ffi()); + // We do not expect Gecko_ImageValue_Create returns null. + debug_assert!(!ptr.is_null()); + Some(RefPtr::from_addrefed(ptr)) + } + } + } } impl ToCss for SpecifiedUrl { diff --git a/components/style/properties/longhand/box.mako.rs b/components/style/properties/longhand/box.mako.rs index eeb2100b11e..86b2e7d95e2 100644 --- a/components/style/properties/longhand/box.mako.rs +++ b/components/style/properties/longhand/box.mako.rs @@ -2441,6 +2441,7 @@ ${helpers.single_keyword("-moz-appearance", ${helpers.predefined_type("-moz-binding", "UrlOrNone", "Either::Second(None_)", products="gecko", + boxed="True" if product == "gecko" else "False", animation_value_type="none", gecko_ffi_name="mBinding", spec="Nonstandard (https://developer.mozilla.org/en-US/docs/Web/CSS/-moz-binding)", diff --git a/components/style/properties/longhand/inherited_svg.mako.rs b/components/style/properties/longhand/inherited_svg.mako.rs index 33cda168d50..d7acf552e89 100644 --- a/components/style/properties/longhand/inherited_svg.mako.rs +++ b/components/style/properties/longhand/inherited_svg.mako.rs @@ -120,16 +120,19 @@ ${helpers.single_keyword("clip-rule", "nonzero evenodd", ${helpers.predefined_type("marker-start", "UrlOrNone", "Either::Second(None_)", products="gecko", + boxed="True" if product == "gecko" else "False", animation_value_type="none", spec="https://www.w3.org/TR/SVG2/painting.html#VertexMarkerProperties")} ${helpers.predefined_type("marker-mid", "UrlOrNone", "Either::Second(None_)", products="gecko", + boxed="True" if product == "gecko" else "False", animation_value_type="none", spec="https://www.w3.org/TR/SVG2/painting.html#VertexMarkerProperties")} ${helpers.predefined_type("marker-end", "UrlOrNone", "Either::Second(None_)", products="gecko", + boxed="True" if product == "gecko" else "False", animation_value_type="none", spec="https://www.w3.org/TR/SVG2/painting.html#VertexMarkerProperties")} diff --git a/components/style/values/specified/image.rs b/components/style/values/specified/image.rs index dcbc5db1c5c..9266bec885b 100644 --- a/components/style/values/specified/image.rs +++ b/components/style/values/specified/image.rs @@ -82,14 +82,34 @@ pub type ImageRect = GenericImageRect; impl Parse for Image { fn parse(context: &ParserContext, input: &mut Parser) -> Result { - if let Ok(url) = input.try(|input| SpecifiedUrl::parse(context, input)) { - return Ok(GenericImage::Url(url)); + #[cfg(feature = "gecko")] + { + if let Ok(mut url) = input.try(|input| SpecifiedUrl::parse(context, input)) { + url.build_image_value(); + return Ok(GenericImage::Url(url)); + } + } + #[cfg(feature = "servo")] + { + if let Ok(url) = input.try(|input| SpecifiedUrl::parse(context, input)) { + return Ok(GenericImage::Url(url)); + } } if let Ok(gradient) = input.try(|i| Gradient::parse(context, i)) { return Ok(GenericImage::Gradient(gradient)); } - if let Ok(image_rect) = input.try(|input| ImageRect::parse(context, input)) { - return Ok(GenericImage::Rect(image_rect)); + #[cfg(feature = "gecko")] + { + if let Ok(mut image_rect) = input.try(|input| ImageRect::parse(context, input)) { + image_rect.url.build_image_value(); + return Ok(GenericImage::Rect(image_rect)); + } + } + #[cfg(feature = "servo")] + { + if let Ok(image_rect) = input.try(|input| ImageRect::parse(context, input)) { + return Ok(GenericImage::Rect(image_rect)); + } } Ok(GenericImage::Element(Image::parse_element(input)?))