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

@ -26,8 +26,9 @@ impl ParseErrorReporter for CSSErrorReporterTest {
fn test_media_rule<F>(css: &str, callback: F) where F: Fn(&MediaList, &str) {
let url = ServoUrl::parse("http://localhost").unwrap();
let stylesheet = Stylesheet::from_str(css, url, Origin::Author, Box::new(CSSErrorReporterTest),
ParserContextExtraData::default());
let stylesheet = Stylesheet::from_str(
css, url, Origin::Author, Default::default(),
Box::new(CSSErrorReporterTest), ParserContextExtraData::default());
let mut rule_count = 0;
media_queries(&stylesheet.rules.0.read(), &mut |mq| {
rule_count += 1;
@ -49,8 +50,9 @@ fn media_queries<F>(rules: &[CssRule], f: &mut F) where F: FnMut(&MediaList) {
fn media_query_test(device: &Device, css: &str, expected_rule_count: usize) {
let url = ServoUrl::parse("http://localhost").unwrap();
let ss = Stylesheet::from_str(css, url, Origin::Author, Box::new(CSSErrorReporterTest),
ParserContextExtraData::default());
let ss = Stylesheet::from_str(
css, url, Origin::Author, Default::default(),
Box::new(CSSErrorReporterTest), ParserContextExtraData::default());
let mut rule_count = 0;
ss.effective_style_rules(device, |_| rule_count += 1);
assert!(rule_count == expected_rule_count, css.to_owned());

View file

@ -12,6 +12,7 @@ use servo_url::ServoUrl;
use std::borrow::ToOwned;
use std::sync::Arc;
use std::sync::Mutex;
use std::sync::atomic::AtomicBool;
use style::error_reporting::ParseErrorReporter;
use style::keyframes::{Keyframe, KeyframeSelector, KeyframePercentage};
use style::parser::ParserContextExtraData;
@ -49,13 +50,13 @@ fn test_parse_stylesheet() {
}
}";
let url = ServoUrl::parse("about::test").unwrap();
let stylesheet = Stylesheet::from_str(css, url, Origin::UserAgent,
let stylesheet = Stylesheet::from_str(css, url, Origin::UserAgent, Default::default(),
Box::new(CSSErrorReporterTest),
ParserContextExtraData::default());
let expected = Stylesheet {
origin: Origin::UserAgent,
media: Default::default(),
dirty_on_viewport_size_change: false,
dirty_on_viewport_size_change: AtomicBool::new(false),
rules: vec![
CssRule::Namespace(Arc::new(RwLock::new(NamespaceRule {
prefix: None,
@ -320,7 +321,7 @@ fn test_report_error_stylesheet() {
let errors = error_reporter.errors.clone();
Stylesheet::from_str(css, url, Origin::UserAgent, error_reporter,
Stylesheet::from_str(css, url, Origin::UserAgent, Default::default(), error_reporter,
ParserContextExtraData::default());
let mut errors = errors.lock().unwrap();

View file

@ -23,6 +23,7 @@ macro_rules! stylesheet {
$css,
ServoUrl::parse("http://localhost").unwrap(),
Origin::$origin,
Default::default(),
$error_reporter,
ParserContextExtraData::default()
))