Implement a URL-generic type for list-style-image

This should fix the following two "expected to fail" tests:

- getComputedStyle(elem) for url() listStyleImage uses the resolved URL
  and elem.style uses the original URL

- getComputedStyle(elem) for url() listStyle uses the resolved URL
  and elem.style uses the original URL
This commit is contained in:
Fausto Núñez Alberro 2018-02-24 21:44:22 +01:00
parent 8f226f841b
commit cc838f54e5
No known key found for this signature in database
GPG key ID: 475A94D9B398B2DF
26 changed files with 157 additions and 124 deletions

View file

@ -66,6 +66,7 @@ use values::generics::column::ColumnCount;
use values::generics::position::ZIndex;
use values::generics::text::MozTabSize;
use values::generics::transform::TransformStyle;
use values::generics::url::UrlOrNone;
use computed_values::border_style;
pub mod style_structs {
@ -937,10 +938,10 @@ def set_gecko_property(ffi_name, expr):
#[allow(non_snake_case)]
pub fn set_${ident}(&mut self, v: longhands::${ident}::computed_value::T) {
match v {
Either::First(url) => {
UrlOrNone::Url(ref url) => {
self.gecko.${gecko_ffi_name}.set_move(url.url_value.clone())
}
Either::Second(_none) => {
UrlOrNone::None => {
unsafe {
self.gecko.${gecko_ffi_name}.clear();
}
@ -961,15 +962,14 @@ def set_gecko_property(ffi_name, expr):
#[allow(non_snake_case)]
pub fn clone_${ident}(&self) -> longhands::${ident}::computed_value::T {
use values::specified::url::SpecifiedUrl;
use values::None_;
if self.gecko.${gecko_ffi_name}.mRawPtr.is_null() {
Either::Second(None_)
UrlOrNone::none()
} else {
unsafe {
let ref gecko_url_value = *self.gecko.${gecko_ffi_name}.mRawPtr;
Either::First(SpecifiedUrl::from_url_value_data(&gecko_url_value._base)
.expect("${gecko_ffi_name} could not convert to SpecifiedUrl"))
UrlOrNone::Url(SpecifiedUrl::from_url_value_data(&gecko_url_value._base)
.expect("${gecko_ffi_name} could not convert to SpecifiedUrl"))
}
}
}
@ -1469,7 +1469,7 @@ impl Clone for ${style_struct.gecko_struct_name} {
"SVGWidth": impl_svg_length,
"Transform": impl_transform,
"TransformOrigin": impl_transform_origin,
"UrlOrNone": impl_css_url,
"url::UrlOrNone": impl_css_url,
}
def longhand_method(longhand):
@ -4061,14 +4061,13 @@ fn static_assert() {
skip_longhands="list-style-image list-style-type quotes -moz-image-region">
pub fn set_list_style_image(&mut self, image: longhands::list_style_image::computed_value::T) {
use values::Either;
match image {
longhands::list_style_image::computed_value::T(Either::Second(_none)) => {
UrlOrNone::None => {
unsafe {
Gecko_SetListStyleImageNone(&mut self.gecko);
}
}
longhands::list_style_image::computed_value::T(Either::First(ref url)) => {
UrlOrNone::Url(ref url) => {
unsafe {
Gecko_SetListStyleImageImageValue(&mut self.gecko, url.image_value.get());
}
@ -4090,20 +4089,16 @@ fn static_assert() {
pub fn clone_list_style_image(&self) -> longhands::list_style_image::computed_value::T {
use values::specified::url::SpecifiedImageUrl;
use values::{Either, None_};
longhands::list_style_image::computed_value::T(
match self.gecko.mListStyleImage.mRawPtr.is_null() {
true => Either::Second(None_),
false => {
unsafe {
let ref gecko_image_request = *self.gecko.mListStyleImage.mRawPtr;
Either::First(SpecifiedImageUrl::from_image_request(gecko_image_request)
.expect("mListStyleImage could not convert to SpecifiedImageUrl"))
}
}
}
)
if self.gecko.mListStyleImage.mRawPtr.is_null() {
return UrlOrNone::None;
}
unsafe {
let ref gecko_image_request = *self.gecko.mListStyleImage.mRawPtr;
UrlOrNone::Url(SpecifiedImageUrl::from_image_request(gecko_image_request)
.expect("mListStyleImage could not convert to SpecifiedImageUrl"))
}
}
pub fn set_list_style_type(&mut self, v: longhands::list_style_type::computed_value::T, device: &Device) {

View file

@ -36,7 +36,7 @@ use values::animated::color::RGBA as AnimatedRGBA;
use values::animated::effects::Filter as AnimatedFilter;
use values::animated::effects::FilterList as AnimatedFilterList;
use values::computed::{Angle, CalcLengthOrPercentage};
use values::computed::{ClipRect, Context, ComputedUrl};
use values::computed::{ClipRect, Context};
use values::computed::{Length, LengthOrPercentage, LengthOrPercentageOrAuto};
use values::computed::{LengthOrPercentageOrNone, MaxLength};
use values::computed::{NonNegativeNumber, Number, NumberOrPercentage, Percentage};
@ -48,6 +48,7 @@ use values::computed::transform::Transform as ComputedTransform;
use values::computed::transform::Rotate as ComputedRotate;
use values::computed::transform::Translate as ComputedTranslate;
use values::computed::transform::Scale as ComputedScale;
use values::computed::url::ComputedUrl;
use values::generics::transform::{self, Rotate, Translate, Scale, Transform, TransformOperation};
use values::distance::{ComputeSquaredDistance, SquaredDistance};
use values::generics::font::{FontSettings as GenericFontSettings, FontTag, VariationValue};

View file

@ -613,7 +613,7 @@ ${helpers.single_keyword("-moz-appearance",
spec="Nonstandard (https://developer.mozilla.org/en-US/docs/Web/CSS/-moz-appearance)",
animation_value_type="discrete")}
${helpers.predefined_type("-moz-binding", "UrlOrNone", "Either::Second(None_)",
${helpers.predefined_type("-moz-binding", "url::UrlOrNone", "computed::url::UrlOrNone::none()",
products="gecko",
animation_value_type="none",
gecko_ffi_name="mBinding",

View file

@ -112,17 +112,17 @@ ${helpers.single_keyword("clip-rule", "nonzero evenodd",
animation_value_type="discrete",
spec="https://www.w3.org/TR/SVG11/masking.html#ClipRuleProperty")}
${helpers.predefined_type("marker-start", "UrlOrNone", "Either::Second(None_)",
${helpers.predefined_type("marker-start", "url::UrlOrNone", "computed::url::UrlOrNone::none()",
products="gecko",
animation_value_type="discrete",
spec="https://www.w3.org/TR/SVG2/painting.html#VertexMarkerProperties")}
${helpers.predefined_type("marker-mid", "UrlOrNone", "Either::Second(None_)",
${helpers.predefined_type("marker-mid", "url::UrlOrNone", "computed::url::UrlOrNone::none()",
products="gecko",
animation_value_type="discrete",
spec="https://www.w3.org/TR/SVG2/painting.html#VertexMarkerProperties")}
${helpers.predefined_type("marker-end", "UrlOrNone", "Either::Second(None_)",
${helpers.predefined_type("marker-end", "url::UrlOrNone", "computed::url::UrlOrNone::none()",
products="gecko",
animation_value_type="discrete",
spec="https://www.w3.org/TR/SVG2/painting.html#VertexMarkerProperties")}

View file

@ -41,9 +41,9 @@ ${helpers.single_keyword("list-style-position", "outside inside", animation_valu
% endif
${helpers.predefined_type("list-style-image",
"ListStyleImage",
initial_value="specified::ListStyleImage::none()",
initial_specified_value="specified::ListStyleImage::none()",
"url::ImageUrlOrNone",
initial_value="computed::url::ImageUrlOrNone::none()",
initial_specified_value="specified::url::ImageUrlOrNone::none()",
animation_value_type="discrete",
spec="https://drafts.csswg.org/css-lists/#propdef-list-style-image",
servo_restyle_damage="rebuild_and_reflow")}

View file

@ -7,7 +7,7 @@
<%helpers:shorthand name="marker" products="gecko"
sub_properties="marker-start marker-end marker-mid"
spec="https://www.w3.org/TR/SVG2/painting.html#MarkerShorthand">
use values::specified::UrlOrNone;
use values::specified::url::UrlOrNone;
pub fn parse_value<'i, 't>(context: &ParserContext, input: &mut Parser<'i, 't>)
-> Result<Longhands, ParseError<'i>> {

View file

@ -9,7 +9,7 @@
derive_serialize="True"
spec="https://drafts.csswg.org/css-lists/#propdef-list-style">
use properties::longhands::{list_style_image, list_style_position, list_style_type};
use values::{Either, None_};
use values::specified::url::ImageUrlOrNone;
pub fn parse_value<'i, 't>(context: &ParserContext, input: &mut Parser<'i, 't>)
-> Result<Longhands, ParseError<'i>> {
@ -74,7 +74,7 @@
(true, 2, None, None) => {
Ok(expanded! {
list_style_position: position,
list_style_image: list_style_image::SpecifiedValue(Either::Second(None_)),
list_style_image: ImageUrlOrNone::none(),
list_style_type: list_style_type_none(),
})
}
@ -88,14 +88,14 @@
(true, 1, Some(list_style_type), None) => {
Ok(expanded! {
list_style_position: position,
list_style_image: list_style_image::SpecifiedValue(Either::Second(None_)),
list_style_image: ImageUrlOrNone::none(),
list_style_type: list_style_type,
})
}
(true, 1, None, None) => {
Ok(expanded! {
list_style_position: position,
list_style_image: list_style_image::SpecifiedValue(Either::Second(None_)),
list_style_image: ImageUrlOrNone::none(),
list_style_type: list_style_type_none(),
})
}