mirror of
https://github.com/servo/servo.git
synced 2025-08-06 22:15:33 +01:00
More lock acquire in callers
This commit is contained in:
parent
d18b1280f2
commit
3ae2ecbec2
6 changed files with 45 additions and 25 deletions
|
@ -62,7 +62,7 @@ fn media_query_test(device: &Device, css: &str, expected_rule_count: usize) {
|
|||
None, &CSSErrorReporterTest,
|
||||
ParserContextExtraData::default());
|
||||
let mut rule_count = 0;
|
||||
ss.effective_style_rules(device, |_| rule_count += 1);
|
||||
ss.effective_style_rules(device, &ss.shared_lock.read(), |_| rule_count += 1);
|
||||
assert!(rule_count == expected_rule_count, css.to_owned());
|
||||
}
|
||||
|
||||
|
|
|
@ -20,12 +20,15 @@ use style_traits::viewport::*;
|
|||
|
||||
macro_rules! stylesheet {
|
||||
($css:expr, $origin:ident, $error_reporter:expr) => {
|
||||
stylesheet!($css, $origin, $error_reporter, SharedRwLock::new())
|
||||
};
|
||||
($css:expr, $origin:ident, $error_reporter:expr, $shared_lock:expr) => {
|
||||
Box::new(Stylesheet::from_str(
|
||||
$css,
|
||||
ServoUrl::parse("http://localhost").unwrap(),
|
||||
Origin::$origin,
|
||||
Default::default(),
|
||||
SharedRwLock::new(),
|
||||
$shared_lock,
|
||||
None,
|
||||
&$error_reporter,
|
||||
ParserContextExtraData::default()
|
||||
|
@ -41,7 +44,7 @@ fn test_viewport_rule<F>(css: &str,
|
|||
PREFS.set("layout.viewport.enabled", PrefValue::Boolean(true));
|
||||
let stylesheet = stylesheet!(css, Author, CSSErrorReporterTest);
|
||||
let mut rule_count = 0;
|
||||
stylesheet.effective_viewport_rules(&device, |rule| {
|
||||
stylesheet.effective_viewport_rules(&device, &stylesheet.shared_lock.read(), |rule| {
|
||||
rule_count += 1;
|
||||
callback(&rule.declarations, css);
|
||||
});
|
||||
|
@ -253,24 +256,31 @@ fn multiple_stylesheets_cascading() {
|
|||
PREFS.set("layout.viewport.enabled", PrefValue::Boolean(true));
|
||||
let device = Device::new(MediaType::Screen, TypedSize2D::new(800., 600.));
|
||||
let error_reporter = CSSErrorReporterTest;
|
||||
let shared_lock = SharedRwLock::new();
|
||||
let stylesheets = vec![
|
||||
stylesheet!("@viewport { min-width: 100px; min-height: 100px; zoom: 1; }", UserAgent, error_reporter),
|
||||
stylesheet!("@viewport { min-width: 200px; min-height: 200px; }", User, error_reporter),
|
||||
stylesheet!("@viewport { min-width: 300px; }", Author, error_reporter)];
|
||||
stylesheet!("@viewport { min-width: 100px; min-height: 100px; zoom: 1; }",
|
||||
UserAgent, error_reporter, shared_lock.clone()),
|
||||
stylesheet!("@viewport { min-width: 200px; min-height: 200px; }",
|
||||
User, error_reporter, shared_lock.clone()),
|
||||
stylesheet!("@viewport { min-width: 300px; }",
|
||||
Author, error_reporter, shared_lock.clone())
|
||||
];
|
||||
|
||||
let declarations = Cascade::from_stylesheets(&stylesheets, &device).finish();
|
||||
let declarations = Cascade::from_stylesheets(&stylesheets, &shared_lock.read(), &device).finish();
|
||||
assert_decl_len!(declarations == 3);
|
||||
assert_decl_eq!(&declarations[0], UserAgent, Zoom: Zoom::Number(1.));
|
||||
assert_decl_eq!(&declarations[1], User, MinHeight: viewport_length!(200., px));
|
||||
assert_decl_eq!(&declarations[2], Author, MinWidth: viewport_length!(300., px));
|
||||
|
||||
let stylesheets = vec![
|
||||
stylesheet!("@viewport { min-width: 100px !important; }", UserAgent, error_reporter),
|
||||
stylesheet!("@viewport { min-width: 100px !important; }",
|
||||
UserAgent, error_reporter, shared_lock.clone()),
|
||||
stylesheet!("@viewport { min-width: 200px !important; min-height: 200px !important; }",
|
||||
User, error_reporter),
|
||||
User, error_reporter, shared_lock.clone()),
|
||||
stylesheet!("@viewport { min-width: 300px !important; min-height: 300px !important; zoom: 3 !important; }",
|
||||
Author, error_reporter)];
|
||||
let declarations = Cascade::from_stylesheets(&stylesheets, &device).finish();
|
||||
Author, error_reporter, shared_lock.clone())
|
||||
];
|
||||
let declarations = Cascade::from_stylesheets(&stylesheets, &shared_lock.read(), &device).finish();
|
||||
assert_decl_len!(declarations == 3);
|
||||
assert_decl_eq!(&declarations[0], UserAgent, MinWidth: viewport_length!(100., px), !important);
|
||||
assert_decl_eq!(&declarations[1], User, MinHeight: viewport_length!(200., px), !important);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue