Use the ParserContext along with Parser in the parse function

This commit is contained in:
Ravi Shankar 2016-11-26 14:45:38 +05:30
parent c4f87f451f
commit dee1a65a69
30 changed files with 318 additions and 285 deletions

View file

@ -7,7 +7,7 @@
//! [values]: https://drafts.csswg.org/css-values/
pub use cssparser::{RGBA, Parser};
use parser::Parse;
use parser::{Parse, ParserContext};
use std::fmt::{self, Debug};
use style_traits::ToCss;
@ -83,7 +83,7 @@ macro_rules! define_keyword_type {
}
impl Parse for $name {
fn parse(input: &mut ::cssparser::Parser) -> Result<$name, ()> {
fn parse(_context: &ParserContext, input: &mut ::cssparser::Parser) -> Result<$name, ()> {
input.expect_ident_matching($css).map(|_| $name)
}
}
@ -132,11 +132,11 @@ impl<A: HasViewportPercentage, B: HasViewportPercentage> HasViewportPercentage f
}
impl<A: Parse, B: Parse> Parse for Either<A, B> {
fn parse(input: &mut Parser) -> Result<Either<A, B>, ()> {
if let Ok(v) = input.try(|i| A::parse(i)) {
fn parse(context: &ParserContext, input: &mut Parser) -> Result<Either<A, B>, ()> {
if let Ok(v) = input.try(|i| A::parse(context, i)) {
Ok(Either::First(v))
} else {
B::parse(input).map(Either::Second)
B::parse(context, input).map(Either::Second)
}
}
}