Wrap most CSS rules in Locked<_> instead of RwLock<_>

This commit is contained in:
Simon Sapin 2017-03-17 16:46:22 +01:00
parent f35b4e27b3
commit adb97d4cbe
17 changed files with 194 additions and 139 deletions

View file

@ -10,21 +10,20 @@ use dom::cssrule::{CSSRule, SpecificCSSRule};
use dom::cssstylesheet::CSSStyleSheet;
use dom::window::Window;
use dom_struct::dom_struct;
use parking_lot::RwLock;
use std::sync::Arc;
use style::shared_lock::ToCssWithGuard;
use style::shared_lock::{Locked, ToCssWithGuard};
use style::stylesheets::ImportRule;
#[dom_struct]
pub struct CSSImportRule {
cssrule: CSSRule,
#[ignore_heap_size_of = "Arc"]
import_rule: Arc<RwLock<ImportRule>>,
import_rule: Arc<Locked<ImportRule>>,
}
impl CSSImportRule {
fn new_inherited(parent_stylesheet: &CSSStyleSheet,
import_rule: Arc<RwLock<ImportRule>>)
import_rule: Arc<Locked<ImportRule>>)
-> Self {
CSSImportRule {
cssrule: CSSRule::new_inherited(parent_stylesheet),
@ -35,7 +34,7 @@ impl CSSImportRule {
#[allow(unrooted_must_root)]
pub fn new(window: &Window,
parent_stylesheet: &CSSStyleSheet,
import_rule: Arc<RwLock<ImportRule>>) -> Root<Self> {
import_rule: Arc<Locked<ImportRule>>) -> Root<Self> {
reflect_dom_object(box Self::new_inherited(parent_stylesheet, import_rule),
window,
CSSImportRuleBinding::Wrap)
@ -50,6 +49,6 @@ impl SpecificCSSRule for CSSImportRule {
fn get_css(&self) -> DOMString {
let guard = self.cssrule.shared_lock().read();
self.import_rule.read().to_css_string(&guard).into()
self.import_rule.read_with(&guard).to_css_string(&guard).into()
}
}