mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
Implements StyleSheet.media
This commit is contained in:
parent
2af9648235
commit
66223f7596
18 changed files with 16 additions and 980 deletions
|
@ -10,6 +10,7 @@ use crate::dom::bindings::root::{DomRoot, MutNullableDom};
|
|||
use crate::dom::bindings::str::DOMString;
|
||||
use crate::dom::cssrulelist::{CSSRuleList, RulesSource};
|
||||
use crate::dom::element::Element;
|
||||
use crate::dom::medialist::MediaList;
|
||||
use crate::dom::node::{stylesheets_owner_from_node, Node};
|
||||
use crate::dom::stylesheet::StyleSheet;
|
||||
use crate::dom::window::Window;
|
||||
|
@ -100,6 +101,14 @@ impl CSSStyleSheet {
|
|||
pub fn set_origin_clean(&self, origin_clean: bool) {
|
||||
self.origin_clean.set(origin_clean);
|
||||
}
|
||||
|
||||
pub fn medialist(&self) -> DomRoot<MediaList> {
|
||||
MediaList::new(
|
||||
self.global().as_window(),
|
||||
self,
|
||||
self.style_stylesheet().media.clone(),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
impl CSSStyleSheetMethods for CSSStyleSheet {
|
||||
|
|
|
@ -9,6 +9,7 @@ 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;
|
||||
use dom_struct::dom_struct;
|
||||
|
||||
#[dom_struct]
|
||||
|
@ -51,6 +52,11 @@ impl StyleSheetMethods for StyleSheet {
|
|||
self.downcast::<CSSStyleSheet>().and_then(|s| s.get_owner())
|
||||
}
|
||||
|
||||
// https://drafts.csswg.org/cssom/#dom-stylesheet-media
|
||||
fn Media(&self) -> DomRoot<MediaList> {
|
||||
self.downcast::<CSSStyleSheet>().unwrap().medialist()
|
||||
}
|
||||
|
||||
// https://drafts.csswg.org/cssom/#dom-stylesheet-title
|
||||
fn GetTitle(&self) -> Option<DOMString> {
|
||||
self.title.clone()
|
||||
|
|
|
@ -12,7 +12,7 @@ interface StyleSheet {
|
|||
// readonly attribute StyleSheet? parentStyleSheet;
|
||||
readonly attribute DOMString? title;
|
||||
|
||||
// [SameObject, PutForwards=mediaText] readonly attribute MediaList media;
|
||||
[SameObject, PutForwards=mediaText] readonly attribute MediaList media;
|
||||
attribute boolean disabled;
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue