mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
implement support for the width media query
failing test for correct to_css of "width" separate test for mq and to_css implement css serialization for Eq remove PASS test expectation remove FIXME simplify serialization
This commit is contained in:
parent
a093b56c84
commit
84e9277771
3 changed files with 33 additions and 10 deletions
|
@ -42,7 +42,7 @@ impl Default for MediaList {
|
|||
pub enum Range<T> {
|
||||
Min(T),
|
||||
Max(T),
|
||||
//Eq(T), // FIXME: Implement parsing support for equality then re-enable this.
|
||||
Eq(T),
|
||||
}
|
||||
|
||||
impl Range<specified::Length> {
|
||||
|
@ -54,7 +54,7 @@ impl Range<specified::Length> {
|
|||
match *self {
|
||||
Range::Min(ref width) => Range::Min(width.to_computed_value(&context)),
|
||||
Range::Max(ref width) => Range::Max(width.to_computed_value(&context)),
|
||||
//Range::Eq(ref width) => Range::Eq(compute_width(width))
|
||||
Range::Eq(ref width) => Range::Eq(width.to_computed_value(&context))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -64,7 +64,7 @@ impl<T: Ord> Range<T> {
|
|||
match *self {
|
||||
Range::Min(ref width) => { value >= *width },
|
||||
Range::Max(ref width) => { value <= *width },
|
||||
//Range::Eq(ref width) => { value == *width },
|
||||
Range::Eq(ref width) => { value == *width },
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -127,10 +127,11 @@ impl ToCss for MediaQuery {
|
|||
for (i, &e) in self.expressions.iter().enumerate() {
|
||||
try!(write!(dest, "("));
|
||||
let (mm, l) = match e {
|
||||
Expression::Width(Range::Min(ref l)) => ("min", l),
|
||||
Expression::Width(Range::Max(ref l)) => ("max", l),
|
||||
Expression::Width(Range::Min(ref l)) => ("min-", l),
|
||||
Expression::Width(Range::Max(ref l)) => ("max-", l),
|
||||
Expression::Width(Range::Eq(ref l)) => ("", l),
|
||||
};
|
||||
try!(write!(dest, "{}-width: ", mm));
|
||||
try!(write!(dest, "{}width: ", mm));
|
||||
try!(l.to_css(dest));
|
||||
if i == self.expressions.len() - 1 {
|
||||
try!(write!(dest, ")"));
|
||||
|
@ -195,6 +196,9 @@ impl Expression {
|
|||
"max-width" => {
|
||||
Ok(Expression::Width(Range::Max(try!(specified::Length::parse_non_negative(input)))))
|
||||
},
|
||||
"width" => {
|
||||
Ok(Expression::Width(Range::Eq(try!(specified::Length::parse_non_negative(input)))))
|
||||
},
|
||||
_ => Err(())
|
||||
}
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue