diff options
Diffstat (limited to 'components/script/dom')
-rw-r--r-- | components/script/dom/bindings/trace.rs | 14 | ||||
-rw-r--r-- | components/script/dom/cssfontfacerule.rs | 11 | ||||
-rw-r--r-- | components/script/dom/cssimportrule.rs | 11 | ||||
-rw-r--r-- | components/script/dom/csskeyframesrule.rs | 23 | ||||
-rw-r--r-- | components/script/dom/cssmediarule.rs | 39 | ||||
-rw-r--r-- | components/script/dom/cssnamespacerule.rs | 17 | ||||
-rw-r--r-- | components/script/dom/cssrulelist.rs | 15 | ||||
-rw-r--r-- | components/script/dom/csssupportsrule.rs | 20 | ||||
-rw-r--r-- | components/script/dom/cssviewportrule.rs | 11 | ||||
-rw-r--r-- | components/script/dom/htmlmetaelement.rs | 3 |
10 files changed, 87 insertions, 77 deletions
diff --git a/components/script/dom/bindings/trace.rs b/components/script/dom/bindings/trace.rs index 122823f6f0d..efa1a5646f2 100644 --- a/components/script/dom/bindings/trace.rs +++ b/components/script/dom/bindings/trace.rs @@ -502,7 +502,7 @@ unsafe impl JSTraceable for Mutex<Option<SharedRt>> { } } -unsafe impl JSTraceable for RwLock<FontFaceRule> { +unsafe impl JSTraceable for StyleLocked<FontFaceRule> { unsafe fn trace(&self, _trc: *mut JSTracer) { // Do nothing. } @@ -520,31 +520,31 @@ unsafe impl JSTraceable for RwLock<Keyframe> { } } -unsafe impl JSTraceable for RwLock<KeyframesRule> { +unsafe impl JSTraceable for StyleLocked<KeyframesRule> { unsafe fn trace(&self, _trc: *mut JSTracer) { // Do nothing. } } -unsafe impl JSTraceable for RwLock<ImportRule> { +unsafe impl JSTraceable for StyleLocked<ImportRule> { unsafe fn trace(&self, _trc: *mut JSTracer) { // Do nothing. } } -unsafe impl JSTraceable for RwLock<SupportsRule> { +unsafe impl JSTraceable for StyleLocked<SupportsRule> { unsafe fn trace(&self, _trc: *mut JSTracer) { // Do nothing. } } -unsafe impl JSTraceable for RwLock<MediaRule> { +unsafe impl JSTraceable for StyleLocked<MediaRule> { unsafe fn trace(&self, _trc: *mut JSTracer) { // Do nothing. } } -unsafe impl JSTraceable for RwLock<NamespaceRule> { +unsafe impl JSTraceable for StyleLocked<NamespaceRule> { unsafe fn trace(&self, _trc: *mut JSTracer) { // Do nothing. } @@ -556,7 +556,7 @@ unsafe impl JSTraceable for RwLock<StyleRule> { } } -unsafe impl JSTraceable for RwLock<ViewportRule> { +unsafe impl JSTraceable for StyleLocked<ViewportRule> { unsafe fn trace(&self, _trc: *mut JSTracer) { // Do nothing. } diff --git a/components/script/dom/cssfontfacerule.rs b/components/script/dom/cssfontfacerule.rs index 05b665a9975..184f6784afa 100644 --- a/components/script/dom/cssfontfacerule.rs +++ b/components/script/dom/cssfontfacerule.rs @@ -10,20 +10,19 @@ 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::font_face::FontFaceRule; -use style::shared_lock::ToCssWithGuard; +use style::shared_lock::{Locked, ToCssWithGuard}; #[dom_struct] pub struct CSSFontFaceRule { cssrule: CSSRule, #[ignore_heap_size_of = "Arc"] - fontfacerule: Arc<RwLock<FontFaceRule>>, + fontfacerule: Arc<Locked<FontFaceRule>>, } impl CSSFontFaceRule { - fn new_inherited(parent_stylesheet: &CSSStyleSheet, fontfacerule: Arc<RwLock<FontFaceRule>>) + fn new_inherited(parent_stylesheet: &CSSStyleSheet, fontfacerule: Arc<Locked<FontFaceRule>>) -> CSSFontFaceRule { CSSFontFaceRule { cssrule: CSSRule::new_inherited(parent_stylesheet), @@ -33,7 +32,7 @@ impl CSSFontFaceRule { #[allow(unrooted_must_root)] pub fn new(window: &Window, parent_stylesheet: &CSSStyleSheet, - fontfacerule: Arc<RwLock<FontFaceRule>>) -> Root<CSSFontFaceRule> { + fontfacerule: Arc<Locked<FontFaceRule>>) -> Root<CSSFontFaceRule> { reflect_dom_object(box CSSFontFaceRule::new_inherited(parent_stylesheet, fontfacerule), window, CSSFontFaceRuleBinding::Wrap) @@ -48,6 +47,6 @@ impl SpecificCSSRule for CSSFontFaceRule { fn get_css(&self) -> DOMString { let guard = self.cssrule.shared_lock().read(); - self.fontfacerule.read().to_css_string(&guard).into() + self.fontfacerule.read_with(&guard).to_css_string(&guard).into() } } diff --git a/components/script/dom/cssimportrule.rs b/components/script/dom/cssimportrule.rs index bb01fdfcc84..3c0eb7eb4aa 100644 --- a/components/script/dom/cssimportrule.rs +++ b/components/script/dom/cssimportrule.rs @@ -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() } } diff --git a/components/script/dom/csskeyframesrule.rs b/components/script/dom/csskeyframesrule.rs index 330b1be3627..d17eeeb51b5 100644 --- a/components/script/dom/csskeyframesrule.rs +++ b/components/script/dom/csskeyframesrule.rs @@ -16,24 +16,23 @@ use dom::cssrulelist::{CSSRuleList, RulesSource}; use dom::cssstylesheet::CSSStyleSheet; use dom::window::Window; use dom_struct::dom_struct; -use parking_lot::RwLock; use servo_atoms::Atom; use std::sync::Arc; use style::keyframes::{Keyframe, KeyframeSelector}; use style::parser::ParserContextExtraData; -use style::shared_lock::ToCssWithGuard; +use style::shared_lock::{Locked, ToCssWithGuard}; use style::stylesheets::KeyframesRule; #[dom_struct] pub struct CSSKeyframesRule { cssrule: CSSRule, #[ignore_heap_size_of = "Arc"] - keyframesrule: Arc<RwLock<KeyframesRule>>, + keyframesrule: Arc<Locked<KeyframesRule>>, rulelist: MutNullableJS<CSSRuleList>, } impl CSSKeyframesRule { - fn new_inherited(parent_stylesheet: &CSSStyleSheet, keyframesrule: Arc<RwLock<KeyframesRule>>) + fn new_inherited(parent_stylesheet: &CSSStyleSheet, keyframesrule: Arc<Locked<KeyframesRule>>) -> CSSKeyframesRule { CSSKeyframesRule { cssrule: CSSRule::new_inherited(parent_stylesheet), @@ -44,7 +43,7 @@ impl CSSKeyframesRule { #[allow(unrooted_must_root)] pub fn new(window: &Window, parent_stylesheet: &CSSStyleSheet, - keyframesrule: Arc<RwLock<KeyframesRule>>) -> Root<CSSKeyframesRule> { + keyframesrule: Arc<Locked<KeyframesRule>>) -> Root<CSSKeyframesRule> { reflect_dom_object(box CSSKeyframesRule::new_inherited(parent_stylesheet, keyframesrule), window, CSSKeyframesRuleBinding::Wrap) @@ -63,9 +62,10 @@ impl CSSKeyframesRule { fn find_rule(&self, selector: &str) -> Option<usize> { let mut input = Parser::new(selector); if let Ok(sel) = KeyframeSelector::parse(&mut input) { + let guard = self.cssrule.shared_lock().read(); // This finds the *last* element matching a selector // because that's the rule that applies. Thus, rposition - self.keyframesrule.read() + self.keyframesrule.read_with(&guard) .keyframes.iter().rposition(|frame| { frame.read().selector == sel }) @@ -86,7 +86,8 @@ impl CSSKeyframesRuleMethods for CSSKeyframesRule { let rule = Keyframe::parse(&rule, self.cssrule.parent_stylesheet().style_stylesheet(), ParserContextExtraData::default()); if let Ok(rule) = rule { - self.keyframesrule.write().keyframes.push(rule); + let mut guard = self.cssrule.shared_lock().write(); + self.keyframesrule.write_with(&mut guard).keyframes.push(rule); self.rulelist().append_lazy_dom_rule(); } } @@ -107,7 +108,8 @@ impl CSSKeyframesRuleMethods for CSSKeyframesRule { // https://drafts.csswg.org/css-animations/#dom-csskeyframesrule-name fn Name(&self) -> DOMString { - DOMString::from(&*self.keyframesrule.read().name) + let guard = self.cssrule.shared_lock().read(); + DOMString::from(&*self.keyframesrule.read_with(&guard).name) } // https://drafts.csswg.org/css-animations/#dom-csskeyframesrule-name @@ -122,7 +124,8 @@ impl CSSKeyframesRuleMethods for CSSKeyframesRule { "none" => return Err(Error::Syntax), _ => () } - self.keyframesrule.write().name = Atom::from(value); + let mut guard = self.cssrule.shared_lock().write(); + self.keyframesrule.write_with(&mut guard).name = Atom::from(value); Ok(()) } } @@ -135,7 +138,7 @@ impl SpecificCSSRule for CSSKeyframesRule { fn get_css(&self) -> DOMString { let guard = self.cssrule.shared_lock().read(); - self.keyframesrule.read().to_css_string(&guard).into() + self.keyframesrule.read_with(&guard).to_css_string(&guard).into() } fn deparent_children(&self) { diff --git a/components/script/dom/cssmediarule.rs b/components/script/dom/cssmediarule.rs index 1d1f0846a51..2a07471679e 100644 --- a/components/script/dom/cssmediarule.rs +++ b/components/script/dom/cssmediarule.rs @@ -14,10 +14,9 @@ use dom::cssstylesheet::CSSStyleSheet; use dom::medialist::MediaList; use dom::window::Window; use dom_struct::dom_struct; -use parking_lot::RwLock; use std::sync::Arc; use style::media_queries::parse_media_query_list; -use style::shared_lock::ToCssWithGuard; +use style::shared_lock::{Locked, ToCssWithGuard}; use style::stylesheets::MediaRule; use style_traits::ToCss; @@ -25,14 +24,15 @@ use style_traits::ToCss; pub struct CSSMediaRule { cssconditionrule: CSSConditionRule, #[ignore_heap_size_of = "Arc"] - mediarule: Arc<RwLock<MediaRule>>, + mediarule: Arc<Locked<MediaRule>>, medialist: MutNullableJS<MediaList>, } impl CSSMediaRule { - fn new_inherited(parent_stylesheet: &CSSStyleSheet, mediarule: Arc<RwLock<MediaRule>>) + fn new_inherited(parent_stylesheet: &CSSStyleSheet, mediarule: Arc<Locked<MediaRule>>) -> CSSMediaRule { - let list = mediarule.read().rules.clone(); + let guard = parent_stylesheet.shared_lock().read(); + let list = mediarule.read_with(&guard).rules.clone(); CSSMediaRule { cssconditionrule: CSSConditionRule::new_inherited(parent_stylesheet, list), mediarule: mediarule, @@ -42,34 +42,43 @@ impl CSSMediaRule { #[allow(unrooted_must_root)] pub fn new(window: &Window, parent_stylesheet: &CSSStyleSheet, - mediarule: Arc<RwLock<MediaRule>>) -> Root<CSSMediaRule> { + mediarule: Arc<Locked<MediaRule>>) -> Root<CSSMediaRule> { reflect_dom_object(box CSSMediaRule::new_inherited(parent_stylesheet, mediarule), window, CSSMediaRuleBinding::Wrap) } fn medialist(&self) -> Root<MediaList> { - self.medialist.or_init(|| MediaList::new(self.global().as_window(), - self.cssconditionrule.parent_stylesheet(), - self.mediarule.read().media_queries.clone())) + self.medialist.or_init(|| { + let guard = self.cssconditionrule.shared_lock().read(); + MediaList::new(self.global().as_window(), + self.cssconditionrule.parent_stylesheet(), + self.mediarule.read_with(&guard).media_queries.clone()) + }) } /// https://drafts.csswg.org/css-conditional-3/#the-cssmediarule-interface pub fn get_condition_text(&self) -> DOMString { let guard = self.cssconditionrule.shared_lock().read(); - let rule = self.mediarule.read(); + let rule = self.mediarule.read_with(&guard); let list = rule.media_queries.read_with(&guard); list.to_css_string().into() } /// https://drafts.csswg.org/css-conditional-3/#the-cssmediarule-interface pub fn set_condition_text(&self, text: DOMString) { - let mut guard = self.cssconditionrule.shared_lock().write(); let mut input = Parser::new(&text); let new_medialist = parse_media_query_list(&mut input); - let rule = self.mediarule.read(); - let mut list = rule.media_queries.write_with(&mut guard); - *list = new_medialist; + let mut guard = self.cssconditionrule.shared_lock().write(); + + // Clone an Arc because we can’t borrow `guard` twice at the same time. + + // FIXME(SimonSapin): allow access to multiple objects with one write guard? + // Would need a set of usize pointer addresses or something, + // the same object is not accessed more than once. + let mqs = Arc::clone(&self.mediarule.write_with(&mut guard).media_queries); + + *mqs.write_with(&mut guard) = new_medialist; } } @@ -81,7 +90,7 @@ impl SpecificCSSRule for CSSMediaRule { fn get_css(&self) -> DOMString { let guard = self.cssconditionrule.shared_lock().read(); - self.mediarule.read().to_css_string(&guard).into() + self.mediarule.read_with(&guard).to_css_string(&guard).into() } } diff --git a/components/script/dom/cssnamespacerule.rs b/components/script/dom/cssnamespacerule.rs index 46702c275ba..744a8020667 100644 --- a/components/script/dom/cssnamespacerule.rs +++ b/components/script/dom/cssnamespacerule.rs @@ -11,20 +11,19 @@ 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::NamespaceRule; #[dom_struct] pub struct CSSNamespaceRule { cssrule: CSSRule, #[ignore_heap_size_of = "Arc"] - namespacerule: Arc<RwLock<NamespaceRule>>, + namespacerule: Arc<Locked<NamespaceRule>>, } impl CSSNamespaceRule { - fn new_inherited(parent_stylesheet: &CSSStyleSheet, namespacerule: Arc<RwLock<NamespaceRule>>) + fn new_inherited(parent_stylesheet: &CSSStyleSheet, namespacerule: Arc<Locked<NamespaceRule>>) -> CSSNamespaceRule { CSSNamespaceRule { cssrule: CSSRule::new_inherited(parent_stylesheet), @@ -34,7 +33,7 @@ impl CSSNamespaceRule { #[allow(unrooted_must_root)] pub fn new(window: &Window, parent_stylesheet: &CSSStyleSheet, - namespacerule: Arc<RwLock<NamespaceRule>>) -> Root<CSSNamespaceRule> { + namespacerule: Arc<Locked<NamespaceRule>>) -> Root<CSSNamespaceRule> { reflect_dom_object(box CSSNamespaceRule::new_inherited(parent_stylesheet, namespacerule), window, CSSNamespaceRuleBinding::Wrap) @@ -44,14 +43,16 @@ impl CSSNamespaceRule { impl CSSNamespaceRuleMethods for CSSNamespaceRule { // https://drafts.csswg.org/cssom/#dom-cssnamespacerule-prefix fn Prefix(&self) -> DOMString { - self.namespacerule.read().prefix + let guard = self.cssrule.shared_lock().read(); + self.namespacerule.read_with(&guard).prefix .as_ref().map(|s| s.to_string().into()) .unwrap_or(DOMString::new()) } // https://drafts.csswg.org/cssom/#dom-cssnamespacerule-namespaceuri fn NamespaceURI(&self) -> DOMString { - (*self.namespacerule.read().url).into() + let guard = self.cssrule.shared_lock().read(); + (*self.namespacerule.read_with(&guard).url).into() } } @@ -63,6 +64,6 @@ impl SpecificCSSRule for CSSNamespaceRule { fn get_css(&self) -> DOMString { let guard = self.cssrule.shared_lock().read(); - self.namespacerule.read().to_css_string(&guard).into() + self.namespacerule.read_with(&guard).to_css_string(&guard).into() } } diff --git a/components/script/dom/cssrulelist.rs b/components/script/dom/cssrulelist.rs index 6321296c785..bc77361b5ae 100644 --- a/components/script/dom/cssrulelist.rs +++ b/components/script/dom/cssrulelist.rs @@ -13,7 +13,6 @@ use dom::cssrule::CSSRule; 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::Locked; use style::stylesheets::{CssRules, KeyframesRule, RulesMutateError}; @@ -45,19 +44,19 @@ pub struct CSSRuleList { pub enum RulesSource { Rules(Arc<Locked<CssRules>>), - Keyframes(Arc<RwLock<KeyframesRule>>), + Keyframes(Arc<Locked<KeyframesRule>>), } impl CSSRuleList { #[allow(unrooted_must_root)] pub fn new_inherited(parent_stylesheet: &CSSStyleSheet, rules: RulesSource) -> CSSRuleList { + let guard = parent_stylesheet.shared_lock().read(); let dom_rules = match rules { RulesSource::Rules(ref rules) => { - let guard = parent_stylesheet.shared_lock().read(); rules.read_with(&guard).0.iter().map(|_| MutNullableJS::new(None)).collect() } RulesSource::Keyframes(ref rules) => { - rules.read().keyframes.iter().map(|_| MutNullableJS::new(None)).collect() + rules.read_with(&guard).keyframes.iter().map(|_| MutNullableJS::new(None)).collect() } }; @@ -104,10 +103,10 @@ impl CSSRuleList { // In case of a keyframe rule, index must be valid. pub fn remove_rule(&self, index: u32) -> ErrorResult { let index = index as usize; + let mut guard = self.parent_stylesheet.shared_lock().write(); match self.rules { RulesSource::Rules(ref css_rules) => { - let mut guard = self.parent_stylesheet.shared_lock().write(); css_rules.write_with(&mut guard).remove_rule(index)?; let mut dom_rules = self.dom_rules.borrow_mut(); dom_rules[index].get().map(|r| r.detach()); @@ -119,7 +118,7 @@ impl CSSRuleList { let mut dom_rules = self.dom_rules.borrow_mut(); dom_rules[index].get().map(|r| r.detach()); dom_rules.remove(index); - kf.write().keyframes.remove(index); + kf.write_with(&mut guard).keyframes.remove(index); Ok(()) } } @@ -136,9 +135,9 @@ impl CSSRuleList { self.dom_rules.borrow().get(idx as usize).map(|rule| { rule.or_init(|| { let parent_stylesheet = &self.parent_stylesheet; + let guard = parent_stylesheet.shared_lock().read(); match self.rules { RulesSource::Rules(ref rules) => { - let guard = parent_stylesheet.shared_lock().read(); CSSRule::new_specific(self.global().as_window(), parent_stylesheet, rules.read_with(&guard).0[idx as usize].clone()) @@ -146,7 +145,7 @@ impl CSSRuleList { RulesSource::Keyframes(ref rules) => { Root::upcast(CSSKeyframeRule::new(self.global().as_window(), parent_stylesheet, - rules.read() + rules.read_with(&guard) .keyframes[idx as usize] .clone())) } diff --git a/components/script/dom/csssupportsrule.rs b/components/script/dom/csssupportsrule.rs index d5e844e52aa..7ba3a24d038 100644 --- a/components/script/dom/csssupportsrule.rs +++ b/components/script/dom/csssupportsrule.rs @@ -13,10 +13,9 @@ use dom::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::parser::ParserContext; -use style::shared_lock::ToCssWithGuard; +use style::shared_lock::{Locked, ToCssWithGuard}; use style::stylesheets::SupportsRule; use style::supports::SupportsCondition; use style_traits::ToCss; @@ -25,13 +24,14 @@ use style_traits::ToCss; pub struct CSSSupportsRule { cssconditionrule: CSSConditionRule, #[ignore_heap_size_of = "Arc"] - supportsrule: Arc<RwLock<SupportsRule>>, + supportsrule: Arc<Locked<SupportsRule>>, } impl CSSSupportsRule { - fn new_inherited(parent_stylesheet: &CSSStyleSheet, supportsrule: Arc<RwLock<SupportsRule>>) + fn new_inherited(parent_stylesheet: &CSSStyleSheet, supportsrule: Arc<Locked<SupportsRule>>) -> CSSSupportsRule { - let list = supportsrule.read().rules.clone(); + let guard = parent_stylesheet.shared_lock().read(); + let list = supportsrule.read_with(&guard).rules.clone(); CSSSupportsRule { cssconditionrule: CSSConditionRule::new_inherited(parent_stylesheet, list), supportsrule: supportsrule, @@ -40,7 +40,7 @@ impl CSSSupportsRule { #[allow(unrooted_must_root)] pub fn new(window: &Window, parent_stylesheet: &CSSStyleSheet, - supportsrule: Arc<RwLock<SupportsRule>>) -> Root<CSSSupportsRule> { + supportsrule: Arc<Locked<SupportsRule>>) -> Root<CSSSupportsRule> { reflect_dom_object(box CSSSupportsRule::new_inherited(parent_stylesheet, supportsrule), window, CSSSupportsRuleBinding::Wrap) @@ -48,7 +48,8 @@ impl CSSSupportsRule { /// https://drafts.csswg.org/css-conditional-3/#the-csssupportsrule-interface pub fn get_condition_text(&self) -> DOMString { - let rule = self.supportsrule.read(); + let guard = self.cssconditionrule.shared_lock().read(); + let rule = self.supportsrule.read_with(&guard); rule.condition.to_css_string().into() } @@ -62,7 +63,8 @@ impl CSSSupportsRule { let url = win.Document().url(); let context = ParserContext::new_for_cssom(&url, win.css_error_reporter()); let enabled = cond.eval(&context); - let mut rule = self.supportsrule.write(); + let mut guard = self.cssconditionrule.shared_lock().write(); + let rule = self.supportsrule.write_with(&mut guard); rule.condition = cond; rule.enabled = enabled; } @@ -77,6 +79,6 @@ impl SpecificCSSRule for CSSSupportsRule { fn get_css(&self) -> DOMString { let guard = self.cssconditionrule.shared_lock().read(); - self.supportsrule.read().to_css_string(&guard).into() + self.supportsrule.read_with(&guard).to_css_string(&guard).into() } } diff --git a/components/script/dom/cssviewportrule.rs b/components/script/dom/cssviewportrule.rs index 855c8bdda57..38abf909ff0 100644 --- a/components/script/dom/cssviewportrule.rs +++ b/components/script/dom/cssviewportrule.rs @@ -10,20 +10,19 @@ 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::viewport::ViewportRule; #[dom_struct] pub struct CSSViewportRule { cssrule: CSSRule, #[ignore_heap_size_of = "Arc"] - viewportrule: Arc<RwLock<ViewportRule>>, + viewportrule: Arc<Locked<ViewportRule>>, } impl CSSViewportRule { - fn new_inherited(parent_stylesheet: &CSSStyleSheet, viewportrule: Arc<RwLock<ViewportRule>>) -> CSSViewportRule { + fn new_inherited(parent_stylesheet: &CSSStyleSheet, viewportrule: Arc<Locked<ViewportRule>>) -> CSSViewportRule { CSSViewportRule { cssrule: CSSRule::new_inherited(parent_stylesheet), viewportrule: viewportrule, @@ -32,7 +31,7 @@ impl CSSViewportRule { #[allow(unrooted_must_root)] pub fn new(window: &Window, parent_stylesheet: &CSSStyleSheet, - viewportrule: Arc<RwLock<ViewportRule>>) -> Root<CSSViewportRule> { + viewportrule: Arc<Locked<ViewportRule>>) -> Root<CSSViewportRule> { reflect_dom_object(box CSSViewportRule::new_inherited(parent_stylesheet, viewportrule), window, CSSViewportRuleBinding::Wrap) @@ -47,6 +46,6 @@ impl SpecificCSSRule for CSSViewportRule { fn get_css(&self) -> DOMString { let guard = self.cssrule.shared_lock().read(); - self.viewportrule.read().to_css_string(&guard).into() + self.viewportrule.read_with(&guard).to_css_string(&guard).into() } } diff --git a/components/script/dom/htmlmetaelement.rs b/components/script/dom/htmlmetaelement.rs index a564c6b2661..bc6f37561d8 100644 --- a/components/script/dom/htmlmetaelement.rs +++ b/components/script/dom/htmlmetaelement.rs @@ -19,7 +19,6 @@ use dom::node::{Node, UnbindContext, document_from_node, window_from_node}; use dom::virtualmethods::VirtualMethods; use dom_struct::dom_struct; use html5ever_atoms::LocalName; -use parking_lot::RwLock; use servo_config::prefs::PREFS; use std::ascii::AsciiExt; use std::sync::Arc; @@ -101,7 +100,7 @@ impl HTMLMetaElement { if let Some(translated_rule) = ViewportRule::from_meta(&**content) { let document = self.upcast::<Node>().owner_doc(); let shared_lock = document.style_shared_lock(); - let rule = CssRule::Viewport(Arc::new(RwLock::new(translated_rule))); + let rule = CssRule::Viewport(Arc::new(shared_lock.wrap(translated_rule))); *self.stylesheet.borrow_mut() = Some(Arc::new(Stylesheet { rules: CssRules::new(vec![rule], shared_lock), origin: Origin::Author, |