mirror of
https://github.com/servo/servo.git
synced 2025-06-10 09:33:13 +00:00
Implementing volume attribute into HTMLMediaElement
This commit is contained in:
parent
1046ae58a1
commit
ad3ec61d2f
10 changed files with 60 additions and 29 deletions
11
Cargo.lock
generated
11
Cargo.lock
generated
|
@ -3528,7 +3528,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "servo-media"
|
name = "servo-media"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://github.com/servo/media#a3a2e8586074227f2e4b175c94f759df3690b195"
|
source = "git+https://github.com/servo/media#352072f33b6d118f89aa4ccf000ceaf360a5f663"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"servo-media-audio 0.1.0 (git+https://github.com/servo/media)",
|
"servo-media-audio 0.1.0 (git+https://github.com/servo/media)",
|
||||||
"servo-media-gstreamer 0.1.0 (git+https://github.com/servo/media)",
|
"servo-media-gstreamer 0.1.0 (git+https://github.com/servo/media)",
|
||||||
|
@ -3538,7 +3538,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "servo-media-audio"
|
name = "servo-media-audio"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://github.com/servo/media#a3a2e8586074227f2e4b175c94f759df3690b195"
|
source = "git+https://github.com/servo/media#352072f33b6d118f89aa4ccf000ceaf360a5f663"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"boxfnonce 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"boxfnonce 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"byte-slice-cast 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"byte-slice-cast 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
@ -3555,7 +3555,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "servo-media-gstreamer"
|
name = "servo-media-gstreamer"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://github.com/servo/media#a3a2e8586074227f2e4b175c94f759df3690b195"
|
source = "git+https://github.com/servo/media#352072f33b6d118f89aa4ccf000ceaf360a5f663"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"byte-slice-cast 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"byte-slice-cast 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"glib 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"glib 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
@ -3563,6 +3563,7 @@ dependencies = [
|
||||||
"gstreamer-app 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"gstreamer-app 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"gstreamer-audio 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"gstreamer-audio 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"gstreamer-player 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"gstreamer-player 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"gstreamer-video 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"ipc-channel 0.11.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
"ipc-channel 0.11.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"regex 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
"regex 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"servo-media-audio 0.1.0 (git+https://github.com/servo/media)",
|
"servo-media-audio 0.1.0 (git+https://github.com/servo/media)",
|
||||||
|
@ -3573,7 +3574,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "servo-media-player"
|
name = "servo-media-player"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://github.com/servo/media#a3a2e8586074227f2e4b175c94f759df3690b195"
|
source = "git+https://github.com/servo/media#352072f33b6d118f89aa4ccf000ceaf360a5f663"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"ipc-channel 0.11.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
"ipc-channel 0.11.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"serde 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)",
|
"serde 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
@ -3660,7 +3661,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "servo_media_derive"
|
name = "servo_media_derive"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://github.com/servo/media#a3a2e8586074227f2e4b175c94f759df3690b195"
|
source = "git+https://github.com/servo/media#352072f33b6d118f89aa4ccf000ceaf360a5f663"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
"proc-macro2 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"quote 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
"quote 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
|
|
@ -101,6 +101,7 @@ transitionend
|
||||||
unhandledrejection
|
unhandledrejection
|
||||||
unload
|
unload
|
||||||
url
|
url
|
||||||
|
volumechange
|
||||||
waiting
|
waiting
|
||||||
webglcontextcreationerror
|
webglcontextcreationerror
|
||||||
week
|
week
|
||||||
|
|
|
@ -15,7 +15,7 @@ use crate::dom::bindings::codegen::Bindings::MediaErrorBinding::MediaErrorMethod
|
||||||
use crate::dom::bindings::codegen::Bindings::TextTrackBinding::{TextTrackKind, TextTrackMode};
|
use crate::dom::bindings::codegen::Bindings::TextTrackBinding::{TextTrackKind, TextTrackMode};
|
||||||
use crate::dom::bindings::codegen::InheritTypes::{ElementTypeId, HTMLElementTypeId};
|
use crate::dom::bindings::codegen::InheritTypes::{ElementTypeId, HTMLElementTypeId};
|
||||||
use crate::dom::bindings::codegen::InheritTypes::{HTMLMediaElementTypeId, NodeTypeId};
|
use crate::dom::bindings::codegen::InheritTypes::{HTMLMediaElementTypeId, NodeTypeId};
|
||||||
use crate::dom::bindings::error::{Error, ErrorResult};
|
use crate::dom::bindings::error::{Error, ErrorResult, Fallible};
|
||||||
use crate::dom::bindings::inheritance::Castable;
|
use crate::dom::bindings::inheritance::Castable;
|
||||||
use crate::dom::bindings::num::Finite;
|
use crate::dom::bindings::num::Finite;
|
||||||
use crate::dom::bindings::refcounted::Trusted;
|
use crate::dom::bindings::refcounted::Trusted;
|
||||||
|
@ -187,6 +187,8 @@ pub struct HTMLMediaElement {
|
||||||
playback_position: Cell<f64>,
|
playback_position: Cell<f64>,
|
||||||
/// https://html.spec.whatwg.org/multipage/#default-playback-start-position
|
/// https://html.spec.whatwg.org/multipage/#default-playback-start-position
|
||||||
default_playback_start_position: Cell<f64>,
|
default_playback_start_position: Cell<f64>,
|
||||||
|
/// https://html.spec.whatwg.org/multipage/#dom-media-volume
|
||||||
|
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>,
|
||||||
/// URL of the media resource, if any.
|
/// URL of the media resource, if any.
|
||||||
|
@ -245,6 +247,7 @@ impl HTMLMediaElement {
|
||||||
duration: Cell::new(f64::NAN),
|
duration: Cell::new(f64::NAN),
|
||||||
playback_position: Cell::new(0.),
|
playback_position: Cell::new(0.),
|
||||||
default_playback_start_position: Cell::new(0.),
|
default_playback_start_position: Cell::new(0.),
|
||||||
|
volume: Cell::new(1.0),
|
||||||
seeking: Cell::new(false),
|
seeking: Cell::new(false),
|
||||||
resource_url: DomRefCell::new(None),
|
resource_url: DomRefCell::new(None),
|
||||||
played: Rc::new(DomRefCell::new(TimeRangesContainer::new())),
|
played: Rc::new(DomRefCell::new(TimeRangesContainer::new())),
|
||||||
|
@ -1413,6 +1416,32 @@ impl HTMLMediaElementMethods for HTMLMediaElement {
|
||||||
// Step 5
|
// Step 5
|
||||||
DomRoot::from_ref(&track)
|
DomRoot::from_ref(&track)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// https://html.spec.whatwg.org/multipage/#dom-media-volume
|
||||||
|
fn GetVolume(&self) -> Fallible<Finite<f64>> {
|
||||||
|
Ok(Finite::wrap(self.volume.get()))
|
||||||
|
}
|
||||||
|
|
||||||
|
// https://html.spec.whatwg.org/multipage/#dom-media-volume
|
||||||
|
fn SetVolume(&self, value: Finite<f64>) -> ErrorResult {
|
||||||
|
let minimum_volume = 0.0;
|
||||||
|
let maximum_volume = 1.0;
|
||||||
|
if *value < minimum_volume || *value > maximum_volume {
|
||||||
|
return Err(Error::IndexSize);
|
||||||
|
}
|
||||||
|
|
||||||
|
if *value != self.volume.get() {
|
||||||
|
self.volume.set(*value);
|
||||||
|
|
||||||
|
let window = window_from_node(self);
|
||||||
|
window
|
||||||
|
.task_manager()
|
||||||
|
.media_element_task_source()
|
||||||
|
.queue_simple_event(self.upcast(), atom!("volumechange"), &window);
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl VirtualMethods for HTMLMediaElement {
|
impl VirtualMethods for HTMLMediaElement {
|
||||||
|
|
|
@ -54,7 +54,7 @@ interface HTMLMediaElement : HTMLElement {
|
||||||
|
|
||||||
// controls
|
// controls
|
||||||
// [CEReactions] attribute boolean controls;
|
// [CEReactions] attribute boolean controls;
|
||||||
// attribute double volume;
|
[Throws] attribute double volume;
|
||||||
// attribute boolean muted;
|
// attribute boolean muted;
|
||||||
// [CEReactions] attribute boolean defaultMuted;
|
// [CEReactions] attribute boolean defaultMuted;
|
||||||
|
|
||||||
|
|
|
@ -1062,7 +1062,7 @@
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
[HTMLMediaElement interface: document.createElement("video") must inherit property "volume" with the proper type]
|
[HTMLMediaElement interface: document.createElement("video") must inherit property "volume" with the proper type]
|
||||||
expected: FAIL
|
expected: PASS
|
||||||
|
|
||||||
[HTMLMediaElement interface: document.createElement("video") must inherit property "muted" with the proper type]
|
[HTMLMediaElement interface: document.createElement("video") must inherit property "muted" with the proper type]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
@ -1134,7 +1134,7 @@
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
[HTMLMediaElement interface: document.createElement("audio") must inherit property "volume" with the proper type]
|
[HTMLMediaElement interface: document.createElement("audio") must inherit property "volume" with the proper type]
|
||||||
expected: FAIL
|
expected: PASS
|
||||||
|
|
||||||
[HTMLMediaElement interface: document.createElement("audio") must inherit property "muted" with the proper type]
|
[HTMLMediaElement interface: document.createElement("audio") must inherit property "muted" with the proper type]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
@ -1278,7 +1278,7 @@
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
[HTMLMediaElement interface: new Audio() must inherit property "volume" with the proper type]
|
[HTMLMediaElement interface: new Audio() must inherit property "volume" with the proper type]
|
||||||
expected: FAIL
|
expected: PASS
|
||||||
|
|
||||||
[HTMLMediaElement interface: new Audio() must inherit property "muted" with the proper type]
|
[HTMLMediaElement interface: new Audio() must inherit property "muted" with the proper type]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
@ -1425,7 +1425,7 @@
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
[HTMLMediaElement interface: attribute volume]
|
[HTMLMediaElement interface: attribute volume]
|
||||||
expected: FAIL
|
expected: PASS
|
||||||
|
|
||||||
[HTMLMediaElement interface: attribute muted]
|
[HTMLMediaElement interface: attribute muted]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
@ -6793,7 +6793,7 @@
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
[HTMLMediaElement interface: document.createElement("video") must inherit property "volume" with the proper type]
|
[HTMLMediaElement interface: document.createElement("video") must inherit property "volume" with the proper type]
|
||||||
expected: FAIL
|
expected: PASS
|
||||||
|
|
||||||
[HTMLMediaElement interface: document.createElement("video") must inherit property "muted" with the proper type]
|
[HTMLMediaElement interface: document.createElement("video") must inherit property "muted" with the proper type]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
@ -6838,7 +6838,7 @@
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
[HTMLMediaElement interface: document.createElement("audio") must inherit property "volume" with the proper type]
|
[HTMLMediaElement interface: document.createElement("audio") must inherit property "volume" with the proper type]
|
||||||
expected: FAIL
|
expected: PASS
|
||||||
|
|
||||||
[HTMLMediaElement interface: document.createElement("audio") must inherit property "muted" with the proper type]
|
[HTMLMediaElement interface: document.createElement("audio") must inherit property "muted" with the proper type]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
@ -6883,7 +6883,7 @@
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
[HTMLMediaElement interface: new Audio() must inherit property "volume" with the proper type]
|
[HTMLMediaElement interface: new Audio() must inherit property "volume" with the proper type]
|
||||||
expected: FAIL
|
expected: PASS
|
||||||
|
|
||||||
[HTMLMediaElement interface: new Audio() must inherit property "muted" with the proper type]
|
[HTMLMediaElement interface: new Audio() must inherit property "muted" with the proper type]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
@ -7006,7 +7006,7 @@
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
[HTMLMediaElement interface: attribute volume]
|
[HTMLMediaElement interface: attribute volume]
|
||||||
expected: FAIL
|
expected: PASS
|
||||||
|
|
||||||
[HTMLMediaElement interface: attribute muted]
|
[HTMLMediaElement interface: attribute muted]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
[audio_volume_check.html]
|
[audio_volume_check.html]
|
||||||
type: testharness
|
type: testharness
|
||||||
[Check if media.volume is set to new value less than 0.0 that expecting an IndexSizeError exception is to be thrown]
|
[Check if media.volume is set to new value less than 0.0 that expecting an IndexSizeError exception is to be thrown]
|
||||||
expected: FAIL
|
expected: PASS
|
||||||
|
|
||||||
[Check if audio.volume is set to new value greater than 1.0 that expecting an IndexSizeError exception is to be thrown]
|
[Check if audio.volume is set to new value greater than 1.0 that expecting an IndexSizeError exception is to be thrown]
|
||||||
expected: FAIL
|
expected: PASS
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
type: testharness
|
type: testharness
|
||||||
expected: TIMEOUT
|
expected: TIMEOUT
|
||||||
[setting audio.volume fires volumechange]
|
[setting audio.volume fires volumechange]
|
||||||
expected: FAIL
|
expected: PASS
|
||||||
|
|
||||||
[setting audio.muted fires volumechange]
|
[setting audio.muted fires volumechange]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
@ -14,7 +14,7 @@
|
||||||
expected: TIMEOUT
|
expected: TIMEOUT
|
||||||
|
|
||||||
[setting video.volume fires volumechange]
|
[setting video.volume fires volumechange]
|
||||||
expected: FAIL
|
expected: PASS
|
||||||
|
|
||||||
[setting video.muted fires volumechange]
|
[setting video.muted fires volumechange]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
[pause-remove-from-document.html]
|
[pause-remove-from-document.html]
|
||||||
type: testharness
|
type: testharness
|
||||||
expected: TIMEOUT
|
expected: OK
|
||||||
[paused state when removing from a document]
|
[paused state when removing from a document]
|
||||||
expected: TIMEOUT
|
expected: PASS
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
[video_volume_check.html]
|
[video_volume_check.html]
|
||||||
type: testharness
|
type: testharness
|
||||||
[Check if media.volume is set to new value less than 0.0 that expecting an IndexSizeError exception is to be thrown]
|
[Check if media.volume is set to new value less than 0.0 that expecting an IndexSizeError exception is to be thrown]
|
||||||
expected: FAIL
|
expected: PASS
|
||||||
|
|
||||||
[Check if video.volume is set to new value greater than 1.0 that expecting an IndexSizeError exception is to be thrown]
|
[Check if video.volume is set to new value greater than 1.0 that expecting an IndexSizeError exception is to be thrown]
|
||||||
expected: FAIL
|
expected: PASS
|
||||||
|
|
||||||
|
|
|
@ -1,20 +1,20 @@
|
||||||
[volume_nonfinite.html]
|
[volume_nonfinite.html]
|
||||||
type: testharness
|
type: testharness
|
||||||
[Setting audio.volume to NaN should throw a TypeError]
|
[Setting audio.volume to NaN should throw a TypeError]
|
||||||
expected: FAIL
|
expected: PASS
|
||||||
|
|
||||||
[Setting audio.volume to Infinity should throw a TypeError]
|
[Setting audio.volume to Infinity should throw a TypeError]
|
||||||
expected: FAIL
|
expected: PASS
|
||||||
|
|
||||||
[Setting audio.volume to -Infinity should throw a TypeError]
|
[Setting audio.volume to -Infinity should throw a TypeError]
|
||||||
expected: FAIL
|
expected: PASS
|
||||||
|
|
||||||
[Setting video.volume to NaN should throw a TypeError]
|
[Setting video.volume to NaN should throw a TypeError]
|
||||||
expected: FAIL
|
expected: PASS
|
||||||
|
|
||||||
[Setting video.volume to Infinity should throw a TypeError]
|
[Setting video.volume to Infinity should throw a TypeError]
|
||||||
expected: FAIL
|
expected: PASS
|
||||||
|
|
||||||
[Setting video.volume to -Infinity should throw a TypeError]
|
[Setting video.volume to -Infinity should throw a TypeError]
|
||||||
expected: FAIL
|
expected: PASS
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue