mirror of
https://github.com/servo/servo.git
synced 2025-08-05 21:50:18 +01:00
Small changes to AdditiveTuple struct.
This commit is contained in:
parent
fdb29e15a4
commit
0722031726
1 changed files with 9 additions and 7 deletions
|
@ -536,7 +536,7 @@ impl Parse for AdditiveSymbols {
|
||||||
fn parse(context: &ParserContext, input: &mut Parser) -> Result<Self, ()> {
|
fn parse(context: &ParserContext, input: &mut Parser) -> Result<Self, ()> {
|
||||||
let tuples = Vec::<AdditiveTuple>::parse(context, input)?;
|
let tuples = Vec::<AdditiveTuple>::parse(context, input)?;
|
||||||
// FIXME maybe? https://github.com/w3c/csswg-drafts/issues/1220
|
// FIXME maybe? https://github.com/w3c/csswg-drafts/issues/1220
|
||||||
if tuples.windows(2).any(|window| window[0].value <= window[1].value) {
|
if tuples.windows(2).any(|window| window[0].weight <= window[1].weight) {
|
||||||
return Err(())
|
return Err(())
|
||||||
}
|
}
|
||||||
Ok(AdditiveSymbols(tuples))
|
Ok(AdditiveSymbols(tuples))
|
||||||
|
@ -552,8 +552,10 @@ impl ToCss for AdditiveSymbols {
|
||||||
/// <integer> && <symbol>
|
/// <integer> && <symbol>
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct AdditiveTuple {
|
pub struct AdditiveTuple {
|
||||||
value: u32,
|
/// <integer>
|
||||||
symbol: Symbol,
|
pub weight: u32,
|
||||||
|
/// <symbol>
|
||||||
|
pub symbol: Symbol,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl OneOrMoreCommaSeparated for AdditiveTuple {}
|
impl OneOrMoreCommaSeparated for AdditiveTuple {}
|
||||||
|
@ -561,13 +563,13 @@ impl OneOrMoreCommaSeparated for AdditiveTuple {}
|
||||||
impl Parse for AdditiveTuple {
|
impl Parse for AdditiveTuple {
|
||||||
fn parse(context: &ParserContext, input: &mut Parser) -> Result<Self, ()> {
|
fn parse(context: &ParserContext, input: &mut Parser) -> Result<Self, ()> {
|
||||||
let symbol = input.try(|input| Symbol::parse(context, input));
|
let symbol = input.try(|input| Symbol::parse(context, input));
|
||||||
let value = input.expect_integer()?;
|
let weight = input.expect_integer()?;
|
||||||
if value < 0 {
|
if weight < 0 {
|
||||||
return Err(())
|
return Err(())
|
||||||
}
|
}
|
||||||
let symbol = symbol.or_else(|()| Symbol::parse(context, input))?;
|
let symbol = symbol.or_else(|()| Symbol::parse(context, input))?;
|
||||||
Ok(AdditiveTuple {
|
Ok(AdditiveTuple {
|
||||||
value: value as u32,
|
weight: weight as u32,
|
||||||
symbol: symbol,
|
symbol: symbol,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -575,7 +577,7 @@ impl Parse for AdditiveTuple {
|
||||||
|
|
||||||
impl ToCss for AdditiveTuple {
|
impl ToCss for AdditiveTuple {
|
||||||
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
|
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
|
||||||
write!(dest, "{} ", self.value)?;
|
write!(dest, "{} ", self.weight)?;
|
||||||
self.symbol.to_css(dest)
|
self.symbol.to_css(dest)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue