mirror of
https://github.com/servo/servo.git
synced 2025-08-12 08:55:32 +01:00
Allow mutation of CssRules
This commit is contained in:
parent
71a2b379c8
commit
2fe390e237
5 changed files with 11 additions and 10 deletions
|
@ -380,7 +380,7 @@ impl Stylist {
|
|||
return true
|
||||
}
|
||||
}
|
||||
mq_eval_changed(&rules, before, after)
|
||||
mq_eval_changed(rules, before, after)
|
||||
}) {
|
||||
return true
|
||||
}
|
||||
|
@ -388,7 +388,7 @@ impl Stylist {
|
|||
false
|
||||
}
|
||||
self.is_device_dirty |= stylesheets.iter().any(|stylesheet| {
|
||||
mq_eval_changed(&stylesheet.rules.0, &self.device, &device)
|
||||
mq_eval_changed(&stylesheet.rules.0.read(), &self.device, &device)
|
||||
});
|
||||
|
||||
self.device = device;
|
||||
|
|
|
@ -43,11 +43,11 @@ pub enum Origin {
|
|||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct CssRules(pub Arc<Vec<CssRule>>);
|
||||
pub struct CssRules(pub Arc<RwLock<Vec<CssRule>>>);
|
||||
|
||||
impl From<Vec<CssRule>> for CssRules {
|
||||
fn from(other: Vec<CssRule>) -> Self {
|
||||
CssRules(Arc::new(other))
|
||||
CssRules(Arc::new(RwLock::new(other)))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -100,7 +100,8 @@ impl CssRule {
|
|||
CssRule::Media(ref lock) => {
|
||||
let media_rule = lock.read();
|
||||
let mq = media_rule.media_queries.read();
|
||||
f(&media_rule.rules.0, Some(&mq))
|
||||
let rules = media_rule.rules.0.read();
|
||||
f(&rules, Some(&mq))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -254,7 +255,7 @@ impl Stylesheet {
|
|||
/// examined.
|
||||
#[inline]
|
||||
pub fn effective_rules<F>(&self, device: &Device, mut f: F) where F: FnMut(&CssRule) {
|
||||
effective_rules(&self.rules.0, device, &mut f);
|
||||
effective_rules(&self.rules.0.read(), device, &mut f);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue