Auto merge of #14159 - upsuper:media-query, r=Wafflespeanut

Allow empty media query list

<!-- Please describe your changes on the following line: -->

---
<!-- 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
- [ ] These changes fix #__ (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/14159)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2016-11-10 01:37:57 -06:00 committed by GitHub
commit c3dc50b7ac
9 changed files with 41 additions and 23 deletions

View file

@ -359,8 +359,7 @@ impl FetchResponseListener for StylesheetContext {
Some(environment_encoding), Origin::Author,
win.css_error_reporter(),
ParserContextExtraData::default());
let media = self.media.take().unwrap();
sheet.set_media(Some(media));
sheet.set_media(self.media.take().unwrap());
let sheet = Arc::new(sheet);
let win = window_from_node(&*elem);

View file

@ -83,7 +83,7 @@ impl HTMLMetaElement {
*self.stylesheet.borrow_mut() = Some(Arc::new(Stylesheet {
rules: vec![CSSRule::Viewport(Arc::new(RwLock::new(translated_rule)))],
origin: Origin::Author,
media: None,
media: Default::default(),
// Viewport constraints are always recomputed on resize; they don't need to
// force all styles to be recomputed.
dirty_on_viewport_size_change: false,

View file

@ -65,8 +65,7 @@ impl HTMLStyleElement {
let mut sheet = Stylesheet::from_str(&data, url, Origin::Author, win.css_error_reporter(),
ParserContextExtraData::default());
let mut css_parser = CssParser::new(&mq_str);
let media = parse_media_query_list(&mut css_parser);
sheet.set_media(Some(media));
sheet.set_media(parse_media_query_list(&mut css_parser));
let sheet = Arc::new(sheet);
win.layout_chan().send(Msg::AddStylesheet(sheet.clone())).unwrap();