diff options
Diffstat (limited to 'components/script/dom/htmllinkelement.rs')
-rw-r--r-- | components/script/dom/htmllinkelement.rs | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/components/script/dom/htmllinkelement.rs b/components/script/dom/htmllinkelement.rs index 36bafa58fb5..8dd50c11441 100644 --- a/components/script/dom/htmllinkelement.rs +++ b/components/script/dom/htmllinkelement.rs @@ -18,7 +18,10 @@ use crate::dom::element::{ }; use crate::dom::element::{AttributeMutation, Element, ElementCreator}; use crate::dom::htmlelement::HTMLElement; -use crate::dom::node::{document_from_node, window_from_node, Node, UnbindContext}; +use crate::dom::node::{ + document_from_node, stylesheets_owner_from_node, window_from_node, BindContext, Node, + UnbindContext, +}; use crate::dom::stylesheet::StyleSheet as DOMStyleSheet; use crate::dom::virtualmethods::VirtualMethods; use crate::stylesheet_loader::{StylesheetContextSource, StylesheetLoader, StylesheetOwner}; @@ -107,14 +110,15 @@ impl HTMLLinkElement { // FIXME(emilio): These methods are duplicated with // HTMLStyleElement::set_stylesheet. + #[allow(unrooted_must_root)] pub fn set_stylesheet(&self, s: Arc<Stylesheet>) { - let doc = document_from_node(self); + let stylesheets_owner = stylesheets_owner_from_node(self); if let Some(ref s) = *self.stylesheet.borrow() { - doc.remove_stylesheet(self.upcast(), s) + stylesheets_owner.remove_stylesheet(self.upcast(), s) } *self.stylesheet.borrow_mut() = Some(s.clone()); self.cssom_stylesheet.set(None); - doc.add_stylesheet(self.upcast(), s); + stylesheets_owner.add_stylesheet(self.upcast(), s); } pub fn get_stylesheet(&self) -> Option<Arc<Stylesheet>> { @@ -183,7 +187,7 @@ impl VirtualMethods for HTMLLinkElement { fn attribute_mutated(&self, attr: &Attr, mutation: AttributeMutation) { self.super_type().unwrap().attribute_mutated(attr, mutation); - if !self.upcast::<Node>().is_in_doc() || mutation.is_removal() { + if !self.upcast::<Node>().is_connected() || mutation.is_removal() { return; } @@ -222,12 +226,12 @@ impl VirtualMethods for HTMLLinkElement { } } - fn bind_to_tree(&self, tree_in_doc: bool) { + fn bind_to_tree(&self, context: &BindContext) { if let Some(ref s) = self.super_type() { - s.bind_to_tree(tree_in_doc); + s.bind_to_tree(context); } - if tree_in_doc { + if context.tree_connected { let element = self.upcast(); let rel = get_attr(element, &local_name!("rel")); @@ -252,7 +256,7 @@ impl VirtualMethods for HTMLLinkElement { } if let Some(s) = self.stylesheet.borrow_mut().take() { - document_from_node(self).remove_stylesheet(self.upcast(), &s); + stylesheets_owner_from_node(self).remove_stylesheet(self.upcast(), &s); } } } |