style: Provide a specialized parse_method for mask-image to use CORS.

Differential Revision: https://phabricator.services.mozilla.com/D5714
This commit is contained in:
Brad Werth 2018-09-12 15:54:24 -07:00 committed by Emilio Cobos Álvarez
parent 3c6be59d22
commit b55bfc49fb
No known key found for this signature in database
GPG key ID: 056B727BB9C1027C
2 changed files with 15 additions and 0 deletions

View file

@ -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",

View file

@ -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>;