Auto merge of #14789 - Manishearth:supports, r=SimonSapin

Support @supports

fixes #14786

cc @heycam @upsuper
r? @SimonSapin

<!-- 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/14789)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2017-01-09 10:54:38 -08:00 committed by GitHub
commit 50bba770d6
98 changed files with 638 additions and 218 deletions

View file

@ -39,6 +39,25 @@ macro_rules! assert_roundtrip_with_context {
}
}
macro_rules! assert_roundtrip {
($fun:expr, $string:expr) => {
assert_roundtrip!($fun, $string, $string);
};
($fun:expr,$input:expr, $output:expr) => {
let mut parser = Parser::new($input);
let parsed = $fun(&mut parser)
.expect(&format!("Failed to parse {}", $input));
let serialized = ToCss::to_css_string(&parsed);
assert_eq!(serialized, $output);
let mut parser = Parser::new(&serialized);
let re_parsed = $fun(&mut parser)
.expect(&format!("Failed to parse serialization {}", $input));
let re_serialized = ToCss::to_css_string(&re_parsed);
assert_eq!(serialized, re_serialized);
}
}
macro_rules! parse_longhand {
($name:ident, $s:expr) => {{
let url = ::servo_url::ServoUrl::parse("http://localhost").unwrap();
@ -58,3 +77,4 @@ mod inherited_text;
mod mask;
mod position;
mod selectors;
mod supports;

View file

@ -0,0 +1,14 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use cssparser::Parser;
use style::supports::SupportsCondition;
use style_traits::ToCss;
#[test]
fn test_supports_condition() {
assert_roundtrip!(SupportsCondition::parse, "(margin: 1px)");
assert_roundtrip!(SupportsCondition::parse, "not (--be: to be)");
assert_roundtrip!(SupportsCondition::parse, "(color: blue) and future-extension(4)");
}