Skip to content
Browse files

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:

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.
  • Loading branch information...
chenpighead committed Apr 18, 2017
1 parent 350d9c6 commit 43525819f4f40d0852f49724592ebc75dd5cf849
Showing with 28 additions and 23 deletions.
  1. +16 −5 components/style/properties/shorthand/
  2. +12 −18 tests/unit/style/properties/
@@ -122,20 +122,31 @@ pub fn parse_border(context: &ParserContext, input: &mut Parser)
% 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="">
<%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'])}"

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"]:
border_${side}_color: color.clone(),
border_${side}_style: style,
border_${side}_width: width.clone(),
% endfor

// The ‘border’ shorthand resets ‘border-image’ to its initial value.
// See
% for name in "outset repeat slice source width".split():
border_image_${name}: border_image_${name}::get_initial_specified_value(),
% endfor

@@ -274,7 +274,7 @@ mod shorthand_serialization {

let serialization = shorthand_properties_to_string(properties);
assert_eq!(serialization, "border: 30px solid rgb(0, 0, 255);");
assert_eq!(serialization, "border-style: solid; border-width: 30px; border-color: rgb(0, 0, 255);");

@@ -475,26 +475,20 @@ mod shorthand_serialization {

fn border_should_serialize_correctly() {
let mut properties = Vec::new();
let (width, style, color) = get_border_property_values();


// According to,
// the ‘border’ shorthand resets ‘border-image’ to its initial value. To verify the
// serialization of 'border' shorthand, we need to set 'border-image' as well.
let block_text = "\
border-top: 4px solid; \
border-right: 4px solid; \
border-bottom: 4px solid; \
border-left: 4px solid; \
border-image: none;";

let block = parse(|c, i| Ok(parse_property_declaration_list(c, i)), block_text).unwrap();

let serialization = block.to_css_string();

let serialization = shorthand_properties_to_string(properties);
assert_eq!(serialization, "border: 4px solid;");

0 comments on commit 4352581

Please sign in to comment.
You can’t perform that action at this time.