Pass ParserContext down to lengths

To make it possible to check the rule type when parsing lengths, we need to pass
the `ParserContext` down through many layers to the place where length units are
parsed.

This change leaves it unused, so it's only to prepare for the next change.

MozReview-Commit-ID: 70YwtcCxnWw
This commit is contained in:
J. Ryan Stinnett 2017-04-11 16:00:37 +08:00
parent 1ae1d370f2
commit 1a31b87c22
31 changed files with 304 additions and 251 deletions

View file

@ -9,6 +9,7 @@ use cssparser::Parser;
use euclid::{Size2D, TypedSize2D};
use font_metrics::ServoMetricsProvider;
use media_queries::MediaType;
use parser::ParserContext;
use properties::ComputedValues;
use std::fmt;
use style_traits::{CSSPixel, ToCss};
@ -104,7 +105,7 @@ impl Expression {
/// ```
///
/// Only supports width and width ranges for now.
pub fn parse(input: &mut Parser) -> Result<Self, ()> {
pub fn parse(context: &ParserContext, input: &mut Parser) -> Result<Self, ()> {
try!(input.expect_parenthesis_block());
input.parse_nested_block(|input| {
let name = try!(input.expect_ident());
@ -112,13 +113,13 @@ impl Expression {
// TODO: Handle other media features
Ok(Expression(match_ignore_ascii_case! { &name,
"min-width" => {
ExpressionKind::Width(Range::Min(try!(specified::Length::parse_non_negative(input))))
ExpressionKind::Width(Range::Min(try!(specified::Length::parse_non_negative(context, input))))
},
"max-width" => {
ExpressionKind::Width(Range::Max(try!(specified::Length::parse_non_negative(input))))
ExpressionKind::Width(Range::Max(try!(specified::Length::parse_non_negative(context, input))))
},
"width" => {
ExpressionKind::Width(Range::Eq(try!(specified::Length::parse_non_negative(input))))
ExpressionKind::Width(Range::Eq(try!(specified::Length::parse_non_negative(context, input))))
},
_ => return Err(())
}))