mirror of
https://github.com/servo/servo.git
synced 2025-08-05 21:50:18 +01:00
Introduce a ToCssWithGuard trait
This commit is contained in:
parent
3ae2ecbec2
commit
fe4e70c5f8
16 changed files with 104 additions and 54 deletions
|
@ -12,6 +12,7 @@ use dom::csssupportsrule::CSSSupportsRule;
|
|||
use dom_struct::dom_struct;
|
||||
use parking_lot::RwLock;
|
||||
use std::sync::Arc;
|
||||
use style::shared_lock::SharedRwLock;
|
||||
use style::stylesheets::CssRules as StyleCssRules;
|
||||
|
||||
#[dom_struct]
|
||||
|
@ -27,6 +28,9 @@ impl CSSConditionRule {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn shared_lock(&self) -> &SharedRwLock {
|
||||
self.cssgroupingrule.shared_lock()
|
||||
}
|
||||
}
|
||||
|
||||
impl CSSConditionRuleMethods for CSSConditionRule {
|
||||
|
|
|
@ -12,8 +12,8 @@ use dom::window::Window;
|
|||
use dom_struct::dom_struct;
|
||||
use parking_lot::RwLock;
|
||||
use std::sync::Arc;
|
||||
use style::shared_lock::ToCssWithGuard;
|
||||
use style::font_face::FontFaceRule;
|
||||
use style_traits::ToCss;
|
||||
|
||||
#[dom_struct]
|
||||
pub struct CSSFontFaceRule {
|
||||
|
@ -47,6 +47,7 @@ impl SpecificCSSRule for CSSFontFaceRule {
|
|||
}
|
||||
|
||||
fn get_css(&self) -> DOMString {
|
||||
self.fontfacerule.read().to_css_string().into()
|
||||
let guard = self.cssrule.shared_lock().read();
|
||||
self.fontfacerule.read().to_css_string(&guard).into()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@ use dom::cssstylesheet::CSSStyleSheet;
|
|||
use dom_struct::dom_struct;
|
||||
use parking_lot::RwLock;
|
||||
use std::sync::Arc;
|
||||
use style::shared_lock::SharedRwLock;
|
||||
use style::stylesheets::CssRules as StyleCssRules;
|
||||
|
||||
#[dom_struct]
|
||||
|
@ -40,6 +41,10 @@ impl CSSGroupingRule {
|
|||
parent_stylesheet,
|
||||
RulesSource::Rules(self.rules.clone())))
|
||||
}
|
||||
|
||||
pub fn shared_lock(&self) -> &SharedRwLock {
|
||||
self.cssrule.shared_lock()
|
||||
}
|
||||
}
|
||||
|
||||
impl CSSGroupingRuleMethods for CSSGroupingRule {
|
||||
|
|
|
@ -12,8 +12,8 @@ use dom::window::Window;
|
|||
use dom_struct::dom_struct;
|
||||
use parking_lot::RwLock;
|
||||
use std::sync::Arc;
|
||||
use style::shared_lock::ToCssWithGuard;
|
||||
use style::stylesheets::ImportRule;
|
||||
use style_traits::ToCss;
|
||||
|
||||
#[dom_struct]
|
||||
pub struct CSSImportRule {
|
||||
|
@ -49,6 +49,7 @@ impl SpecificCSSRule for CSSImportRule {
|
|||
}
|
||||
|
||||
fn get_css(&self) -> DOMString {
|
||||
self.import_rule.read().to_css_string().into()
|
||||
let guard = self.cssrule.shared_lock().read();
|
||||
self.import_rule.read().to_css_string(&guard).into()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,8 +21,8 @@ use servo_atoms::Atom;
|
|||
use std::sync::Arc;
|
||||
use style::keyframes::{Keyframe, KeyframeSelector};
|
||||
use style::parser::ParserContextExtraData;
|
||||
use style::shared_lock::ToCssWithGuard;
|
||||
use style::stylesheets::KeyframesRule;
|
||||
use style_traits::ToCss;
|
||||
|
||||
#[dom_struct]
|
||||
pub struct CSSKeyframesRule {
|
||||
|
@ -134,7 +134,8 @@ impl SpecificCSSRule for CSSKeyframesRule {
|
|||
}
|
||||
|
||||
fn get_css(&self) -> DOMString {
|
||||
self.keyframesrule.read().to_css_string().into()
|
||||
let guard = self.cssrule.shared_lock().read();
|
||||
self.keyframesrule.read().to_css_string(&guard).into()
|
||||
}
|
||||
|
||||
fn deparent_children(&self) {
|
||||
|
|
|
@ -17,12 +17,13 @@ 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::stylesheets::MediaRule;
|
||||
use style_traits::ToCss;
|
||||
|
||||
#[dom_struct]
|
||||
pub struct CSSMediaRule {
|
||||
cssrule: CSSConditionRule,
|
||||
cssconditionrule: CSSConditionRule,
|
||||
#[ignore_heap_size_of = "Arc"]
|
||||
mediarule: Arc<RwLock<MediaRule>>,
|
||||
medialist: MutNullableJS<MediaList>,
|
||||
|
@ -33,7 +34,7 @@ impl CSSMediaRule {
|
|||
-> CSSMediaRule {
|
||||
let list = mediarule.read().rules.clone();
|
||||
CSSMediaRule {
|
||||
cssrule: CSSConditionRule::new_inherited(parent_stylesheet, list),
|
||||
cssconditionrule: CSSConditionRule::new_inherited(parent_stylesheet, list),
|
||||
mediarule: mediarule,
|
||||
medialist: MutNullableJS::new(None),
|
||||
}
|
||||
|
@ -76,7 +77,8 @@ impl SpecificCSSRule for CSSMediaRule {
|
|||
}
|
||||
|
||||
fn get_css(&self) -> DOMString {
|
||||
self.mediarule.read().to_css_string().into()
|
||||
let guard = self.cssconditionrule.shared_lock().read();
|
||||
self.mediarule.read().to_css_string(&guard).into()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -13,8 +13,8 @@ use dom::window::Window;
|
|||
use dom_struct::dom_struct;
|
||||
use parking_lot::RwLock;
|
||||
use std::sync::Arc;
|
||||
use style::shared_lock::ToCssWithGuard;
|
||||
use style::stylesheets::NamespaceRule;
|
||||
use style_traits::ToCss;
|
||||
|
||||
#[dom_struct]
|
||||
pub struct CSSNamespaceRule {
|
||||
|
@ -62,6 +62,7 @@ impl SpecificCSSRule for CSSNamespaceRule {
|
|||
}
|
||||
|
||||
fn get_css(&self) -> DOMString {
|
||||
self.namespacerule.read().to_css_string().into()
|
||||
let guard = self.cssrule.shared_lock().read();
|
||||
self.namespacerule.read().to_css_string(&guard).into()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,6 +20,7 @@ use dom::cssviewportrule::CSSViewportRule;
|
|||
use dom::window::Window;
|
||||
use dom_struct::dom_struct;
|
||||
use std::cell::Cell;
|
||||
use style::shared_lock::SharedRwLock;
|
||||
use style::stylesheets::CssRule as StyleCssRule;
|
||||
|
||||
|
||||
|
@ -103,6 +104,10 @@ impl CSSRule {
|
|||
pub fn parent_stylesheet(&self) -> &CSSStyleSheet {
|
||||
&self.parent_stylesheet
|
||||
}
|
||||
|
||||
pub fn shared_lock(&self) -> &SharedRwLock {
|
||||
&self.parent_stylesheet.style_stylesheet().shared_lock
|
||||
}
|
||||
}
|
||||
|
||||
impl CSSRuleMethods for CSSRule {
|
||||
|
|
|
@ -14,8 +14,8 @@ use dom::window::Window;
|
|||
use dom_struct::dom_struct;
|
||||
use parking_lot::RwLock;
|
||||
use std::sync::Arc;
|
||||
use style::shared_lock::ToCssWithGuard;
|
||||
use style::stylesheets::StyleRule;
|
||||
use style_traits::ToCss;
|
||||
|
||||
#[dom_struct]
|
||||
pub struct CSSStyleRule {
|
||||
|
@ -51,7 +51,8 @@ impl SpecificCSSRule for CSSStyleRule {
|
|||
}
|
||||
|
||||
fn get_css(&self) -> DOMString {
|
||||
self.stylerule.read().to_css_string().into()
|
||||
let guard = self.cssrule.shared_lock().read();
|
||||
self.stylerule.read().to_css_string(&guard).into()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -16,13 +16,14 @@ use dom_struct::dom_struct;
|
|||
use parking_lot::RwLock;
|
||||
use std::sync::Arc;
|
||||
use style::parser::ParserContext;
|
||||
use style::shared_lock::ToCssWithGuard;
|
||||
use style::stylesheets::SupportsRule;
|
||||
use style::supports::SupportsCondition;
|
||||
use style_traits::ToCss;
|
||||
|
||||
#[dom_struct]
|
||||
pub struct CSSSupportsRule {
|
||||
cssrule: CSSConditionRule,
|
||||
cssconditionrule: CSSConditionRule,
|
||||
#[ignore_heap_size_of = "Arc"]
|
||||
supportsrule: Arc<RwLock<SupportsRule>>,
|
||||
}
|
||||
|
@ -32,7 +33,7 @@ impl CSSSupportsRule {
|
|||
-> CSSSupportsRule {
|
||||
let list = supportsrule.read().rules.clone();
|
||||
CSSSupportsRule {
|
||||
cssrule: CSSConditionRule::new_inherited(parent_stylesheet, list),
|
||||
cssconditionrule: CSSConditionRule::new_inherited(parent_stylesheet, list),
|
||||
supportsrule: supportsrule,
|
||||
}
|
||||
}
|
||||
|
@ -75,6 +76,7 @@ impl SpecificCSSRule for CSSSupportsRule {
|
|||
}
|
||||
|
||||
fn get_css(&self) -> DOMString {
|
||||
self.supportsrule.read().to_css_string().into()
|
||||
let guard = self.cssconditionrule.shared_lock().read();
|
||||
self.supportsrule.read().to_css_string(&guard).into()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,8 +12,8 @@ use dom::window::Window;
|
|||
use dom_struct::dom_struct;
|
||||
use parking_lot::RwLock;
|
||||
use std::sync::Arc;
|
||||
use style::shared_lock::ToCssWithGuard;
|
||||
use style::viewport::ViewportRule;
|
||||
use style_traits::ToCss;
|
||||
|
||||
#[dom_struct]
|
||||
pub struct CSSViewportRule {
|
||||
|
@ -46,6 +46,7 @@ impl SpecificCSSRule for CSSViewportRule {
|
|||
}
|
||||
|
||||
fn get_css(&self) -> DOMString {
|
||||
self.viewportrule.read().to_css_string().into()
|
||||
let guard = self.cssrule.shared_lock().read();
|
||||
self.viewportrule.read().to_css_string(&guard).into()
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue