1use dom_struct::dom_struct;
6
7use crate::dom::bindings::codegen::Bindings::StyleSheetBinding::StyleSheetMethods;
8use crate::dom::bindings::inheritance::Castable;
9use crate::dom::bindings::reflector::Reflector;
10use crate::dom::bindings::root::DomRoot;
11use crate::dom::bindings::str::DOMString;
12use crate::dom::cssstylesheet::CSSStyleSheet;
13use crate::dom::element::Element;
14use crate::dom::medialist::MediaList;
15use crate::script_runtime::CanGc;
16
17#[dom_struct]
18pub(crate) struct StyleSheet {
19 reflector_: Reflector,
20 type_: DOMString,
21 href: Option<DOMString>,
22 title: Option<DOMString>,
23}
24
25impl StyleSheet {
26 #[cfg_attr(crown, allow(crown::unrooted_must_root))]
27 pub(crate) fn new_inherited(
28 type_: DOMString,
29 href: Option<DOMString>,
30 title: Option<DOMString>,
31 ) -> StyleSheet {
32 StyleSheet {
33 reflector_: Reflector::new(),
34 type_,
35 href,
36 title,
37 }
38 }
39}
40
41impl StyleSheetMethods<crate::DomTypeHolder> for StyleSheet {
42 fn Type(&self) -> DOMString {
44 self.type_.clone()
45 }
46
47 fn GetHref(&self) -> Option<DOMString> {
49 self.href.clone()
50 }
51
52 fn GetOwnerNode(&self) -> Option<DomRoot<Element>> {
54 self.downcast::<CSSStyleSheet>()
55 .and_then(|s| s.owner_node())
56 }
57
58 fn Media(&self) -> DomRoot<MediaList> {
60 self.downcast::<CSSStyleSheet>()
61 .unwrap()
62 .medialist(CanGc::note())
63 }
64
65 fn GetTitle(&self) -> Option<DOMString> {
67 self.title.clone()
68 }
69
70 fn Disabled(&self) -> bool {
72 self.downcast::<CSSStyleSheet>().unwrap().disabled()
73 }
74
75 fn SetDisabled(&self, disabled: bool) {
77 self.downcast::<CSSStyleSheet>()
78 .unwrap()
79 .set_disabled(disabled)
80 }
81}