mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
Further changes required by Servo
This commit is contained in:
parent
6728158188
commit
68cbe6833d
4 changed files with 44 additions and 42 deletions
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
use dom_struct::dom_struct;
|
use dom_struct::dom_struct;
|
||||||
use servo_arc::Arc;
|
use servo_arc::Arc;
|
||||||
use style::shared_lock::{Locked, ToCssWithGuard};
|
use style::shared_lock::ToCssWithGuard;
|
||||||
use style::stylesheets::MediaRule;
|
use style::stylesheets::MediaRule;
|
||||||
use style_traits::ToCss;
|
use style_traits::ToCss;
|
||||||
|
|
||||||
|
@ -23,17 +23,13 @@ pub struct CSSMediaRule {
|
||||||
cssconditionrule: CSSConditionRule,
|
cssconditionrule: CSSConditionRule,
|
||||||
#[ignore_malloc_size_of = "Arc"]
|
#[ignore_malloc_size_of = "Arc"]
|
||||||
#[no_trace]
|
#[no_trace]
|
||||||
mediarule: Arc<Locked<MediaRule>>,
|
mediarule: Arc<MediaRule>,
|
||||||
medialist: MutNullableDom<MediaList>,
|
medialist: MutNullableDom<MediaList>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl CSSMediaRule {
|
impl CSSMediaRule {
|
||||||
fn new_inherited(
|
fn new_inherited(parent_stylesheet: &CSSStyleSheet, mediarule: Arc<MediaRule>) -> CSSMediaRule {
|
||||||
parent_stylesheet: &CSSStyleSheet,
|
let list = mediarule.rules.clone();
|
||||||
mediarule: Arc<Locked<MediaRule>>,
|
|
||||||
) -> CSSMediaRule {
|
|
||||||
let guard = parent_stylesheet.shared_lock().read();
|
|
||||||
let list = mediarule.read_with(&guard).rules.clone();
|
|
||||||
CSSMediaRule {
|
CSSMediaRule {
|
||||||
cssconditionrule: CSSConditionRule::new_inherited(parent_stylesheet, list),
|
cssconditionrule: CSSConditionRule::new_inherited(parent_stylesheet, list),
|
||||||
mediarule: mediarule,
|
mediarule: mediarule,
|
||||||
|
@ -45,7 +41,7 @@ impl CSSMediaRule {
|
||||||
pub fn new(
|
pub fn new(
|
||||||
window: &Window,
|
window: &Window,
|
||||||
parent_stylesheet: &CSSStyleSheet,
|
parent_stylesheet: &CSSStyleSheet,
|
||||||
mediarule: Arc<Locked<MediaRule>>,
|
mediarule: Arc<MediaRule>,
|
||||||
) -> DomRoot<CSSMediaRule> {
|
) -> DomRoot<CSSMediaRule> {
|
||||||
reflect_dom_object(
|
reflect_dom_object(
|
||||||
Box::new(CSSMediaRule::new_inherited(parent_stylesheet, mediarule)),
|
Box::new(CSSMediaRule::new_inherited(parent_stylesheet, mediarule)),
|
||||||
|
@ -55,11 +51,10 @@ impl CSSMediaRule {
|
||||||
|
|
||||||
fn medialist(&self) -> DomRoot<MediaList> {
|
fn medialist(&self) -> DomRoot<MediaList> {
|
||||||
self.medialist.or_init(|| {
|
self.medialist.or_init(|| {
|
||||||
let guard = self.cssconditionrule.shared_lock().read();
|
|
||||||
MediaList::new(
|
MediaList::new(
|
||||||
self.global().as_window(),
|
self.global().as_window(),
|
||||||
self.cssconditionrule.parent_stylesheet(),
|
self.cssconditionrule.parent_stylesheet(),
|
||||||
self.mediarule.read_with(&guard).media_queries.clone(),
|
self.mediarule.media_queries.clone(),
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -67,8 +62,7 @@ impl CSSMediaRule {
|
||||||
/// <https://drafts.csswg.org/css-conditional-3/#the-cssmediarule-interface>
|
/// <https://drafts.csswg.org/css-conditional-3/#the-cssmediarule-interface>
|
||||||
pub fn get_condition_text(&self) -> DOMString {
|
pub fn get_condition_text(&self) -> DOMString {
|
||||||
let guard = self.cssconditionrule.shared_lock().read();
|
let guard = self.cssconditionrule.shared_lock().read();
|
||||||
let rule = self.mediarule.read_with(&guard);
|
let list = self.mediarule.media_queries.read_with(&guard);
|
||||||
let list = rule.media_queries.read_with(&guard);
|
|
||||||
list.to_css_string().into()
|
list.to_css_string().into()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -81,10 +75,7 @@ impl SpecificCSSRule for CSSMediaRule {
|
||||||
|
|
||||||
fn get_css(&self) -> DOMString {
|
fn get_css(&self) -> DOMString {
|
||||||
let guard = self.cssconditionrule.shared_lock().read();
|
let guard = self.cssconditionrule.shared_lock().read();
|
||||||
self.mediarule
|
self.mediarule.to_css_string(&guard).into()
|
||||||
.read_with(&guard)
|
|
||||||
.to_css_string(&guard)
|
|
||||||
.into()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
use dom_struct::dom_struct;
|
use dom_struct::dom_struct;
|
||||||
use servo_arc::Arc;
|
use servo_arc::Arc;
|
||||||
use style::shared_lock::{Locked, ToCssWithGuard};
|
use style::shared_lock::ToCssWithGuard;
|
||||||
use style::stylesheets::NamespaceRule;
|
use style::stylesheets::NamespaceRule;
|
||||||
|
|
||||||
use crate::dom::bindings::codegen::Bindings::CSSNamespaceRuleBinding::CSSNamespaceRuleMethods;
|
use crate::dom::bindings::codegen::Bindings::CSSNamespaceRuleBinding::CSSNamespaceRuleMethods;
|
||||||
|
@ -20,13 +20,13 @@ pub struct CSSNamespaceRule {
|
||||||
cssrule: CSSRule,
|
cssrule: CSSRule,
|
||||||
#[ignore_malloc_size_of = "Arc"]
|
#[ignore_malloc_size_of = "Arc"]
|
||||||
#[no_trace]
|
#[no_trace]
|
||||||
namespacerule: Arc<Locked<NamespaceRule>>,
|
namespacerule: Arc<NamespaceRule>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl CSSNamespaceRule {
|
impl CSSNamespaceRule {
|
||||||
fn new_inherited(
|
fn new_inherited(
|
||||||
parent_stylesheet: &CSSStyleSheet,
|
parent_stylesheet: &CSSStyleSheet,
|
||||||
namespacerule: Arc<Locked<NamespaceRule>>,
|
namespacerule: Arc<NamespaceRule>,
|
||||||
) -> CSSNamespaceRule {
|
) -> CSSNamespaceRule {
|
||||||
CSSNamespaceRule {
|
CSSNamespaceRule {
|
||||||
cssrule: CSSRule::new_inherited(parent_stylesheet),
|
cssrule: CSSRule::new_inherited(parent_stylesheet),
|
||||||
|
@ -38,7 +38,7 @@ impl CSSNamespaceRule {
|
||||||
pub fn new(
|
pub fn new(
|
||||||
window: &Window,
|
window: &Window,
|
||||||
parent_stylesheet: &CSSStyleSheet,
|
parent_stylesheet: &CSSStyleSheet,
|
||||||
namespacerule: Arc<Locked<NamespaceRule>>,
|
namespacerule: Arc<NamespaceRule>,
|
||||||
) -> DomRoot<CSSNamespaceRule> {
|
) -> DomRoot<CSSNamespaceRule> {
|
||||||
reflect_dom_object(
|
reflect_dom_object(
|
||||||
Box::new(CSSNamespaceRule::new_inherited(
|
Box::new(CSSNamespaceRule::new_inherited(
|
||||||
|
@ -53,9 +53,7 @@ impl CSSNamespaceRule {
|
||||||
impl CSSNamespaceRuleMethods for CSSNamespaceRule {
|
impl CSSNamespaceRuleMethods for CSSNamespaceRule {
|
||||||
// https://drafts.csswg.org/cssom/#dom-cssnamespacerule-prefix
|
// https://drafts.csswg.org/cssom/#dom-cssnamespacerule-prefix
|
||||||
fn Prefix(&self) -> DOMString {
|
fn Prefix(&self) -> DOMString {
|
||||||
let guard = self.cssrule.shared_lock().read();
|
|
||||||
self.namespacerule
|
self.namespacerule
|
||||||
.read_with(&guard)
|
|
||||||
.prefix
|
.prefix
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.map(|s| s.to_string().into())
|
.map(|s| s.to_string().into())
|
||||||
|
@ -64,8 +62,7 @@ impl CSSNamespaceRuleMethods for CSSNamespaceRule {
|
||||||
|
|
||||||
// https://drafts.csswg.org/cssom/#dom-cssnamespacerule-namespaceuri
|
// https://drafts.csswg.org/cssom/#dom-cssnamespacerule-namespaceuri
|
||||||
fn NamespaceURI(&self) -> DOMString {
|
fn NamespaceURI(&self) -> DOMString {
|
||||||
let guard = self.cssrule.shared_lock().read();
|
(**self.namespacerule.url).into()
|
||||||
(**self.namespacerule.read_with(&guard).url).into()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -77,9 +74,6 @@ impl SpecificCSSRule for CSSNamespaceRule {
|
||||||
|
|
||||||
fn get_css(&self) -> DOMString {
|
fn get_css(&self) -> DOMString {
|
||||||
let guard = self.cssrule.shared_lock().read();
|
let guard = self.cssrule.shared_lock().read();
|
||||||
self.namespacerule
|
self.namespacerule.to_css_string(&guard).into()
|
||||||
.read_with(&guard)
|
|
||||||
.to_css_string(&guard)
|
|
||||||
.into()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
use dom_struct::dom_struct;
|
use dom_struct::dom_struct;
|
||||||
use servo_arc::Arc;
|
use servo_arc::Arc;
|
||||||
use style::shared_lock::{Locked, ToCssWithGuard};
|
use style::shared_lock::ToCssWithGuard;
|
||||||
use style::stylesheets::SupportsRule;
|
use style::stylesheets::SupportsRule;
|
||||||
use style_traits::ToCss;
|
use style_traits::ToCss;
|
||||||
|
|
||||||
|
@ -21,16 +21,15 @@ pub struct CSSSupportsRule {
|
||||||
cssconditionrule: CSSConditionRule,
|
cssconditionrule: CSSConditionRule,
|
||||||
#[ignore_malloc_size_of = "Arc"]
|
#[ignore_malloc_size_of = "Arc"]
|
||||||
#[no_trace]
|
#[no_trace]
|
||||||
supportsrule: Arc<Locked<SupportsRule>>,
|
supportsrule: Arc<SupportsRule>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl CSSSupportsRule {
|
impl CSSSupportsRule {
|
||||||
fn new_inherited(
|
fn new_inherited(
|
||||||
parent_stylesheet: &CSSStyleSheet,
|
parent_stylesheet: &CSSStyleSheet,
|
||||||
supportsrule: Arc<Locked<SupportsRule>>,
|
supportsrule: Arc<SupportsRule>,
|
||||||
) -> CSSSupportsRule {
|
) -> CSSSupportsRule {
|
||||||
let guard = parent_stylesheet.shared_lock().read();
|
let list = supportsrule.rules.clone();
|
||||||
let list = supportsrule.read_with(&guard).rules.clone();
|
|
||||||
CSSSupportsRule {
|
CSSSupportsRule {
|
||||||
cssconditionrule: CSSConditionRule::new_inherited(parent_stylesheet, list),
|
cssconditionrule: CSSConditionRule::new_inherited(parent_stylesheet, list),
|
||||||
supportsrule: supportsrule,
|
supportsrule: supportsrule,
|
||||||
|
@ -41,7 +40,7 @@ impl CSSSupportsRule {
|
||||||
pub fn new(
|
pub fn new(
|
||||||
window: &Window,
|
window: &Window,
|
||||||
parent_stylesheet: &CSSStyleSheet,
|
parent_stylesheet: &CSSStyleSheet,
|
||||||
supportsrule: Arc<Locked<SupportsRule>>,
|
supportsrule: Arc<SupportsRule>,
|
||||||
) -> DomRoot<CSSSupportsRule> {
|
) -> DomRoot<CSSSupportsRule> {
|
||||||
reflect_dom_object(
|
reflect_dom_object(
|
||||||
Box::new(CSSSupportsRule::new_inherited(
|
Box::new(CSSSupportsRule::new_inherited(
|
||||||
|
@ -54,9 +53,7 @@ impl CSSSupportsRule {
|
||||||
|
|
||||||
/// <https://drafts.csswg.org/css-conditional-3/#the-csssupportsrule-interface>
|
/// <https://drafts.csswg.org/css-conditional-3/#the-csssupportsrule-interface>
|
||||||
pub fn get_condition_text(&self) -> DOMString {
|
pub fn get_condition_text(&self) -> DOMString {
|
||||||
let guard = self.cssconditionrule.shared_lock().read();
|
self.supportsrule.condition.to_css_string().into()
|
||||||
let rule = self.supportsrule.read_with(&guard);
|
|
||||||
rule.condition.to_css_string().into()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -68,9 +65,6 @@ impl SpecificCSSRule for CSSSupportsRule {
|
||||||
|
|
||||||
fn get_css(&self) -> DOMString {
|
fn get_css(&self) -> DOMString {
|
||||||
let guard = self.cssconditionrule.shared_lock().read();
|
let guard = self.cssconditionrule.shared_lock().read();
|
||||||
self.supportsrule
|
self.supportsrule.to_css_string(&guard).into()
|
||||||
.read_with(&guard)
|
|
||||||
.to_css_string(&guard)
|
|
||||||
.into()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -209,6 +209,26 @@ pub struct Stylesheet {
|
||||||
}
|
}
|
||||||
|
|
||||||
macro_rules! rule_filter {
|
macro_rules! rule_filter {
|
||||||
|
($( $method: ident($variant:ident => $rule_type: ident), )+) => {
|
||||||
|
$(
|
||||||
|
#[allow(missing_docs)]
|
||||||
|
fn $method<F>(&self, device: &Device, guard: &SharedRwLockReadGuard, mut f: F)
|
||||||
|
where F: FnMut(&crate::stylesheets::$rule_type),
|
||||||
|
{
|
||||||
|
use crate::stylesheets::CssRule;
|
||||||
|
|
||||||
|
for rule in self.effective_rules(device, guard) {
|
||||||
|
if let CssRule::$variant(ref lock) = *rule {
|
||||||
|
let rule = lock.read_with(guard);
|
||||||
|
f(&rule)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)+
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
macro_rules! rule_filter_for_non_locked {
|
||||||
($( $method: ident($variant:ident => $rule_type: ident), )+) => {
|
($( $method: ident($variant:ident => $rule_type: ident), )+) => {
|
||||||
$(
|
$(
|
||||||
#[allow(missing_docs)]
|
#[allow(missing_docs)]
|
||||||
|
@ -283,6 +303,9 @@ pub trait StylesheetInDocument: ::std::fmt::Debug {
|
||||||
|
|
||||||
rule_filter! {
|
rule_filter! {
|
||||||
effective_font_face_rules(FontFace => FontFaceRule),
|
effective_font_face_rules(FontFace => FontFaceRule),
|
||||||
|
}
|
||||||
|
|
||||||
|
rule_filter_for_non_locked! {
|
||||||
effective_viewport_rules(Viewport => ViewportRule),
|
effective_viewport_rules(Viewport => ViewportRule),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue