script/dom/css/
stylesheet.rs1use dom_struct::dom_struct;
6
7use super::cssstylesheet::CSSStyleSheet;
8use crate::dom::bindings::codegen::Bindings::StyleSheetBinding::StyleSheetMethods;
9use crate::dom::bindings::inheritance::Castable;
10use crate::dom::bindings::reflector::Reflector;
11use crate::dom::bindings::root::DomRoot;
12use crate::dom::bindings::str::DOMString;
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 pub(crate) fn new_inherited(
27 type_: DOMString,
28 href: Option<DOMString>,
29 title: Option<DOMString>,
30 ) -> StyleSheet {
31 StyleSheet {
32 reflector_: Reflector::new(),
33 type_,
34 href,
35 title,
36 }
37 }
38}
39
40impl StyleSheetMethods<crate::DomTypeHolder> for StyleSheet {
41 fn Type(&self) -> DOMString {
43 self.type_.clone()
44 }
45
46 fn GetHref(&self) -> Option<DOMString> {
48 self.href.clone()
49 }
50
51 fn GetOwnerNode(&self) -> Option<DomRoot<Element>> {
53 self.downcast::<CSSStyleSheet>()
54 .and_then(|s| s.owner_node())
55 }
56
57 fn Media(&self) -> DomRoot<MediaList> {
59 self.downcast::<CSSStyleSheet>()
60 .unwrap()
61 .medialist(CanGc::note())
62 }
63
64 fn GetTitle(&self) -> Option<DOMString> {
66 self.title.clone()
67 }
68
69 fn Disabled(&self) -> bool {
71 self.downcast::<CSSStyleSheet>().unwrap().disabled()
72 }
73
74 fn SetDisabled(&self, disabled: bool) {
76 self.downcast::<CSSStyleSheet>()
77 .unwrap()
78 .set_disabled(disabled)
79 }
80}