Auto merge of #14232 - servo:moar-locks, r=upsuper

CSSOM: Make Stylesheet fields have their own synchronization

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

r? @upsuper

---
<!-- 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 bug 1314208.

<!-- Either: -->
- [ ] 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/14232)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2016-11-21 19:33:57 -06:00 committed by GitHub
commit 30867001d1
12 changed files with 56 additions and 56 deletions

View file

@ -370,12 +370,10 @@ impl FetchResponseListener for StylesheetContext {
let win = window_from_node(&*elem);
let mut sheet = Stylesheet::from_bytes(&data, final_url, protocol_encoding_label,
Some(environment_encoding), Origin::Author,
win.css_error_reporter(),
ParserContextExtraData::default());
sheet.set_media(self.media.take().unwrap());
let sheet = Arc::new(sheet);
let sheet = Arc::new(Stylesheet::from_bytes(
&data, final_url, protocol_encoding_label, Some(environment_encoding),
Origin::Author, self.media.take().unwrap(), win.css_error_reporter(),
ParserContextExtraData::default()));
let win = window_from_node(&*elem);
win.layout_chan().send(Msg::AddStylesheet(sheet.clone())).unwrap();

View file

@ -21,6 +21,7 @@ use html5ever_atoms::LocalName;
use parking_lot::RwLock;
use std::ascii::AsciiExt;
use std::sync::Arc;
use std::sync::atomic::AtomicBool;
use style::attr::AttrValue;
use style::str::HTML_SPACE_CHARACTERS;
use style::stylesheets::{Stylesheet, CssRule, Origin};
@ -101,7 +102,7 @@ impl HTMLMetaElement {
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,
dirty_on_viewport_size_change: AtomicBool::new(false),
}));
let doc = document_from_node(self);
doc.invalidate_stylesheets();

View file

@ -65,10 +65,9 @@ impl HTMLStyleElement {
};
let data = node.GetTextContent().expect("Element.textContent must be a string");
let mut sheet = Stylesheet::from_str(&data, url, Origin::Author, win.css_error_reporter(),
ParserContextExtraData::default());
let mut css_parser = CssParser::new(&mq_str);
sheet.set_media(parse_media_query_list(&mut css_parser));
let mq = parse_media_query_list(&mut CssParser::new(&mq_str));
let sheet = Stylesheet::from_str(&data, url, Origin::Author, mq, win.css_error_reporter(),
ParserContextExtraData::default());
let sheet = Arc::new(sheet);
win.layout_chan().send(Msg::AddStylesheet(sheet.clone())).unwrap();