use dom_struct::dom_struct;
use crate::dom::bindings::codegen::Bindings::StyleSheetBinding::StyleSheetMethods;
use crate::dom::bindings::inheritance::Castable;
use crate::dom::bindings::reflector::Reflector;
use crate::dom::bindings::root::DomRoot;
use crate::dom::bindings::str::DOMString;
use crate::dom::cssstylesheet::CSSStyleSheet;
use crate::dom::element::Element;
use crate::dom::medialist::MediaList;
#[dom_struct]
pub struct StyleSheet {
reflector_: Reflector,
type_: DOMString,
href: Option<DOMString>,
title: Option<DOMString>,
}
impl StyleSheet {
#[allow(crown::unrooted_must_root)]
pub fn new_inherited(
type_: DOMString,
href: Option<DOMString>,
title: Option<DOMString>,
) -> StyleSheet {
StyleSheet {
reflector_: Reflector::new(),
type_,
href,
title,
}
}
}
impl StyleSheetMethods<crate::DomTypeHolder> for StyleSheet {
fn Type_(&self) -> DOMString {
self.type_.clone()
}
fn GetHref(&self) -> Option<DOMString> {
self.href.clone()
}
fn GetOwnerNode(&self) -> Option<DomRoot<Element>> {
self.downcast::<CSSStyleSheet>().and_then(|s| s.get_owner())
}
fn Media(&self) -> DomRoot<MediaList> {
self.downcast::<CSSStyleSheet>().unwrap().medialist()
}
fn GetTitle(&self) -> Option<DOMString> {
self.title.clone()
}
fn Disabled(&self) -> bool {
self.downcast::<CSSStyleSheet>().unwrap().disabled()
}
fn SetDisabled(&self, disabled: bool) {
self.downcast::<CSSStyleSheet>()
.unwrap()
.set_disabled(disabled)
}
}