Skip to content

Commit

Permalink
Auto merge of #27697 - ghostd:stylesheet-media, r=<try>
Browse files Browse the repository at this point in the history
Implements StyleSheet.media

<!-- Please describe your changes on the following line: -->

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: -->
- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors
- [ ] These changes fix #___ (GitHub issue number if applicable)

<!-- Either: -->
- [x] There are tests for these changes OR
- [ ] These changes do not require tests because ___

<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
  • Loading branch information
bors-servo committed Oct 11, 2020
2 parents 7f12ee6 + 7092f23 commit 079465b
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 25 deletions.
9 changes: 9 additions & 0 deletions components/script/dom/cssstylesheet.rs
Expand Up @@ -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;
Expand Down Expand Up @@ -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 {
Expand Down
6 changes: 6 additions & 0 deletions components/script/dom/stylesheet.rs
Expand Up @@ -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]
Expand Down Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion components/script/dom/webidls/StyleSheet.webidl
Expand Up @@ -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;
};

Expand Down
12 changes: 0 additions & 12 deletions tests/wpt/metadata-layout-2020/css/cssom/MediaList2.xhtml.ini

This file was deleted.

12 changes: 0 additions & 12 deletions tests/wpt/metadata/css/cssom/MediaList2.xhtml.ini

This file was deleted.

0 comments on commit 079465b

Please sign in to comment.