Auto merge of #17813 - upsuper:supports-decl, r=SimonSapin

Store raw string for prop decl in @supports

This fixes the serialization issue of `@supports` rule that whitespaces are not preserved like in other browsers.

It makes the work a bit redundant (the property name and colon is parsed twice), but I suppose this isn't a big deal.

<!-- 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/17813)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2017-07-21 09:01:57 -07:00 committed by GitHub
commit d1ac8b26e9
2 changed files with 26 additions and 31 deletions

View file

@ -30,7 +30,11 @@ impl CSS {
/// https://drafts.csswg.org/css-conditional/#dom-css-supports
pub fn Supports(win: &Window, property: DOMString, value: DOMString) -> bool {
let decl = Declaration { prop: property.into(), val: value.into() };
let mut decl = String::new();
serialize_identifier(&property, &mut decl).unwrap();
decl.push_str(": ");
decl.push_str(&value);
let decl = Declaration(decl);
let url = win.Document().url();
let context = ParserContext::new_for_cssom(&url, win.css_error_reporter(), Some(CssRuleType::Supports),
PARSING_MODE_DEFAULT,