Bug 1357350 - reset longhands of border-image to their initial value while parsing border shorthand. draft
authorJeremy Chen <jeremychen@mozilla.com>
Wed, 19 Apr 2017 11:28:48 +0800
changeset 564863 ada43dbff106ba98ed1b33056eea0b815fe44b11
parent 564862 07b606f7ae192a25537a628073e6701635385cfd
child 624843 8eec5904c887428390440504b9050ac7c45ffa5e
push id54707
push userjichen@mozilla.com
push dateWed, 19 Apr 2017 03:29:09 +0000
bugs1357350
milestone55.0a1
Bug 1357350 - 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. Spec link: https://drafts.csswg.org/css-backgrounds-3/#the-border-shorthands MozReview-Commit-ID: LqQjSa9yFB1
servo/components/style/properties/shorthand/border.mako.rs
--- a/servo/components/style/properties/shorthand/border.mako.rs
+++ b/servo/components/style/properties/shorthand/border.mako.rs
@@ -117,30 +117,41 @@ pub fn parse_border(context: &ParserCont
                 self.border_${to_rust_ident(side)}_color
             )
         }
     }
 
     </%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"]:
                 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 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
         })
     }
 
     impl<'a> ToCss for LonghandsToSerialize<'a>  {
         fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
             let all_equal = {
                 % for side in PHYSICAL_SIDES:
                   let border_${side}_width = self.border_${side}_width;