Stylo - reset longhands of border-image to their initial value while parsing border shorthand.

To do so, we need to declare the border-image longhands as part of border
shorthand and always reset them. This could fix couple stylo test failures.
See Gecko Bug 1357350 for the test update patches.

Spec link: https://drafts.csswg.org/css-backgrounds-3/#the-border-shorthands

Note that two unit tests have been fixed as well:

1. border_should_serialize_correctly
To verify the correctness of serialization of 'border' shorthand, we need
to reset 'border-image' as well.

2. same_longhands_should_serialize_correctly
Due to the same reason as above, since the 'border-image' is not reset,
the test expectation should be fixed.
This commit is contained in:
Jeremy Chen 2017-04-18 16:56:04 +00:00
parent 350d9c6c47
commit 43525819f4
2 changed files with 28 additions and 23 deletions

View file

@ -122,13 +122,18 @@ pub fn parse_border(context: &ParserContext, input: &mut Parser)
</%helpers:shorthand>
% endfor
<%helpers:shorthand name="border" sub_properties="${' '.join(
'border-%s-%s' % (side, prop)
for side in ['top', 'right', 'bottom', 'left']
for prop in ['color', 'style', 'width']
)}" spec="https://drafts.csswg.org/css-backgrounds/#border">
<%helpers:shorthand name="border"
sub_properties="${' '.join('border-%s-%s' % (side, prop)
for side in ['top', 'right', 'bottom', 'left']
for prop in ['color', 'style', 'width'])}
${' '.join('border-image-%s' % name
for name in ['outset', 'repeat', 'slice', 'source', 'width'])}"
spec="https://drafts.csswg.org/css-backgrounds/#border">
pub fn parse_value(context: &ParserContext, input: &mut Parser) -> Result<Longhands, ()> {
use properties::longhands::{border_image_outset, border_image_repeat, border_image_slice};
use properties::longhands::{border_image_source, border_image_width};
let (color, style, width) = try!(super::parse_border(context, input));
Ok(Longhands {
% for side in ["top", "right", "bottom", "left"]:
@ -136,6 +141,12 @@ pub fn parse_border(context: &ParserContext, input: &mut Parser)
border_${side}_style: style,
border_${side}_width: width.clone(),
% endfor
// The border shorthand resets border-image to its initial value.
// See https://drafts.csswg.org/css-backgrounds-3/#the-border-shorthands
% for name in "outset repeat slice source width".split():
border_image_${name}: border_image_${name}::get_initial_specified_value(),
% endfor
})
}