style: Merge ImageLayer and Image.

ImageLayer is almost the only usage of Image, so keeping them in the same enum
makes the resulting C++ struct smaller, and makes it map more cleanly to
nsStyleImage.

Differential Revision: https://phabricator.services.mozilla.com/D62161
This commit is contained in:
Emilio Cobos Álvarez 2020-02-10 20:02:31 +00:00
parent c0d67f796c
commit 149cb5f5f1
12 changed files with 62 additions and 112 deletions

View file

@ -71,6 +71,10 @@ impl Parse for ClippingShape {
context: &ParserContext,
input: &mut Parser<'i, 't>,
) -> Result<Self, ParseError<'i>> {
if input.try(|i| i.expect_ident_matching("none")).is_ok() {
return Ok(ShapeSource::None);
}
if is_clip_path_path_enabled(context) {
if let Ok(p) = input.try(|i| Path::parse(context, i)) {
return Ok(ShapeSource::Path(p));
@ -91,7 +95,14 @@ impl Parse for FloatAreaShape {
context: &ParserContext,
input: &mut Parser<'i, 't>,
) -> Result<Self, ParseError<'i>> {
// Need to parse this here so that `Image::parse_with_cors_anonymous`
// doesn't parse it.
if input.try(|i| i.expect_ident_matching("none")).is_ok() {
return Ok(ShapeSource::None);
}
if let Ok(image) = input.try(|i| Image::parse_with_cors_anonymous(context, i)) {
debug_assert_ne!(image, Image::None);
return Ok(ShapeSource::ImageOrUrl(image));
}
@ -108,10 +119,6 @@ where
context: &ParserContext,
input: &mut Parser<'i, 't>,
) -> Result<Self, ParseError<'i>> {
if input.try(|i| i.expect_ident_matching("none")).is_ok() {
return Ok(ShapeSource::None);
}
fn parse_component<U: Parse>(
context: &ParserContext,
input: &mut Parser,