mirror of
https://github.com/servo/servo.git
synced 2025-07-16 20:03:39 +01:00
Auto merge of #22347 - stevesweetney:master, r=ferjm
Implement HTMLMediaElement muted and defaultMuted attributes <!-- Please describe your changes on the following line: --> PR for issue #22291 --- <!-- 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 - [X] These changes fix #22291 (github issue number if applicable). - [X] There are tests for these changes OR <!-- 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. --> <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/22347) <!-- Reviewable:end -->
This commit is contained in:
commit
a28e15e4ea
5 changed files with 44 additions and 109 deletions
|
@ -199,6 +199,8 @@ pub struct HTMLMediaElement {
|
||||||
volume: Cell<f64>,
|
volume: Cell<f64>,
|
||||||
/// https://html.spec.whatwg.org/multipage/#dom-media-seeking
|
/// https://html.spec.whatwg.org/multipage/#dom-media-seeking
|
||||||
seeking: Cell<bool>,
|
seeking: Cell<bool>,
|
||||||
|
/// https://html.spec.whatwg.org/multipage/#dom-media-muted
|
||||||
|
muted: Cell<bool>,
|
||||||
/// URL of the media resource, if any.
|
/// URL of the media resource, if any.
|
||||||
resource_url: DomRefCell<Option<ServoUrl>>,
|
resource_url: DomRefCell<Option<ServoUrl>>,
|
||||||
/// https://html.spec.whatwg.org/multipage/#dom-media-played
|
/// https://html.spec.whatwg.org/multipage/#dom-media-played
|
||||||
|
@ -248,6 +250,7 @@ impl HTMLMediaElement {
|
||||||
paused: Cell::new(true),
|
paused: Cell::new(true),
|
||||||
defaultPlaybackRate: Cell::new(1.0),
|
defaultPlaybackRate: Cell::new(1.0),
|
||||||
playbackRate: Cell::new(1.0),
|
playbackRate: Cell::new(1.0),
|
||||||
|
muted: Cell::new(false),
|
||||||
// FIXME(nox): Why is this initialised to true?
|
// FIXME(nox): Why is this initialised to true?
|
||||||
autoplaying: Cell::new(true),
|
autoplaying: Cell::new(true),
|
||||||
delaying_the_load_event_flag: Default::default(),
|
delaying_the_load_event_flag: Default::default(),
|
||||||
|
@ -370,6 +373,10 @@ impl HTMLMediaElement {
|
||||||
// playback position.
|
// playback position.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// https://html.spec.whatwg.org/multipage/#allowed-to-play
|
||||||
|
fn is_allowed_to_play(&self) -> bool {
|
||||||
|
true
|
||||||
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#notify-about-playing
|
// https://html.spec.whatwg.org/multipage/#notify-about-playing
|
||||||
fn notify_about_playing(&self) {
|
fn notify_about_playing(&self) {
|
||||||
|
@ -1398,12 +1405,39 @@ impl HTMLMediaElementMethods for HTMLMediaElement {
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-media-autoplay
|
// https://html.spec.whatwg.org/multipage/#dom-media-autoplay
|
||||||
make_bool_setter!(SetAutoplay, "autoplay");
|
make_bool_setter!(SetAutoplay, "autoplay");
|
||||||
|
|
||||||
|
// https://html.spec.whatwg.org/multipage/#dom-media-defaultmuted
|
||||||
|
make_bool_getter!(DefaultMuted, "muted");
|
||||||
|
// https://html.spec.whatwg.org/multipage/#dom-media-defaultmuted
|
||||||
|
make_bool_setter!(SetDefaultMuted, "muted");
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-media-src
|
// https://html.spec.whatwg.org/multipage/#dom-media-src
|
||||||
make_url_getter!(Src, "src");
|
make_url_getter!(Src, "src");
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-media-src
|
// https://html.spec.whatwg.org/multipage/#dom-media-src
|
||||||
make_url_setter!(SetSrc, "src");
|
make_url_setter!(SetSrc, "src");
|
||||||
|
|
||||||
|
// https://html.spec.whatwg.org/multipage/#dom-media-muted
|
||||||
|
fn Muted(&self) -> bool {
|
||||||
|
self.muted.get()
|
||||||
|
}
|
||||||
|
|
||||||
|
// https://html.spec.whatwg.org/multipage/#dom-media-muted
|
||||||
|
fn SetMuted(&self, value: bool) {
|
||||||
|
if self.muted.get() == value {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
self.muted.set(value);
|
||||||
|
let _ = self.player.set_mute(value);
|
||||||
|
let window = window_from_node(self);
|
||||||
|
window
|
||||||
|
.task_manager()
|
||||||
|
.media_element_task_source()
|
||||||
|
.queue_simple_event(self.upcast(), atom!("volumechange"), &window);
|
||||||
|
if !self.is_allowed_to_play() {
|
||||||
|
self.internal_pause_steps();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-media-srcobject
|
// https://html.spec.whatwg.org/multipage/#dom-media-srcobject
|
||||||
fn GetSrcObject(&self) -> Option<DomRoot<Blob>> {
|
fn GetSrcObject(&self) -> Option<DomRoot<Blob>> {
|
||||||
self.src_object.get()
|
self.src_object.get()
|
||||||
|
@ -1720,6 +1754,9 @@ impl HTMLMediaElementMethods for HTMLMediaElement {
|
||||||
.task_manager()
|
.task_manager()
|
||||||
.media_element_task_source()
|
.media_element_task_source()
|
||||||
.queue_simple_event(self.upcast(), atom!("volumechange"), &window);
|
.queue_simple_event(self.upcast(), atom!("volumechange"), &window);
|
||||||
|
if !self.is_allowed_to_play() {
|
||||||
|
self.internal_pause_steps();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
@ -1734,6 +1771,11 @@ impl VirtualMethods for HTMLMediaElement {
|
||||||
fn attribute_mutated(&self, attr: &Attr, mutation: AttributeMutation) {
|
fn attribute_mutated(&self, attr: &Attr, mutation: AttributeMutation) {
|
||||||
self.super_type().unwrap().attribute_mutated(attr, mutation);
|
self.super_type().unwrap().attribute_mutated(attr, mutation);
|
||||||
|
|
||||||
|
if &local_name!("muted") == attr.local_name() {
|
||||||
|
self.SetMuted(mutation.new_value(attr).is_some());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if mutation.new_value(attr).is_none() {
|
if mutation.new_value(attr).is_none() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,8 +55,8 @@ interface HTMLMediaElement : HTMLElement {
|
||||||
// controls
|
// controls
|
||||||
// [CEReactions] attribute boolean controls;
|
// [CEReactions] attribute boolean controls;
|
||||||
[Throws] attribute double volume;
|
[Throws] attribute double volume;
|
||||||
// attribute boolean muted;
|
attribute boolean muted;
|
||||||
// [CEReactions] attribute boolean defaultMuted;
|
[CEReactions] attribute boolean defaultMuted;
|
||||||
|
|
||||||
// tracks
|
// tracks
|
||||||
// readonly attribute AudioTrackList audioTracks;
|
// readonly attribute AudioTrackList audioTracks;
|
||||||
|
|
|
@ -6783,12 +6783,6 @@
|
||||||
[HTMLMediaElement interface: document.createElement("video") must inherit property "controls" with the proper type]
|
[HTMLMediaElement interface: document.createElement("video") must inherit property "controls" with the proper type]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
[HTMLMediaElement interface: document.createElement("video") must inherit property "muted" with the proper type]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[HTMLMediaElement interface: document.createElement("video") must inherit property "defaultMuted" with the proper type]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[HTMLMediaElement interface: document.createElement("video") must inherit property "audioTracks" with the proper type]
|
[HTMLMediaElement interface: document.createElement("video") must inherit property "audioTracks" with the proper type]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
|
@ -6813,12 +6807,6 @@
|
||||||
[HTMLMediaElement interface: document.createElement("audio") must inherit property "controls" with the proper type]
|
[HTMLMediaElement interface: document.createElement("audio") must inherit property "controls" with the proper type]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
[HTMLMediaElement interface: document.createElement("audio") must inherit property "muted" with the proper type]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[HTMLMediaElement interface: document.createElement("audio") must inherit property "defaultMuted" with the proper type]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[HTMLMediaElement interface: document.createElement("audio") must inherit property "audioTracks" with the proper type]
|
[HTMLMediaElement interface: document.createElement("audio") must inherit property "audioTracks" with the proper type]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
|
@ -6843,12 +6831,6 @@
|
||||||
[HTMLMediaElement interface: new Audio() must inherit property "controls" with the proper type]
|
[HTMLMediaElement interface: new Audio() must inherit property "controls" with the proper type]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
[HTMLMediaElement interface: new Audio() must inherit property "muted" with the proper type]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[HTMLMediaElement interface: new Audio() must inherit property "defaultMuted" with the proper type]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[HTMLMediaElement interface: new Audio() must inherit property "audioTracks" with the proper type]
|
[HTMLMediaElement interface: new Audio() must inherit property "audioTracks" with the proper type]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
|
@ -6873,12 +6855,6 @@
|
||||||
[HTMLMediaElement interface: attribute controls]
|
[HTMLMediaElement interface: attribute controls]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
[HTMLMediaElement interface: attribute muted]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[HTMLMediaElement interface: attribute defaultMuted]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[HTMLMediaElement interface: attribute audioTracks]
|
[HTMLMediaElement interface: attribute audioTracks]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
|
|
|
@ -1,20 +0,0 @@
|
||||||
[event_volumechange.html]
|
|
||||||
expected: TIMEOUT
|
|
||||||
[setting audio.muted fires volumechange]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[setting video.volume/muted repeatedly fires volumechange repeatedly]
|
|
||||||
expected: TIMEOUT
|
|
||||||
|
|
||||||
[setting audio.volume/muted to the same value does not fire volumechange]
|
|
||||||
expected: TIMEOUT
|
|
||||||
|
|
||||||
[setting video.muted fires volumechange]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[setting audio.volume/muted repeatedly fires volumechange repeatedly]
|
|
||||||
expected: TIMEOUT
|
|
||||||
|
|
||||||
[setting video.volume/muted to the same value does not fire volumechange]
|
|
||||||
expected: TIMEOUT
|
|
||||||
|
|
|
@ -1,76 +1,13 @@
|
||||||
[muted.html]
|
[muted.html]
|
||||||
[getting audio.muted (script-created)]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[getting audio.muted (parser-created)]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[getting audio.muted with muted="" (document.write-created)]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[getting video.muted with muted="" after load (parser-created)]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[cloning video propagates muted (innerHTML-created)]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[getting video.muted with muted="" (innerHTML-created)]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[setting audio.muted with muted="" (parser-created)]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[setting audio.muted (script-created)]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[getting video.muted with muted="" (document.write-created)]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[getting audio.muted with muted="" (innerHTML-created)]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[setting video.muted with muted="" (parser-created)]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[getting video.muted with muted="" (script-created)]
|
[getting video.muted with muted="" (script-created)]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
[setting video.muted (parser-created)]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[getting video.muted (parser-created)]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[setting audio.muted (parser-created)]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[setting video.muted (script-created)]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[setting audio.muted with muted="" (script-created)]
|
[setting audio.muted with muted="" (script-created)]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
[cloning video propagates muted (script-created)]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[getting audio.muted with muted="" (parser-created)]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[getting video.muted (script-created)]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[setting video.muted with muted="" (script-created)]
|
[setting video.muted with muted="" (script-created)]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
[cloning audio propagates muted (innerHTML-created)]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[cloning audio propagates muted (script-created)]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[getting audio.muted with muted="" (script-created)]
|
[getting audio.muted with muted="" (script-created)]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
[getting video.muted with muted="" (parser-created)]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue