Skip to content

Commit

Permalink
Implement the unitless length quirk for border-*-width
Browse files Browse the repository at this point in the history
  • Loading branch information
nox committed Apr 27, 2017
1 parent 03d24e8 commit b5a558e
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 52 deletions.
8 changes: 6 additions & 2 deletions components/style/properties/helpers.mako.rs
Expand Up @@ -8,11 +8,13 @@
%>

<%def name="predefined_type(name, type, initial_value, parse_method='parse',
needs_context=True, vector=False, computed_type=None, initial_specified_value=None, **kwargs)">
needs_context=True, vector=False, computed_type=None, initial_specified_value=None,
allow_quirks=False, **kwargs)">
<%def name="predefined_type_inner(name, type, initial_value, parse_method)">
#[allow(unused_imports)]
use app_units::Au;
use cssparser::{Color as CSSParserColor, RGBA};
use values::specified::AllowQuirks;
pub use values::specified::${type} as SpecifiedValue;
pub mod computed_value {
% if computed_type:
Expand All @@ -30,7 +32,9 @@
pub fn parse(context: &ParserContext,
input: &mut Parser)
-> Result<SpecifiedValue, ()> {
% if needs_context:
% if allow_quirks:
specified::${type}::${parse_method}_quirky(context, input, AllowQuirks::Yes)
% elif needs_context:
specified::${type}::${parse_method}(context, input)
% else:
specified::${type}::${parse_method}(input)
Expand Down
4 changes: 3 additions & 1 deletion components/style/properties/longhand/border.mako.rs
Expand Up @@ -33,7 +33,9 @@
computed_type="::app_units::Au",
alias=maybe_moz_logical_alias(product, side, "-moz-border-%s-width"),
spec=maybe_logical_spec(side, "width"),
animation_value_type="ComputedValue", logical=side[1])}
animation_value_type="ComputedValue",
logical=side[1],
allow_quirks=not side[1])}
% endfor

${helpers.gecko_keyword_conversion(Keyword('border-style',
Expand Down
12 changes: 11 additions & 1 deletion components/style/values/specified/mod.rs
Expand Up @@ -491,7 +491,17 @@ pub enum BorderWidth {

impl Parse for BorderWidth {
fn parse(context: &ParserContext, input: &mut Parser) -> Result<BorderWidth, ()> {
match input.try(|i| Length::parse_non_negative(context, i)) {
Self::parse_quirky(context, input, AllowQuirks::No)
}
}

impl BorderWidth {
/// Parses a border width, allowing quirks.
pub fn parse_quirky(context: &ParserContext,
input: &mut Parser,
allow_quirks: AllowQuirks)
-> Result<BorderWidth, ()> {
match input.try(|i| Length::parse_non_negative_quirky(context, i, allow_quirks)) {
Ok(length) => Ok(BorderWidth::Width(length)),
Err(_) => match_ignore_ascii_case! { &try!(input.expect_ident()),
"thin" => Ok(BorderWidth::Thin),
Expand Down
48 changes: 0 additions & 48 deletions tests/wpt/metadata/quirks-mode/unitless-length.html.ini
@@ -1,17 +1,5 @@
[unitless-length.html]
type: testharness
[border-top-width: 1 (quirks)]
expected: FAIL

[border-right-width: 1 (quirks)]
expected: FAIL

[border-bottom-width: 1 (quirks)]
expected: FAIL

[border-left-width: 1 (quirks)]
expected: FAIL

[border-width: 1 (quirks)]
expected: FAIL

Expand Down Expand Up @@ -99,18 +87,6 @@
[word-spacing: 1 (quirks)]
expected: FAIL

[border-top-width: +1 (quirks)]
expected: FAIL

[border-right-width: +1 (quirks)]
expected: FAIL

[border-bottom-width: +1 (quirks)]
expected: FAIL

[border-left-width: +1 (quirks)]
expected: FAIL

[border-width: +1 (quirks)]
expected: FAIL

Expand Down Expand Up @@ -249,18 +225,6 @@
[word-spacing: -1 (quirks)]
expected: FAIL

[border-top-width: 1.5 (quirks)]
expected: FAIL

[border-right-width: 1.5 (quirks)]
expected: FAIL

[border-bottom-width: 1.5 (quirks)]
expected: FAIL

[border-left-width: 1.5 (quirks)]
expected: FAIL

[border-width: 1.5 (quirks)]
expected: FAIL

Expand Down Expand Up @@ -348,18 +312,6 @@
[word-spacing: 1.5 (quirks)]
expected: FAIL

[border-top-width: +1.5 (quirks)]
expected: FAIL

[border-right-width: +1.5 (quirks)]
expected: FAIL

[border-bottom-width: +1.5 (quirks)]
expected: FAIL

[border-left-width: +1.5 (quirks)]
expected: FAIL

[border-width: +1.5 (quirks)]
expected: FAIL

Expand Down

0 comments on commit b5a558e

Please sign in to comment.