diff options
Diffstat (limited to 'components/script/dom/htmlstyleelement.rs')
-rw-r--r-- | components/script/dom/htmlstyleelement.rs | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/components/script/dom/htmlstyleelement.rs b/components/script/dom/htmlstyleelement.rs index 8c1bc031dc0..577e290a3ea 100644 --- a/components/script/dom/htmlstyleelement.rs +++ b/components/script/dom/htmlstyleelement.rs @@ -7,8 +7,9 @@ use dom::bindings::cell::DOMRefCell; use dom::bindings::codegen::Bindings::HTMLStyleElementBinding; use dom::bindings::codegen::Bindings::NodeBinding::NodeMethods; use dom::bindings::inheritance::Castable; -use dom::bindings::js::Root; +use dom::bindings::js::{JS, MutNullableHeap, Root}; use dom::bindings::str::DOMString; +use dom::cssstylesheet::CSSStyleSheet; use dom::document::Document; use dom::element::Element; use dom::htmlelement::HTMLElement; @@ -26,6 +27,7 @@ pub struct HTMLStyleElement { htmlelement: HTMLElement, #[ignore_heap_size_of = "Arc"] stylesheet: DOMRefCell<Option<Arc<Stylesheet>>>, + cssom_stylesheet: MutNullableHeap<JS<CSSStyleSheet>>, } impl HTMLStyleElement { @@ -35,6 +37,7 @@ impl HTMLStyleElement { HTMLStyleElement { htmlelement: HTMLElement::new_inherited(local_name, prefix, document), stylesheet: DOMRefCell::new(None), + cssom_stylesheet: MutNullableHeap::new(None), } } @@ -77,6 +80,18 @@ impl HTMLStyleElement { pub fn get_stylesheet(&self) -> Option<Arc<Stylesheet>> { self.stylesheet.borrow().clone() } + + pub fn get_cssom_stylesheet(&self) -> Option<Root<CSSStyleSheet>> { + self.get_stylesheet().map(|sheet| { + self.cssom_stylesheet.or_init(|| { + CSSStyleSheet::new(&window_from_node(self), + "text/css".into(), + None, // todo handle location + None, // todo handle title + sheet) + }) + }) + } } impl VirtualMethods for HTMLStyleElement { |