Implement the unitless length quirk for border-*-width

This commit is contained in:
Anthony Ramine 2017-04-24 12:54:34 +02:00
parent 03d24e8361
commit b5a558e592
4 changed files with 20 additions and 52 deletions

View file

@ -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:
@ -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)

View file

@ -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',

View file

@ -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),

View file

@ -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
@ -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
@ -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
@ -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