Bug 1738296 - Fix broken 'list-style' serialization. r=emilio

Differential Revision: https://phabricator.services.mozilla.com/D129847
This commit is contained in:
Mats Palmgren 2021-10-28 17:06:53 +00:00
Родитель 2028fd222a
Коммит 1169c0cdc1
3 изменённых файлов: 43 добавлений и 14 удалений

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

@ -7,7 +7,6 @@
<%helpers:shorthand name="list-style"
engines="gecko servo-2013 servo-2020"
sub_properties="list-style-position list-style-image list-style-type"
derive_serialize="True"
spec="https://drafts.csswg.org/css-lists/#propdef-list-style">
use crate::properties::longhands::{list_style_image, list_style_position, list_style_type};
use crate::values::specified::Image;
@ -104,4 +103,35 @@
_ => Err(input.new_custom_error(StyleParseErrorKind::UnspecifiedError)),
}
}
impl<'a> ToCss for LonghandsToSerialize<'a> {
fn to_css<W>(&self, dest: &mut CssWriter<W>) -> fmt::Result where W: fmt::Write {
use longhands::list_style_position::SpecifiedValue as ListStylePosition;
use longhands::list_style_type::SpecifiedValue as ListStyleType;
use longhands::list_style_image::SpecifiedValue as ListStyleImage;
let mut have_one_non_initial_value = false;
if self.list_style_position != &ListStylePosition::Outside {
self.list_style_position.to_css(dest)?;
have_one_non_initial_value = true;
}
if self.list_style_image != &ListStyleImage::None {
if have_one_non_initial_value {
dest.write_str(" ")?;
}
self.list_style_image.to_css(dest)?;
have_one_non_initial_value = true;
}
if self.list_style_type != &ListStyleType::disc() {
if have_one_non_initial_value {
dest.write_str(" ")?;
}
self.list_style_type.to_css(dest)?;
have_one_non_initial_value = true;
}
if !have_one_non_initial_value {
self.list_style_position.to_css(dest)?;
}
Ok(())
}
}
</%helpers:shorthand>

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

@ -1,13 +0,0 @@
[list-style-valid.html]
[e.style['list-style'\] = "inside" should set the property value]
expected: FAIL
[e.style['list-style'\] = "url(\\"https://example.com/\\")" should set the property value]
expected: FAIL
[e.style['list-style'\] = "none" should set the property value]
expected: FAIL
[e.style['list-style'\] = "square" should set the property value]
expected: FAIL

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

@ -12,12 +12,24 @@
<body>
<script>
test_valid_value('list-style', 'none');
test_valid_value('list-style', 'disc outside none', 'outside');
test_valid_value('list-style', 'inside');
test_valid_value('list-style', 'inside disc', 'inside');
test_valid_value('list-style', 'inside none');
test_valid_value('list-style', 'inside none none', 'inside none');
test_valid_value('list-style', 'none inside none', 'inside none');
test_valid_value('list-style', 'none none inside', 'inside none');
test_valid_value('list-style', 'none inside', 'inside none');
test_valid_value('list-style', 'url("https://example.com/")');
test_valid_value('list-style', 'none url("https://example.com/")', 'url("https://example.com/") none');
test_valid_value('list-style', 'url("https://example.com/") disc', 'url("https://example.com/")');
test_valid_value('list-style', 'url("https://example.com/") disc outside', 'url("https://example.com/")');
test_valid_value('list-style', 'square');
test_valid_value('list-style', 'square url("https://example.com/") inside', 'inside url("https://example.com/") square');
test_valid_value('list-style', 'square linear-gradient(red,blue) inside', 'inside linear-gradient(red, blue) square');
test_valid_value('list-style', 'disc radial-gradient(circle, #006, #00a 90%, #0000af 100%,white 100%) inside', 'inside radial-gradient(circle, rgb(0, 0, 102), rgb(0, 0, 170) 90%, rgb(0, 0, 175) 100%, white 100%)');
</script>
</body>
</html>