Skip to content

Commit cc9c51c

Browse files
committed
Bug 1707584 - part4 : implement :muted pseudo class. r=media-playback-reviewers,firefox-style-system-reviewers,emilio,chunmin
This patch implements :muted [1] for media element. [1] https://html.spec.whatwg.org/multipage/semantics-other.html#selector-muted Differential Revision: https://phabricator.services.mozilla.com/D281040
1 parent 606b5bc commit cc9c51c

File tree

7 files changed

+9
-8
lines changed

7 files changed

+9
-8
lines changed

dom/base/rust/lib.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
use bitflags::bitflags;
88
use malloc_size_of::malloc_size_of_is_0;
99

10-
pub const HEADING_LEVEL_OFFSET: usize = 56;
10+
pub const HEADING_LEVEL_OFFSET: usize = 57;
1111

1212
bitflags! {
1313
/// Event-based element states.
@@ -152,6 +152,8 @@ bitflags! {
152152
const BUFFERING = 1u64 << 54;
153153
/// https://html.spec.whatwg.org/multipage/semantics-other.html#selector-stalled
154154
const STALLED = 1u64 << 55;
155+
/// https://html.spec.whatwg.org/multipage/semantics-other.html#selector-muted
156+
const MUTED = 1u64 << 56;
155157
/// https://drafts.csswg.org/selectors-5/#headings
156158
/// These 4 bits are used to pack the elements heading level into the element state
157159
/// Heading levels can be from 1-9 so 4 bits allows us to express the full range.

dom/media/mediaelement/HTMLMediaElement.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3718,6 +3718,8 @@ void HTMLMediaElement::SetMutedInternal(uint32_t aMuted) {
37183718
return;
37193719
}
37203720

3721+
// https://html.spec.whatwg.org/multipage/semantics-other.html#selector-muted
3722+
SetStates(ElementState::MUTED, mMuted & MUTED_BY_CONTENT);
37213723
SetVolumeInternal();
37223724
}
37233725

servo/components/style/gecko/non_ts_pseudo_class_list.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ macro_rules! apply_non_ts_list {
9898
("seeking", Seeking, SEEKING, _),
9999
("buffering", Buffering, BUFFERING, _),
100100
("stalled", Stalled, STALLED, _),
101+
("muted", Muted, MUTED, _),
101102

102103

103104
// NOTE(emilio): Pseudo-classes below only depend on document state, and thus

servo/components/style/gecko/selector_parser.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ impl NonTSPseudoClass {
229229
}
230230
if matches!(
231231
*self,
232-
Self::Playing | Self::Paused | Self::Seeking | Self::Buffering | Self::Stalled
232+
Self::Playing | Self::Paused | Self::Seeking | Self::Buffering | Self::Stalled | Self::Muted
233233
) {
234234
return static_prefs::pref!("dom.media.pseudo-classes.enabled");
235235
}

servo/components/style/gecko/wrapper.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2088,7 +2088,8 @@ impl<'le> ::selectors::Element for GeckoElement<'le> {
20882088
| NonTSPseudoClass::MozSuppressForPrintSelection
20892089
| NonTSPseudoClass::Seeking
20902090
| NonTSPseudoClass::Buffering
2091-
| NonTSPseudoClass::Stalled => {
2091+
| NonTSPseudoClass::Stalled
2092+
| NonTSPseudoClass::Muted => {
20922093
self.state().intersects(pseudo_class.state_flag())
20932094
},
20942095
NonTSPseudoClass::Paused => self.is_html_media_element() && self.state().intersects(ElementState::PAUSED),
Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,2 @@
11
[media-pseudo-classes-in-has.html]
22
prefs: [dom.media.pseudo-classes.enabled:true]
3-
[Test :muted pseudo-class]
4-
expected: FAIL

testing/web-platform/meta/css/selectors/media/sound-state.html.ini

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,3 @@
33
if (os == "android") and fission: [OK, TIMEOUT]
44
[Test :pseudo-class syntax is supported without throwing a SyntaxError]
55
expected: FAIL
6-
7-
[Test :muted pseudo-class]
8-
expected: FAIL

0 commit comments

Comments
 (0)