mirror of
https://github.com/servo/servo.git
synced 2025-06-20 07:08:59 +01:00
Replace RwLock<StyleRule> with Locked<StyleRule>
This commit is contained in:
parent
57724e5a37
commit
aeffca2a59
33 changed files with 279 additions and 334 deletions
|
@ -550,7 +550,7 @@ unsafe impl JSTraceable for StyleLocked<NamespaceRule> {
|
|||
}
|
||||
}
|
||||
|
||||
unsafe impl JSTraceable for RwLock<StyleRule> {
|
||||
unsafe impl JSTraceable for StyleLocked<StyleRule> {
|
||||
unsafe fn trace(&self, _trc: *mut JSTracer) {
|
||||
// Do nothing.
|
||||
}
|
||||
|
|
|
@ -12,21 +12,20 @@ use dom::cssstyledeclaration::{CSSModificationAccess, CSSStyleDeclaration, CSSSt
|
|||
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::StyleRule;
|
||||
|
||||
#[dom_struct]
|
||||
pub struct CSSStyleRule {
|
||||
cssrule: CSSRule,
|
||||
#[ignore_heap_size_of = "Arc"]
|
||||
stylerule: Arc<RwLock<StyleRule>>,
|
||||
stylerule: Arc<Locked<StyleRule>>,
|
||||
style_decl: MutNullableJS<CSSStyleDeclaration>,
|
||||
}
|
||||
|
||||
impl CSSStyleRule {
|
||||
fn new_inherited(parent_stylesheet: &CSSStyleSheet, stylerule: Arc<RwLock<StyleRule>>)
|
||||
fn new_inherited(parent_stylesheet: &CSSStyleSheet, stylerule: Arc<Locked<StyleRule>>)
|
||||
-> CSSStyleRule {
|
||||
CSSStyleRule {
|
||||
cssrule: CSSRule::new_inherited(parent_stylesheet),
|
||||
|
@ -37,7 +36,7 @@ impl CSSStyleRule {
|
|||
|
||||
#[allow(unrooted_must_root)]
|
||||
pub fn new(window: &Window, parent_stylesheet: &CSSStyleSheet,
|
||||
stylerule: Arc<RwLock<StyleRule>>) -> Root<CSSStyleRule> {
|
||||
stylerule: Arc<Locked<StyleRule>>) -> Root<CSSStyleRule> {
|
||||
reflect_dom_object(box CSSStyleRule::new_inherited(parent_stylesheet, stylerule),
|
||||
window,
|
||||
CSSStyleRuleBinding::Wrap)
|
||||
|
@ -52,7 +51,7 @@ impl SpecificCSSRule for CSSStyleRule {
|
|||
|
||||
fn get_css(&self) -> DOMString {
|
||||
let guard = self.cssrule.shared_lock().read();
|
||||
self.stylerule.read().to_css_string(&guard).into()
|
||||
self.stylerule.read_with(&guard).to_css_string(&guard).into()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -60,11 +59,16 @@ impl CSSStyleRuleMethods for CSSStyleRule {
|
|||
// https://drafts.csswg.org/cssom/#dom-cssstylerule-style
|
||||
fn Style(&self) -> Root<CSSStyleDeclaration> {
|
||||
self.style_decl.or_init(|| {
|
||||
CSSStyleDeclaration::new(self.global().as_window(),
|
||||
CSSStyleOwner::CSSRule(JS::from_ref(self.upcast()),
|
||||
self.stylerule.read().block.clone()),
|
||||
None,
|
||||
CSSModificationAccess::ReadWrite)
|
||||
let guard = self.cssrule.shared_lock().read();
|
||||
CSSStyleDeclaration::new(
|
||||
self.global().as_window(),
|
||||
CSSStyleOwner::CSSRule(
|
||||
JS::from_ref(self.upcast()),
|
||||
self.stylerule.read_with(&guard).block.clone()
|
||||
),
|
||||
None,
|
||||
CSSModificationAccess::ReadWrite
|
||||
)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
@ -134,6 +134,7 @@ use style::attr::AttrValue;
|
|||
use style::context::{QuirksMode, ReflowGoal};
|
||||
use style::restyle_hints::{RestyleHint, RESTYLE_STYLE_ATTRIBUTE};
|
||||
use style::selector_parser::{RestyleDamage, Snapshot};
|
||||
use style::servo::AUTHOR_SHARED_LOCK;
|
||||
use style::shared_lock::SharedRwLock as StyleSharedRwLock;
|
||||
use style::str::{HTML_SPACE_CHARACTERS, split_html_space_chars, str_join};
|
||||
use style::stylesheets::Stylesheet;
|
||||
|
@ -2131,7 +2132,7 @@ impl Document {
|
|||
scripts: Default::default(),
|
||||
anchors: Default::default(),
|
||||
applets: Default::default(),
|
||||
style_shared_lock: StyleSharedRwLock::new(),
|
||||
style_shared_lock: AUTHOR_SHARED_LOCK.clone(),
|
||||
stylesheets: DOMRefCell::new(None),
|
||||
stylesheets_changed_since_reflow: Cell::new(false),
|
||||
stylesheet_list: MutNullableJS::new(None),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue