Backed out changeset a154633506f0 (bug 1818598) for causing mochitest plain failures. CLOSED TREE

This commit is contained in:
Cosmin Sabou 2023-02-25 23:27:46 +02:00
Родитель 33c69203cb
Коммит 2a1ffc6e4f
2 изменённых файлов: 30 добавлений и 33 удалений

Просмотреть файл

@ -165,14 +165,6 @@ pub type MozImageRect = generic::GenericMozImageRect<NumberOrPercentage, Specifi
/// Empty enum on non-Gecko
pub enum MozImageRect {}
bitflags! {
struct ParseImageFlags: u8 {
const FORBID_NONE = 1 << 0;
const FORBID_IMAGE_SET = 1 << 1;
const FORBID_NON_URL = 1 << 2;
}
}
impl Parse for Image {
fn parse<'i, 't>(
context: &ParserContext,
@ -182,7 +174,8 @@ impl Parse for Image {
context,
input,
CorsMode::None,
ParseImageFlags::empty()
/* allow_none = */ true,
/* only_url = */ false,
)
}
}
@ -192,9 +185,10 @@ impl Image {
context: &ParserContext,
input: &mut Parser<'i, 't>,
cors_mode: CorsMode,
flags: ParseImageFlags
allow_none: bool,
only_url: bool,
) -> Result<Image, ParseError<'i>> {
if !flags.contains(ParseImageFlags::FORBID_NONE) && input.try_parse(|i| i.expect_ident_matching("none")).is_ok() {
if allow_none && input.try_parse(|i| i.expect_ident_matching("none")).is_ok() {
return Ok(generic::Image::None);
}
@ -204,15 +198,13 @@ impl Image {
return Ok(generic::Image::Url(url));
}
if !flags.contains(ParseImageFlags::FORBID_IMAGE_SET) {
if let Ok(is) =
input.try_parse(|input| ImageSet::parse(context, input, cors_mode, flags))
{
return Ok(generic::Image::ImageSet(Box::new(is)));
}
if let Ok(is) =
input.try_parse(|input| ImageSet::parse(context, input, cors_mode, only_url))
{
return Ok(generic::Image::ImageSet(Box::new(is)));
}
if flags.contains(ParseImageFlags::FORBID_NON_URL) {
if only_url {
return Err(input.new_custom_error(StyleParseErrorKind::UnspecifiedError));
}
@ -221,7 +213,7 @@ impl Image {
}
if cross_fade_enabled() {
if let Ok(cf) = input.try_parse(|input| CrossFade::parse(context, input, cors_mode, flags)) {
if let Ok(cf) = input.try_parse(|input| CrossFade::parse(context, input, cors_mode)) {
return Ok(generic::Image::CrossFade(Box::new(cf)));
}
}
@ -275,7 +267,8 @@ impl Image {
context,
input,
CorsMode::Anonymous,
ParseImageFlags::empty()
/* allow_none = */ true,
/* only_url = */ false,
)
}
@ -288,7 +281,8 @@ impl Image {
context,
input,
CorsMode::None,
ParseImageFlags::FORBID_NONE | ParseImageFlags::FORBID_NON_URL
/* allow_none = */ false,
/* only_url = */ true,
)
}
}
@ -299,11 +293,10 @@ impl CrossFade {
context: &ParserContext,
input: &mut Parser<'i, 't>,
cors_mode: CorsMode,
flags: ParseImageFlags
) -> Result<Self, ParseError<'i>> {
input.expect_function_matching("cross-fade")?;
let elements = input.parse_nested_block(|input| {
input.parse_comma_separated(|input| CrossFadeElement::parse(context, input, cors_mode, flags))
input.parse_comma_separated(|input| CrossFadeElement::parse(context, input, cors_mode))
})?;
let elements = crate::OwnedSlice::from(elements);
Ok(Self { elements })
@ -330,12 +323,11 @@ impl CrossFadeElement {
context: &ParserContext,
input: &mut Parser<'i, 't>,
cors_mode: CorsMode,
flags: ParseImageFlags
) -> Result<Self, ParseError<'i>> {
// Try and parse a leading percent sign.
let mut percent = Self::parse_percentage(context, input);
// Parse the image
let image = CrossFadeImage::parse(context, input, cors_mode, flags)?;
let image = CrossFadeImage::parse(context, input, cors_mode)?;
// Try and parse a trailing percent sign.
if percent.is_none() {
percent = Self::parse_percentage(context, input);
@ -352,12 +344,11 @@ impl CrossFadeImage {
context: &ParserContext,
input: &mut Parser<'i, 't>,
cors_mode: CorsMode,
flags: ParseImageFlags
) -> Result<Self, ParseError<'i>> {
if let Ok(image) = input.try_parse(|input| {
Image::parse_with_cors_mode(
context, input, cors_mode,
flags | ParseImageFlags::FORBID_NONE
context, input, cors_mode, /* allow_none = */ false,
/* only_url = */ false,
)
}) {
return Ok(Self::Image(image));
@ -371,7 +362,7 @@ impl ImageSet {
context: &ParserContext,
input: &mut Parser<'i, 't>,
cors_mode: CorsMode,
flags: ParseImageFlags
only_url: bool,
) -> Result<Self, ParseError<'i>> {
let function = input.expect_function()?;
match_ignore_ascii_case! { &function,
@ -383,7 +374,7 @@ impl ImageSet {
}
let items = input.parse_nested_block(|input| {
input.parse_comma_separated(|input| {
ImageSetItem::parse(context, input, cors_mode, flags)
ImageSetItem::parse(context, input, cors_mode, only_url)
})
})?;
Ok(Self {
@ -403,7 +394,7 @@ impl ImageSetItem {
context: &ParserContext,
input: &mut Parser<'i, 't>,
cors_mode: CorsMode,
flags: ParseImageFlags
only_url: bool,
) -> Result<Self, ParseError<'i>> {
let image = match input.try_parse(|i| i.expect_url_or_string()) {
Ok(url) => Image::Url(SpecifiedImageUrl::parse_from_string(
@ -412,8 +403,8 @@ impl ImageSetItem {
cors_mode,
)),
Err(..) => Image::parse_with_cors_mode(
context, input, cors_mode,
flags | ParseImageFlags::FORBID_NONE | ParseImageFlags::FORBID_IMAGE_SET
context, input, cors_mode, /* allow_none = */ false,
/* only_url = */ only_url,
)?,
};

Просмотреть файл

@ -10,3 +10,9 @@
[e.style['content'\] = "-webkit-image-set(url(\\"example.png\\") 192dpi, linear-gradient(black, white) 1x)" should set the property value]
expected: FAIL
[e.style['background-image'\] = "image-set(image-set(url(example.png)) 2x)" should not set the property value]
expected: FAIL
[e.style['background-image'\] = "-webkit-image-set(image-set(url(example.png)) 2x)" should not set the property value]
expected: FAIL