Fix related to #14101

Add Parse trait implementation for some structures
This commit is contained in:
Artem Biryukov 2016-11-10 17:11:33 +03:00
parent 4b9693cf81
commit 9564673b5a
14 changed files with 149 additions and 114 deletions

View file

@ -8,6 +8,7 @@
use Atom;
use cssparser::{Delimiter, Parser, SourcePosition, Token, TokenSerializationType};
use parser::Parse;
use properties::DeclaredValue;
use std::ascii::AsciiExt;
use std::borrow::Cow;
@ -111,15 +112,17 @@ impl ComputedValue {
}
}
pub fn parse(input: &mut Parser) -> Result<SpecifiedValue, ()> {
let mut references = Some(HashSet::new());
let (first, css, last) = try!(parse_self_contained_declaration_value(input, &mut references));
Ok(SpecifiedValue {
css: css.into_owned(),
first_token_type: first,
last_token_type: last,
references: references.unwrap(),
})
impl Parse for SpecifiedValue {
fn parse(input: &mut Parser) -> Result<Self, ()> {
let mut references = Some(HashSet::new());
let (first, css, last) = try!(parse_self_contained_declaration_value(input, &mut references));
Ok(SpecifiedValue {
css: css.into_owned(),
first_token_type: first,
last_token_type: last,
references: references.unwrap(),
})
}
}
/// Parse the value of a non-custom property that contains `var()` references.