Fix another deadlock

This commit is contained in:
Simon Sapin 2017-03-18 15:41:50 +01:00
parent d9491187dc
commit 2952ccfae2

View file

@ -90,9 +90,12 @@ impl CSSRuleList {
let index = idx as usize; let index = idx as usize;
let parent_stylesheet = self.parent_stylesheet.style_stylesheet(); let parent_stylesheet = self.parent_stylesheet.style_stylesheet();
let mut guard = parent_stylesheet.shared_lock.write(); let new_rule = {
let new_rule = css_rules.write_with(&mut guard) let mut guard = parent_stylesheet.shared_lock.write();
.insert_rule(rule, parent_stylesheet, index, nested)?; css_rules.write_with(&mut guard).insert_rule(rule, parent_stylesheet, index, nested)?
// Drop `guard` here,
// CSSRule::new_specific re-acquires the lock for @support and @media.
};
let parent_stylesheet = &*self.parent_stylesheet; let parent_stylesheet = &*self.parent_stylesheet;
let dom_rule = CSSRule::new_specific(&window, parent_stylesheet, new_rule); let dom_rule = CSSRule::new_specific(&window, parent_stylesheet, new_rule);