Implement the unitless length quirk for margin

This commit is contained in:
Anthony Ramine 2017-04-25 00:37:32 +02:00
parent bcc6d4580d
commit 2aea6d8907
3 changed files with 7 additions and 33 deletions

View file

@ -809,7 +809,8 @@
% endif % endif
</%def> </%def>
<%def name="four_sides_shorthand(name, sub_property_pattern, parser_function, needs_context=True, **kwargs)"> <%def name="four_sides_shorthand(name, sub_property_pattern, parser_function,
needs_context=True, allow_quirks=False, **kwargs)">
<% sub_properties=' '.join(sub_property_pattern % side for side in ['top', 'right', 'bottom', 'left']) %> <% sub_properties=' '.join(sub_property_pattern % side for side in ['top', 'right', 'bottom', 'left']) %>
<%call expr="self.shorthand(name, sub_properties=sub_properties, **kwargs)"> <%call expr="self.shorthand(name, sub_properties=sub_properties, **kwargs)">
#[allow(unused_imports)] #[allow(unused_imports)]
@ -819,7 +820,9 @@
pub fn parse_value(context: &ParserContext, input: &mut Parser) -> Result<Longhands, ()> { pub fn parse_value(context: &ParserContext, input: &mut Parser) -> Result<Longhands, ()> {
let (top, right, bottom, left) = let (top, right, bottom, left) =
% if needs_context: % if allow_quirks:
try!(parse_four_sides(input, |i| ${parser_function}_quirky(context, i, specified::AllowQuirks::Yes)));
% elif needs_context:
try!(parse_four_sides(input, |i| ${parser_function}(context, i))); try!(parse_four_sides(input, |i| ${parser_function}(context, i)));
% else: % else:
try!(parse_four_sides(input, ${parser_function})); try!(parse_four_sides(input, ${parser_function}));

View file

@ -6,4 +6,5 @@
${helpers.four_sides_shorthand("margin", "margin-%s", "specified::LengthOrPercentageOrAuto::parse", ${helpers.four_sides_shorthand("margin", "margin-%s", "specified::LengthOrPercentageOrAuto::parse",
spec="https://drafts.csswg.org/css-box/#propdef-margin", spec="https://drafts.csswg.org/css-box/#propdef-margin",
allowed_in_page_rule=True)} allowed_in_page_rule=True,
allow_quirks=True)}

View file

@ -12,9 +12,6 @@
expected: expected:
if os == "mac": FAIL if os == "mac": FAIL
[margin: 1 (quirks)]
expected: FAIL
[max-height: 1 (quirks)] [max-height: 1 (quirks)]
expected: FAIL expected: FAIL
@ -75,9 +72,6 @@
expected: expected:
if os == "mac": FAIL if os == "mac": FAIL
[margin: +1 (quirks)]
expected: FAIL
[max-height: +1 (quirks)] [max-height: +1 (quirks)]
expected: FAIL expected: FAIL
@ -138,9 +132,6 @@
expected: expected:
if os == "mac": FAIL if os == "mac": FAIL
[margin: -1 (quirks)]
expected: FAIL
[padding: -1 (quirks)] [padding: -1 (quirks)]
expected: FAIL expected: FAIL
@ -177,9 +168,6 @@
expected: expected:
if os == "mac": FAIL if os == "mac": FAIL
[margin: 1.5 (quirks)]
expected: FAIL
[max-height: 1.5 (quirks)] [max-height: 1.5 (quirks)]
expected: FAIL expected: FAIL
@ -240,9 +228,6 @@
expected: expected:
if os == "mac": FAIL if os == "mac": FAIL
[margin: +1.5 (quirks)]
expected: FAIL
[max-height: +1.5 (quirks)] [max-height: +1.5 (quirks)]
expected: FAIL expected: FAIL
@ -303,9 +288,6 @@
expected: expected:
if os == "mac": FAIL if os == "mac": FAIL
[margin: -1.5 (quirks)]
expected: FAIL
[padding: -1.5 (quirks)] [padding: -1.5 (quirks)]
expected: FAIL expected: FAIL
@ -1314,27 +1296,15 @@
expected: expected:
if os == "mac": FAIL if os == "mac": FAIL
[margin: 1px 2 (quirks)]
expected: FAIL
[padding: 1px 2 (quirks)] [padding: 1px 2 (quirks)]
expected: FAIL expected: FAIL
[margin: 1 2px (quirks)]
expected: FAIL
[padding: 1 2px (quirks)] [padding: 1 2px (quirks)]
expected: FAIL expected: FAIL
[margin: 1 +2 (quirks)]
expected: FAIL
[padding: 1 +2 (quirks)] [padding: 1 +2 (quirks)]
expected: FAIL expected: FAIL
[margin: 1 -2 (quirks)]
expected: FAIL
[padding: 1 -2 (quirks)] [padding: 1 -2 (quirks)]
expected: FAIL expected: FAIL