mirror of
https://github.com/servo/servo.git
synced 2025-08-05 21:50:18 +01:00
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:
parent
3c6be59d22
commit
b55bfc49fb
2 changed files with 15 additions and 0 deletions
|
@ -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",
|
||||
|
|
|
@ -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>;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue