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 16, 2020
2 parents 2af9648 + fe82d17 commit 1bc6a3f
Show file tree
Hide file tree
Showing 17 changed files with 16 additions and 134 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.

Expand Up @@ -8,9 +8,6 @@
[Existence and writability of CSSImportRule attributes]
expected: FAIL

[StyleSheet : MediaList mediaText attribute should be updated due to [PutForwards\]]
expected: FAIL

[CSSImportRule : MediaList mediaText attribute should be updated due to [PutForwards\]]
expected: FAIL

Expand Down
36 changes: 0 additions & 36 deletions tests/wpt/metadata-layout-2020/css/cssom/idlharness.html.ini
Expand Up @@ -8,9 +8,6 @@
[CSSStyleDeclaration interface: style_element.style must inherit property "parentRule" with the proper type]
expected: FAIL

[MediaList interface: sheet.media must inherit property "deleteMedium(CSSOMString)" with the proper type]
expected: FAIL

[CSSStyleDeclaration interface: sheet.cssRules[4\].style must inherit property "setProperty(CSSOMString, CSSOMString, optional CSSOMString)" with the proper type]
expected: FAIL

Expand All @@ -20,9 +17,6 @@
[Stringification of svg_element.style]
expected: FAIL

[MediaList interface: calling item(unsigned long) on sheet.media with too few arguments must throw TypeError]
expected: FAIL

[CSSStyleSheet interface: sheet must inherit property "ownerRule" with the proper type]
expected: FAIL

Expand Down Expand Up @@ -53,18 +47,9 @@
[CSSMarginRule interface: sheet.cssRules[2\].cssRules[0\] must inherit property "style" with the proper type]
expected: FAIL

[MediaList interface: sheet.media must inherit property "item(unsigned long)" with the proper type]
expected: FAIL

[CSSStyleDeclaration interface: svg_element.style must inherit property "getPropertyValue(CSSOMString)" with the proper type]
expected: FAIL

[MediaList interface: sheet.media must inherit property "length" with the proper type]
expected: FAIL

[StyleSheet interface: sheet must inherit property "media" with the proper type]
expected: FAIL

[SVGStyleElement interface: attribute sheet]
expected: FAIL

Expand All @@ -89,9 +74,6 @@
[StyleSheet interface: attribute type]
expected: FAIL

[MediaList interface: calling appendMedium(CSSOMString) on sheet.media with too few arguments must throw TypeError]
expected: FAIL

[Stringification of sheet.cssRules[2\].cssRules[0\]]
expected: FAIL

Expand Down Expand Up @@ -248,9 +230,6 @@
[StyleSheet interface: sheet must inherit property "parentStyleSheet" with the proper type]
expected: FAIL

[MediaList interface: calling deleteMedium(CSSOMString) on sheet.media with too few arguments must throw TypeError]
expected: FAIL

[CSSPageRule interface: sheet.cssRules[2\] must inherit property "selectorText" with the proper type]
expected: FAIL

Expand All @@ -275,9 +254,6 @@
[CSSStyleDeclaration interface: sheet.cssRules[2\].style must inherit property "getPropertyPriority(CSSOMString)" with the proper type]
expected: FAIL
[MediaList interface: sheet.media must inherit property "mediaText" with the proper type]
expected: FAIL
[CSSStyleDeclaration interface: sheet.cssRules[2\].cssRules[0\].style must inherit property "removeProperty(CSSOMString)" with the proper type]
expected: FAIL
Expand All @@ -296,9 +272,6 @@
[CSSStyleDeclaration interface: calling getPropertyValue(CSSOMString) on sheet.cssRules[4\].style with too few arguments must throw TypeError]
expected: FAIL
[MediaList interface: sheet.media must inherit property "appendMedium(CSSOMString)" with the proper type]
expected: FAIL
[CSSStyleDeclaration interface: sheet.cssRules[4\].style must inherit property "length" with the proper type]
expected: FAIL
Expand All @@ -323,9 +296,6 @@
[SVGElement interface: svg_element must inherit property "style" with the proper type]
expected: FAIL
[StyleSheet interface: attribute media]
expected: FAIL
[CSSPageRule interface: attribute style]
expected: FAIL
Expand All @@ -344,9 +314,6 @@
[CSSStyleDeclaration interface: sheet.cssRules[4\].style must inherit property "getPropertyValue(CSSOMString)" with the proper type]
expected: FAIL
[MediaList must be primary interface of sheet.media]
expected: FAIL
[CSSRule interface: sheet.cssRules[2\].cssRules[0\] must inherit property "PAGE_RULE" with the proper type]
expected: FAIL
Expand Down Expand Up @@ -407,9 +374,6 @@
[CSSStyleDeclaration interface: svg_element.style must inherit property "cssText" with the proper type]
expected: FAIL

[Stringification of sheet.media]
expected: FAIL

[CSSRule interface: sheet.cssRules[2\].cssRules[0\] must inherit property "type" with the proper type]
expected: FAIL

Expand Down

This file was deleted.

Expand Up @@ -8,6 +8,3 @@
[mediatest_medialist_serialize_element]
expected: FAIL

[mediatest_medialist_serialize_empty]
expected: FAIL

Expand Up @@ -2,6 +2,3 @@
[deleteMedium_no_matching_medium_to_remove]
expected: FAIL

[deleteMedium_removes_correct_medium]
expected: FAIL

This file was deleted.

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

This file was deleted.

