aboutsummaryrefslogtreecommitdiffstats
path: root/components/style
diff options
context:
space:
mode:
authorbors-servo <lbergstrom+bors@mozilla.com>2016-11-26 04:09:24 -0800
committerGitHub <noreply@github.com>2016-11-26 04:09:24 -0800
commitbcc76f8a58f2ebe3886d16ff3eebbe68e3debf6c (patch)
treedba660affaae953837d677e8a756e47c28764321 /components/style
parenta093b56c84cd66e4629c1e252134b523a49f751d (diff)
parent84e9277771704b5448102dfad9803374dce7f67a (diff)
downloadservo-bcc76f8a58f2ebe3886d16ff3eebbe68e3debf6c.tar.gz
servo-bcc76f8a58f2ebe3886d16ff3eebbe68e3debf6c.zip
Auto merge of #14192 - gterzian:support_equality_constraints, r=emilio
implement support for the width query <!-- Please describe your changes on the following line: --> implement support for the `width` media query --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes fix #https://github.com/servo/servo/issues/13670 (github issue number if applicable). <!-- Either: --> - [x] There are tests for these changes OR - [ ] These changes do not require tests because _____ <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/14192) <!-- Reviewable:end -->
Diffstat (limited to 'components/style')
-rw-r--r--components/style/media_queries.rs16
1 files changed, 10 insertions, 6 deletions
diff --git a/components/style/media_queries.rs b/components/style/media_queries.rs
index 569265b323f..522a252a05b 100644
--- a/components/style/media_queries.rs
+++ b/components/style/media_queries.rs
@@ -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(())
}
})