Skip to content

Commit

Permalink
Implement the unitless length quirk for margin
Browse files Browse the repository at this point in the history
  • Loading branch information
nox committed Apr 27, 2017
1 parent bcc6d45 commit 2aea6d8
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 33 deletions.
7 changes: 5 additions & 2 deletions components/style/properties/helpers.mako.rs
Expand Up @@ -809,7 +809,8 @@
% endif
</%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']) %>
<%call expr="self.shorthand(name, sub_properties=sub_properties, **kwargs)">
#[allow(unused_imports)]
Expand All @@ -819,7 +820,9 @@

pub fn parse_value(context: &ParserContext, input: &mut Parser) -> Result<Longhands, ()> {
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)));
% else:
try!(parse_four_sides(input, ${parser_function}));
Expand Down
3 changes: 2 additions & 1 deletion components/style/properties/shorthand/margin.mako.rs
Expand Up @@ -6,4 +6,5 @@
${helpers.four_sides_shorthand("margin", "margin-%s", "specified::LengthOrPercentageOrAuto::parse",
spec="https://drafts.csswg.org/css-box/#propdef-margin",
allowed_in_page_rule=True)}
allowed_in_page_rule=True,
allow_quirks=True)}
30 changes: 0 additions & 30 deletions tests/wpt/metadata/quirks-mode/unitless-length.html.ini
Expand Up @@ -12,9 +12,6 @@
expected:
if os == "mac": FAIL

[margin: 1 (quirks)]
expected: FAIL

[max-height: 1 (quirks)]
expected: FAIL

Expand Down Expand Up @@ -75,9 +72,6 @@
expected:
if os == "mac": FAIL

[margin: +1 (quirks)]
expected: FAIL

[max-height: +1 (quirks)]
expected: FAIL

Expand Down Expand Up @@ -138,9 +132,6 @@
expected:
if os == "mac": FAIL

[margin: -1 (quirks)]
expected: FAIL

[padding: -1 (quirks)]
expected: FAIL

Expand Down Expand Up @@ -177,9 +168,6 @@
expected:
if os == "mac": FAIL

[margin: 1.5 (quirks)]
expected: FAIL

[max-height: 1.5 (quirks)]
expected: FAIL

Expand Down Expand Up @@ -240,9 +228,6 @@
expected:
if os == "mac": FAIL

[margin: +1.5 (quirks)]
expected: FAIL

[max-height: +1.5 (quirks)]
expected: FAIL

Expand Down Expand Up @@ -303,9 +288,6 @@
expected:
if os == "mac": FAIL

[margin: -1.5 (quirks)]
expected: FAIL

[padding: -1.5 (quirks)]
expected: FAIL

Expand Down Expand Up @@ -1314,27 +1296,15 @@
expected:
if os == "mac": FAIL

[margin: 1px 2 (quirks)]
expected: FAIL

[padding: 1px 2 (quirks)]
expected: FAIL

[margin: 1 2px (quirks)]
expected: FAIL

[padding: 1 2px (quirks)]
expected: FAIL

[margin: 1 +2 (quirks)]
expected: FAIL

[padding: 1 +2 (quirks)]
expected: FAIL

[margin: 1 -2 (quirks)]
expected: FAIL

[padding: 1 -2 (quirks)]
expected: FAIL

0 comments on commit 2aea6d8

Please sign in to comment.