Skip to content

Commit

Permalink
style: Provide a specialized parse_method for mask-image to use CORS.
Browse files Browse the repository at this point in the history
  • Loading branch information
bradwerth authored and emilio committed Sep 22, 2018
1 parent 3c6be59 commit b55bfc4
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions components/style/properties/longhands/svg.mako.rs
Expand Up @@ -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",
Expand Down
14 changes: 14 additions & 0 deletions components/style/values/specified/image.rs
Expand Up @@ -33,6 +33,20 @@ use values::specified::url::SpecifiedImageUrl;
/// A specified image layer.
pub type ImageLayer = Either<None_, Image>;

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<Self, ParseError<'i>> {
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.
/// <https://drafts.csswg.org/css-images/#image-values>
pub type Image = generic::Image<Gradient, MozImageRect, SpecifiedImageUrl>;
Expand Down

0 comments on commit b55bfc4

Please sign in to comment.