ShadowRoot stylesheet list

This commit is contained in:
Fernando Jiménez Moreno 2019-02-05 20:50:44 +01:00
parent 0d6bd24245
commit 3bb50cc479
8 changed files with 93 additions and 29 deletions

View file

@ -18,7 +18,9 @@ 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, Node, UnbindContext,
};
use crate::dom::stylesheet::StyleSheet as DOMStyleSheet;
use crate::dom::virtualmethods::VirtualMethods;
use crate::stylesheet_loader::{StylesheetContextSource, StylesheetLoader, StylesheetOwner};
@ -108,13 +110,13 @@ impl HTMLLinkElement {
// FIXME(emilio): These methods are duplicated with
// HTMLStyleElement::set_stylesheet.
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>> {
@ -252,7 +254,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);
}
}
}