diff --git a/components/style/properties/longhands/svg.mako.rs b/components/style/properties/longhands/svg.mako.rs index 36105247676..acdb809135f 100644 --- a/components/style/properties/longhands/svg.mako.rs +++ b/components/style/properties/longhands/svg.mako.rs @@ -183,6 +183,7 @@ ${helpers.predefined_type( "ImageLayer", "Either::First(None_)", initial_specified_value="Either::First(None_)", + parse_method="parse_with_cors_anonymous", spec="https://drafts.fxtf.org/css-masking/#propdef-mask-image", vector=True, products="gecko", diff --git a/components/style/values/specified/image.rs b/components/style/values/specified/image.rs index 1b080816e83..b1a611846a8 100644 --- a/components/style/values/specified/image.rs +++ b/components/style/values/specified/image.rs @@ -33,6 +33,20 @@ use values::specified::url::SpecifiedImageUrl; /// A specified image layer. pub type ImageLayer = Either; +impl ImageLayer { + /// This is a specialization of Either with an alternative parse + /// method to provide anonymous CORS headers for the Image url fetch. + pub fn parse_with_cors_anonymous<'i, 't>( + context: &ParserContext, + input: &mut Parser<'i, 't>, + ) -> Result> { + if let Ok(v) = input.try(|i| None_::parse(context, i)) { + return Ok(Either::First(v)); + } + Image::parse_with_cors_anonymous(context, input).map(Either::Second) + } +} + /// Specified values for an image according to CSS-IMAGES. /// pub type Image = generic::Image;