3 changes: 0 additions & 3 deletions tests/wpt/metadata/css/cssom/cssimportrule.html.ini
Expand Up @@ -21,6 +21,3 @@
[CSSStyleDeclaration cssText attribute should be updated due to [PutForwards\]]
expected: FAIL

[StyleSheet : MediaList mediaText attribute should be updated due to [PutForwards\]]
expected: FAIL

36 changes: 0 additions & 36 deletions tests/wpt/metadata/css/cssom/idlharness.html.ini
Expand Up @@ -8,18 +8,12 @@
[CSSStyleDeclaration interface: style_element.style must inherit property "parentRule" with the proper type]
expected: FAIL

[MediaList interface: sheet.media must inherit property "deleteMedium(CSSOMString)" with the proper type]
expected: FAIL

[CSSStyleDeclaration interface: sheet.cssRules[2\].style must inherit property "removeProperty(CSSOMString)" with the proper type]
expected: FAIL

[Stringification of svg_element.style]
expected: FAIL

[MediaList interface: calling item(unsigned long) on sheet.media with too few arguments must throw TypeError]
expected: FAIL

[CSSStyleSheet interface: sheet must inherit property "ownerRule" with the proper type]
expected: FAIL

Expand Down Expand Up @@ -56,18 +50,9 @@
[CSSMarginRule interface: sheet.cssRules[2\].cssRules[0\] must inherit property "style" with the proper type]
expected: FAIL

[MediaList interface: sheet.media must inherit property "item(unsigned long)" with the proper type]
expected: FAIL

[CSSStyleDeclaration interface: svg_element.style must inherit property "getPropertyValue(CSSOMString)" with the proper type]
expected: FAIL

[MediaList interface: sheet.media must inherit property "length" with the proper type]
expected: FAIL

[StyleSheet interface: sheet must inherit property "media" with the proper type]
expected: FAIL

[SVGStyleElement interface: attribute sheet]
expected: FAIL

Expand Down Expand Up @@ -227,9 +212,6 @@
[CSSStyleDeclaration interface: sheet.cssRules[2\].cssRules[0\].style must inherit property "getPropertyValue(CSSOMString)" with the proper type]
expected: FAIL

[MediaList interface: calling appendMedium(CSSOMString) on sheet.media with too few arguments must throw TypeError]
expected: FAIL

[CSSRule interface: sheet.cssRules[4\] must inherit property "cssText" with the proper type]
expected: FAIL

Expand All @@ -248,9 +230,6 @@
[CSSStyleDeclaration interface: sheet.cssRules[2\].cssRules[0\].style must inherit property "getPropertyPriority(CSSOMString)" with the proper type]
expected: FAIL

[MediaList interface: calling deleteMedium(CSSOMString) on sheet.media with too few arguments must throw TypeError]
expected: FAIL

[CSSPageRule interface: sheet.cssRules[2\] must inherit property "selectorText" with the proper type]
expected: FAIL

Expand All @@ -275,9 +254,6 @@
[CSSStyleDeclaration interface: sheet.cssRules[2\].style must inherit property "getPropertyPriority(CSSOMString)" with the proper type]
expected: FAIL
[MediaList interface: sheet.media must inherit property "mediaText" with the proper type]
expected: FAIL
[CSSStyleDeclaration interface: sheet.cssRules[2\].style must inherit property "length" with the proper type]
expected: FAIL
Expand Down Expand Up @@ -308,9 +284,6 @@
[CSSStyleDeclaration interface: calling getPropertyValue(CSSOMString) on sheet.cssRules[4\].style with too few arguments must throw TypeError]
expected: FAIL
[MediaList interface: sheet.media must inherit property "appendMedium(CSSOMString)" with the proper type]
expected: FAIL
[CSSStyleDeclaration interface: sheet.cssRules[4\].style must inherit property "length" with the proper type]
expected: FAIL
Expand All @@ -335,9 +308,6 @@
[SVGElement interface: svg_element must inherit property "style" with the proper type]
expected: FAIL
[StyleSheet interface: attribute media]
expected: FAIL
[CSSPageRule interface: attribute style]
expected: FAIL
Expand All @@ -356,9 +326,6 @@
[CSSStyleDeclaration interface: sheet.cssRules[4\].style must inherit property "getPropertyValue(CSSOMString)" with the proper type]
expected: FAIL
[MediaList must be primary interface of sheet.media]
expected: FAIL
[CSSRule interface: sheet.cssRules[2\].cssRules[0\] must inherit property "PAGE_RULE" with the proper type]
expected: FAIL
Expand Down Expand Up @@ -413,9 +380,6 @@
[CSSStyleDeclaration interface: svg_element.style must inherit property "cssText" with the proper type]
expected: FAIL

[Stringification of sheet.media]
expected: FAIL

[CSSRule interface: sheet.cssRules[2\].cssRules[0\] must inherit property "type" with the proper type]
expected: FAIL

Expand Down
2 changes: 0 additions & 2 deletions tests/wpt/metadata/css/cssom/medialist-dynamic-001.html.ini

This file was deleted.

Expand Up @@ -6,9 +6,6 @@
[mediatest_medialist_serialize_comma]
expected: FAIL

[mediatest_medialist_serialize_empty]
expected: FAIL

[mediatest_medialist_serialize_lexicographical]
expected: FAIL

Expand Down
@@ -1,8 +1,5 @@
[medialist-interfaces-002.html]
type: testharness
[deleteMedium_removes_correct_medium]
expected: FAIL

[deleteMedium_no_matching_medium_to_remove]
expected: FAIL

This file was deleted.

0 comments on commit 1bc6a3f

Please sign in to comment.