aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/cssstylesheet.rs
diff options
context:
space:
mode:
authorVincent Ricard <magic@magicninja.org>2020-10-08 22:30:22 +0200
committerVincent Ricard <magic@magicninja.org>2020-10-10 21:21:00 +0200
commite7199c029f3ce276c77ce9680eb198fdfdb650d8 (patch)
tree5c819d27f614b6dd142af1efc4bbbb80c03052b1 /components/script/dom/cssstylesheet.rs
parent406d15974f3231dc769c2703e89b986ef9b20210 (diff)
downloadservo-e7199c029f3ce276c77ce9680eb198fdfdb650d8.tar.gz
servo-e7199c029f3ce276c77ce9680eb198fdfdb650d8.zip
Implements Stylesheet.ownerNode
Diffstat (limited to 'components/script/dom/cssstylesheet.rs')
-rw-r--r--components/script/dom/cssstylesheet.rs23
1 files changed, 12 insertions, 11 deletions
diff --git a/components/script/dom/cssstylesheet.rs b/components/script/dom/cssstylesheet.rs
index 35277ddc0fc..7ee5e444394 100644
--- a/components/script/dom/cssstylesheet.rs
+++ b/components/script/dom/cssstylesheet.rs
@@ -6,7 +6,7 @@ use crate::dom::bindings::codegen::Bindings::CSSStyleSheetBinding::CSSStyleSheet
use crate::dom::bindings::error::{Error, ErrorResult, Fallible};
use crate::dom::bindings::inheritance::Castable;
use crate::dom::bindings::reflector::{reflect_dom_object, DomObject};
-use crate::dom::bindings::root::{Dom, DomRoot, MutNullableDom};
+use crate::dom::bindings::root::{DomRoot, MutNullableDom};
use crate::dom::bindings::str::DOMString;
use crate::dom::cssrulelist::{CSSRuleList, RulesSource};
use crate::dom::element::Element;
@@ -22,7 +22,7 @@ use style::stylesheets::Stylesheet as StyleStyleSheet;
#[dom_struct]
pub struct CSSStyleSheet {
stylesheet: StyleSheet,
- owner: Dom<Element>,
+ owner: MutNullableDom<Element>,
rulelist: MutNullableDom<CSSRuleList>,
#[ignore_malloc_size_of = "Arc"]
style_stylesheet: Arc<StyleStyleSheet>,
@@ -39,7 +39,7 @@ impl CSSStyleSheet {
) -> CSSStyleSheet {
CSSStyleSheet {
stylesheet: StyleSheet::new_inherited(type_, href, title),
- owner: Dom::from_ref(owner),
+ owner: MutNullableDom::new(Some(owner)),
rulelist: MutNullableDom::new(None),
style_stylesheet: stylesheet,
origin_clean: Cell::new(true),
@@ -63,10 +63,6 @@ impl CSSStyleSheet {
)
}
- pub fn owner(&self) -> DomRoot<Element> {
- DomRoot::from_ref(&*self.owner)
- }
-
fn rulelist(&self) -> DomRoot<CSSRuleList> {
self.rulelist.or_init(|| {
let rules = self.style_stylesheet.contents.rules.clone();
@@ -78,16 +74,21 @@ impl CSSStyleSheet {
self.style_stylesheet.disabled()
}
- pub fn get_owner(&self) -> &Element {
- &*self.owner
+ pub fn get_owner(&self) -> Option<DomRoot<Element>> {
+ self.owner.get()
}
pub fn set_disabled(&self, disabled: bool) {
- if self.style_stylesheet.set_disabled(disabled) {
- stylesheets_owner_from_node(self.owner().upcast::<Node>()).invalidate_stylesheets();
+ if self.style_stylesheet.set_disabled(disabled) && self.get_owner().is_some() {
+ stylesheets_owner_from_node(self.get_owner().unwrap().upcast::<Node>())
+ .invalidate_stylesheets();
}
}
+ pub fn set_owner(&self, value: Option<&Element>) {
+ self.owner.set(value);
+ }
+
pub fn shared_lock(&self) -> &SharedRwLock {
&self.style_stylesheet.shared_lock
}