aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/htmllinkelement.rs
diff options
context:
space:
mode:
Diffstat (limited to 'components/script/dom/htmllinkelement.rs')
-rw-r--r--components/script/dom/htmllinkelement.rs15
1 files changed, 15 insertions, 0 deletions
diff --git a/components/script/dom/htmllinkelement.rs b/components/script/dom/htmllinkelement.rs
index 5df64f62ca0..17c9514287e 100644
--- a/components/script/dom/htmllinkelement.rs
+++ b/components/script/dom/htmllinkelement.rs
@@ -14,6 +14,7 @@ use dom::bindings::js::{JS, MutNullableHeap, Root, RootedReference};
use dom::bindings::refcounted::Trusted;
use dom::bindings::reflector::Reflectable;
use dom::bindings::str::DOMString;
+use dom::cssstylesheet::CSSStyleSheet;
use dom::document::Document;
use dom::domtokenlist::DOMTokenList;
use dom::element::{AttributeMutation, Element, ElementCreator};
@@ -56,6 +57,7 @@ pub struct HTMLLinkElement {
rel_list: MutNullableHeap<JS<DOMTokenList>>,
#[ignore_heap_size_of = "Arc"]
stylesheet: DOMRefCell<Option<Arc<Stylesheet>>>,
+ cssom_stylesheet: MutNullableHeap<JS<CSSStyleSheet>>,
/// https://html.spec.whatwg.org/multipage/#a-style-sheet-that-is-blocking-scripts
parser_inserted: Cell<bool>,
@@ -69,6 +71,7 @@ impl HTMLLinkElement {
rel_list: Default::default(),
parser_inserted: Cell::new(creator == ElementCreator::ParserCreated),
stylesheet: DOMRefCell::new(None),
+ cssom_stylesheet: MutNullableHeap::new(None),
}
}
@@ -85,6 +88,18 @@ impl HTMLLinkElement {
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)
+ })
+ })
+ }
}
fn get_attr(element: &Element, local_name: &LocalName) -> Option<String> {