mirror of
https://github.com/servo/servo.git
synced 2025-06-21 15:49:04 +01:00
Implement the unitless length quirk for border-spacing
This commit is contained in:
parent
080f74ca63
commit
03d24e8361
3 changed files with 24 additions and 31 deletions
|
@ -26,6 +26,7 @@ ${helpers.single_keyword("caption-side", "top bottom",
|
|||
use std::fmt;
|
||||
use style_traits::ToCss;
|
||||
use values::HasViewportPercentage;
|
||||
use values::specified::{AllowQuirks, Length};
|
||||
|
||||
pub mod computed_value {
|
||||
use app_units::Au;
|
||||
|
@ -60,8 +61,8 @@ ${helpers.single_keyword("caption-side", "top bottom",
|
|||
#[derive(Clone, Debug, PartialEq)]
|
||||
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
|
||||
pub struct SpecifiedValue {
|
||||
pub horizontal: specified::Length,
|
||||
pub vertical: Option<specified::Length>,
|
||||
pub horizontal: Length,
|
||||
pub vertical: Option<Length>,
|
||||
}
|
||||
|
||||
#[inline]
|
||||
|
@ -117,11 +118,11 @@ ${helpers.single_keyword("caption-side", "top bottom",
|
|||
pub fn parse(context: &ParserContext, input: &mut Parser) -> Result<SpecifiedValue,()> {
|
||||
let mut first = None;
|
||||
let mut second = None;
|
||||
match specified::Length::parse_non_negative(context, input) {
|
||||
match Length::parse_non_negative_quirky(context, input, AllowQuirks::Yes) {
|
||||
Err(()) => (),
|
||||
Ok(length) => {
|
||||
first = Some(length);
|
||||
if let Ok(len) = input.try(|input| specified::Length::parse_non_negative(context, input)) {
|
||||
if let Ok(len) = input.try(|i| Length::parse_non_negative_quirky(context, i, AllowQuirks::Yes)) {
|
||||
second = Some(len);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -563,13 +563,17 @@ impl Length {
|
|||
}
|
||||
|
||||
#[inline]
|
||||
fn parse_internal(context: &ParserContext, input: &mut Parser, num_context: AllowedLengthType)
|
||||
fn parse_internal(context: &ParserContext,
|
||||
input: &mut Parser,
|
||||
num_context: AllowedLengthType,
|
||||
allow_quirks: AllowQuirks)
|
||||
-> Result<Length, ()> {
|
||||
match try!(input.next()) {
|
||||
Token::Dimension(ref value, ref unit) if num_context.is_ok(value.value) =>
|
||||
Length::parse_dimension(context, value.value, unit),
|
||||
Token::Number(ref value) => {
|
||||
if value.value != 0. && !context.length_parsing_mode.allows_unitless_lengths() {
|
||||
Token::Number(ref value) if num_context.is_ok(value.value) => {
|
||||
if value.value != 0. && !context.length_parsing_mode.allows_unitless_lengths() &&
|
||||
!allow_quirks.allowed(context.quirks_mode) {
|
||||
return Err(())
|
||||
}
|
||||
Ok(Length::NoCalc(NoCalcLength::Absolute(AbsoluteLength::Px(value.value))))
|
||||
|
@ -585,7 +589,16 @@ impl Length {
|
|||
/// Parse a non-negative length
|
||||
#[inline]
|
||||
pub fn parse_non_negative(context: &ParserContext, input: &mut Parser) -> Result<Length, ()> {
|
||||
Self::parse_internal(context, input, AllowedLengthType::NonNegative)
|
||||
Self::parse_non_negative_quirky(context, input, AllowQuirks::No)
|
||||
}
|
||||
|
||||
/// Parse a non-negative length, allowing quirks.
|
||||
#[inline]
|
||||
pub fn parse_non_negative_quirky(context: &ParserContext,
|
||||
input: &mut Parser,
|
||||
allow_quirks: AllowQuirks)
|
||||
-> Result<Length, ()> {
|
||||
Self::parse_internal(context, input, AllowedLengthType::NonNegative, allow_quirks)
|
||||
}
|
||||
|
||||
/// Get an absolute length from a px value.
|
||||
|
@ -605,7 +618,7 @@ impl Length {
|
|||
|
||||
impl Parse for Length {
|
||||
fn parse(context: &ParserContext, input: &mut Parser) -> Result<Self, ()> {
|
||||
Self::parse_internal(context, input, AllowedLengthType::All)
|
||||
Self::parse_internal(context, input, AllowedLengthType::All, AllowQuirks::No)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -616,7 +629,7 @@ impl<T: Parse> Either<Length, T> {
|
|||
if let Ok(v) = input.try(|input| T::parse(context, input)) {
|
||||
return Ok(Either::Second(v));
|
||||
}
|
||||
Length::parse_internal(context, input, AllowedLengthType::NonNegative).map(Either::First)
|
||||
Length::parse_internal(context, input, AllowedLengthType::NonNegative, AllowQuirks::No).map(Either::First)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,8 +1,5 @@
|
|||
[unitless-length.html]
|
||||
type: testharness
|
||||
[border-spacing: 1 (quirks)]
|
||||
expected: FAIL
|
||||
|
||||
[border-top-width: 1 (quirks)]
|
||||
expected: FAIL
|
||||
|
||||
|
@ -102,9 +99,6 @@
|
|||
[word-spacing: 1 (quirks)]
|
||||
expected: FAIL
|
||||
|
||||
[border-spacing: +1 (quirks)]
|
||||
expected: FAIL
|
||||
|
||||
[border-top-width: +1 (quirks)]
|
||||
expected: FAIL
|
||||
|
||||
|
@ -255,9 +249,6 @@
|
|||
[word-spacing: -1 (quirks)]
|
||||
expected: FAIL
|
||||
|
||||
[border-spacing: 1.5 (quirks)]
|
||||
expected: FAIL
|
||||
|
||||
[border-top-width: 1.5 (quirks)]
|
||||
expected: FAIL
|
||||
|
||||
|
@ -357,9 +348,6 @@
|
|||
[word-spacing: 1.5 (quirks)]
|
||||
expected: FAIL
|
||||
|
||||
[border-spacing: +1.5 (quirks)]
|
||||
expected: FAIL
|
||||
|
||||
[border-top-width: +1.5 (quirks)]
|
||||
expected: FAIL
|
||||
|
||||
|
@ -1248,9 +1236,6 @@
|
|||
[top: calc(2 * 2px) (standards)]
|
||||
expected: FAIL
|
||||
|
||||
[border-spacing: 1px 2 (quirks)]
|
||||
expected: FAIL
|
||||
|
||||
[border-width: 1px 2 (quirks)]
|
||||
expected: FAIL
|
||||
|
||||
|
@ -1260,9 +1245,6 @@
|
|||
[padding: 1px 2 (quirks)]
|
||||
expected: FAIL
|
||||
|
||||
[border-spacing: 1 2px (quirks)]
|
||||
expected: FAIL
|
||||
|
||||
[border-width: 1 2px (quirks)]
|
||||
expected: FAIL
|
||||
|
||||
|
@ -1272,9 +1254,6 @@
|
|||
[padding: 1 2px (quirks)]
|
||||
expected: FAIL
|
||||
|
||||
[border-spacing: 1 +2 (quirks)]
|
||||
expected: FAIL
|
||||
|
||||
[border-width: 1 +2 (quirks)]
|
||||
expected: FAIL
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue