diff options
author | Tetsuharu OHZEKI <saneyuki.s.snyk@gmail.com> | 2013-08-24 01:31:24 +0900 |
---|---|---|
committer | Tetsuharu OHZEKI <saneyuki.s.snyk@gmail.com> | 2013-08-31 20:00:26 +0900 |
commit | a76e46416a6d68f5a3c5b3bb5badff25078f1b94 (patch) | |
tree | a490e51ce319f6206286e3a4e9a6f40a63c3fccc /src | |
parent | d3108a898dd6b5f60263c10fe704d26fc98b05ec (diff) | |
download | servo-a76e46416a6d68f5a3c5b3bb5badff25078f1b94.tar.gz servo-a76e46416a6d68f5a3c5b3bb5badff25078f1b94.zip |
Generate bindings for HTMLMediaElement.
Diffstat (limited to 'src')
-rw-r--r-- | src/components/script/dom/bindings/codegen/Bindings.conf | 1 | ||||
-rw-r--r-- | src/components/script/dom/bindings/codegen/HTMLMediaElement.webidl | 188 | ||||
-rw-r--r-- | src/components/script/dom/bindings/element.rs | 2 | ||||
-rw-r--r-- | src/components/script/dom/bindings/node.rs | 1 | ||||
-rw-r--r-- | src/components/script/dom/element.rs | 1 | ||||
-rw-r--r-- | src/components/script/dom/htmlmediaelement.rs | 142 | ||||
-rw-r--r-- | src/components/script/script.rc | 1 |
7 files changed, 336 insertions, 0 deletions
diff --git a/src/components/script/dom/bindings/codegen/Bindings.conf b/src/components/script/dom/bindings/codegen/Bindings.conf index 39f19bf9df1..9c4ad41d61b 100644 --- a/src/components/script/dom/bindings/codegen/Bindings.conf +++ b/src/components/script/dom/bindings/codegen/Bindings.conf @@ -585,6 +585,7 @@ addHTMLElement('HTMLLegendElement') addHTMLElement('HTMLLIElement') addHTMLElement('HTMLLinkElement') addHTMLElement('HTMLMapElement') +addHTMLElement('HTMLMediaElement') addHTMLElement('HTMLMetaElement') addHTMLElement('HTMLMeterElement') addHTMLElement('HTMLModElement') diff --git a/src/components/script/dom/bindings/codegen/HTMLMediaElement.webidl b/src/components/script/dom/bindings/codegen/HTMLMediaElement.webidl new file mode 100644 index 00000000000..25f03e5111d --- /dev/null +++ b/src/components/script/dom/bindings/codegen/HTMLMediaElement.webidl @@ -0,0 +1,188 @@ +/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. + * + * The origin of this IDL file is + * http://www.whatwg.org/specs/web-apps/current-work/#media-elements + * + * © Copyright 2004-2011 Apple Computer, Inc., Mozilla Foundation, and + * Opera Software ASA. You are granted a license to use, reproduce + * and create derivative works of this document. + */ + +interface HTMLMediaElement : HTMLElement { +/* + // error state + readonly attribute MediaError? error; +*/ + // network state + [SetterThrows] + attribute DOMString src; + readonly attribute DOMString currentSrc; + + [SetterThrows] + attribute DOMString crossOrigin; + const unsigned short NETWORK_EMPTY = 0; + const unsigned short NETWORK_IDLE = 1; + const unsigned short NETWORK_LOADING = 2; + const unsigned short NETWORK_NO_SOURCE = 3; +/* + TODO: + readonly attribute unsigned short networkState; +*/ + [SetterThrows] + attribute DOMString preload; +/* + [Creator] + readonly attribute TimeRanges buffered; +*/ + void load(); + DOMString canPlayType(DOMString type); + + // ready state + const unsigned short HAVE_NOTHING = 0; + const unsigned short HAVE_METADATA = 1; + const unsigned short HAVE_CURRENT_DATA = 2; + const unsigned short HAVE_FUTURE_DATA = 3; + const unsigned short HAVE_ENOUGH_DATA = 4; + readonly attribute unsigned short readyState; + readonly attribute boolean seeking; + + // playback state + [SetterThrows] + attribute double currentTime; + // TODO: Bug 847375 - void fastSeek(double time); +/* + TODO: + readonly attribute unrestricted double duration; +*/ + // TODO: Bug 847376 - readonly attribute any startDate; + readonly attribute boolean paused; + [SetterThrows] + attribute double defaultPlaybackRate; + [SetterThrows] + attribute double playbackRate; +/* + [Creator] + readonly attribute TimeRanges played; + [Creator] + readonly attribute TimeRanges seekable; +*/ + readonly attribute boolean ended; + [SetterThrows] + attribute boolean autoplay; + [SetterThrows] + attribute boolean loop; + [Throws] + void play(); + [Throws] + void pause(); + + // TODO: Bug 847377 - mediaGroup and MediaController + // media controller + // attribute DOMString mediaGroup; + // attribute MediaController? controller; + + // controls + [SetterThrows] + attribute boolean controls; + [SetterThrows] + attribute double volume; + attribute boolean muted; + [SetterThrows] + attribute boolean defaultMuted; + + // TODO: Bug 847379 + // tracks + //readonly attribute AudioTrackList audioTracks; + //readonly attribute VideoTrackList videoTracks; +/* + [Pref="media.webvtt.enabled"] + readonly attribute TextTrackList textTracks; + [Pref="media.webvtt.enabled"] + TextTrack addTextTrack(TextTrackKind kind, + optional DOMString label = "", + optional DOMString language = ""); +*/ +}; + +/* +// Mozilla extensions: +partial interface HTMLMediaElement { + attribute MediaStream? mozSrcObject; + attribute boolean mozPreservesPitch; + readonly attribute boolean mozAutoplayEnabled; + + // Mozilla extension: stream capture + [Throws] + MediaStream mozCaptureStream(); + [Throws] + MediaStream mozCaptureStreamUntilEnded(); + readonly attribute boolean mozAudioCaptured; + + // Mozilla extension: extra stream metadata information, used as part + // of MozAudioAvailable events and the mozWriteAudio() method. The + // mozFrameBufferLength method allows for the size of the framebuffer + // used within MozAudioAvailable events to be changed. The new size must + // be between 512 and 16384. The default size, for a media element with + // audio is (mozChannels * 1024). + [GetterThrows] + readonly attribute unsigned long mozChannels; + [GetterThrows] + readonly attribute unsigned long mozSampleRate; + [Throws] + attribute unsigned long mozFrameBufferLength; + + // Mozilla extension: return embedded metadata from the stream as a + // JSObject with key:value pairs for each tag. This can be used by + // player interfaces to display the song title, artist, etc. + [Throws] + object? mozGetMetadata(); + + // Mozilla extension: provides access to the fragment end time if + // the media element has a fragment URI for the currentSrc, otherwise + // it is equal to the media duration. + readonly attribute double mozFragmentEnd; + + // Mozilla extension: an audio channel type for media elements. + // An exception is thrown if the app tries to change the audio channel type + // without the permission (manifest file for B2G apps). + // The supported values are: + // * normal (default value) + // Automatically paused if "notification" or higher priority channel + // is played + // Use case: normal applications + // * content + // Automatically paused if "notification" or higher priority channel + // is played. Also paused if another app starts using "content" + // channel. Using this channel never affects applications using + // the "normal" channel. + // Use case: video/audio players + // * notification + // Automatically paused if "alarm" or higher priority channel is played. + // Use case: New email, incoming SMS + // * alarm + // Automatically paused if "telephony" or higher priority channel is + // played. + // User case: Alarm clock, calendar alarms + // * telephony + // Automatically paused if "ringer" or higher priority + // channel is played. + // Use case: dialer, voip + // * ringer + // Automatically paused if "publicnotification" or higher priority + // channel is played. + // Use case: dialer, voip + // * publicnotification + // Always plays in speaker, even when headphones are plugged in. + // Use case: Camera shutter sound. + [SetterThrows] + attribute DOMString mozAudioChannelType; + + // In addition the media element has this new events: + // * onmozinterruptbegin - called when the media element is interrupted + // because of the audiochannel manager. + // * onmozinterruptend - called when the interruption is concluded +}; +*/ diff --git a/src/components/script/dom/bindings/element.rs b/src/components/script/dom/bindings/element.rs index 6478f0289dc..af5e8174003 100644 --- a/src/components/script/dom/bindings/element.rs +++ b/src/components/script/dom/bindings/element.rs @@ -102,6 +102,8 @@ generate_cacheable_wrapper!(HTMLLinkElement, HTMLLinkElementBinding::Wrap) generate_binding_object!(HTMLLinkElement) generate_cacheable_wrapper!(HTMLMapElement, HTMLMapElementBinding::Wrap) generate_binding_object!(HTMLMapElement) +generate_cacheable_wrapper!(HTMLMediaElement, HTMLMediaElementBinding::Wrap) +generate_binding_object!(HTMLMediaElement) generate_cacheable_wrapper!(HTMLMetaElement, HTMLMetaElementBinding::Wrap) generate_binding_object!(HTMLMetaElement) generate_cacheable_wrapper!(HTMLMeterElement, HTMLMeterElementBinding::Wrap) diff --git a/src/components/script/dom/bindings/node.rs b/src/components/script/dom/bindings/node.rs index ef76c931ffc..5e45268d2b4 100644 --- a/src/components/script/dom/bindings/node.rs +++ b/src/components/script/dom/bindings/node.rs @@ -54,6 +54,7 @@ pub fn create(cx: *JSContext, node: &mut AbstractNode<ScriptView>) -> *JSObject ElementNodeTypeId(HTMLLIElementTypeId) => generate_element!(HTMLLIElement), ElementNodeTypeId(HTMLLinkElementTypeId) => generate_element!(HTMLLinkElement), ElementNodeTypeId(HTMLMapElementTypeId) => generate_element!(HTMLMapElement), + ElementNodeTypeId(HTMLMediaElementTypeId) => generate_element!(HTMLMediaElement), ElementNodeTypeId(HTMLMetaElementTypeId) => generate_element!(HTMLMetaElement), ElementNodeTypeId(HTMLMeterElementTypeId) => generate_element!(HTMLMeterElement), ElementNodeTypeId(HTMLModElementTypeId) => generate_element!(HTMLModElement), diff --git a/src/components/script/dom/element.rs b/src/components/script/dom/element.rs index 4e66db145a2..59844882af5 100644 --- a/src/components/script/dom/element.rs +++ b/src/components/script/dom/element.rs @@ -78,6 +78,7 @@ pub enum ElementTypeId { HTMLLinkElementTypeId, HTMLLIElementTypeId, HTMLMapElementTypeId, + HTMLMediaElementTypeId, HTMLMetaElementTypeId, HTMLMeterElementTypeId, HTMLModElementTypeId, diff --git a/src/components/script/dom/htmlmediaelement.rs b/src/components/script/dom/htmlmediaelement.rs new file mode 100644 index 00000000000..009940ac926 --- /dev/null +++ b/src/components/script/dom/htmlmediaelement.rs @@ -0,0 +1,142 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +use dom::bindings::utils::{DOMString, null_string, ErrorResult}; +use dom::element::ElementTypeId; +use dom::htmlelement::HTMLElement; + +pub struct HTMLMediaElement { + parent: HTMLElement, +} + +impl HTMLMediaElement { + pub fn new(type_id: ElementTypeId, tag_name: ~str) -> HTMLMediaElement { + HTMLMediaElement { + parent: HTMLElement::new(type_id, tag_name) + } + } +} + +impl HTMLMediaElement { + pub fn Src(&self) -> DOMString { + null_string + } + + pub fn SetSrc(&mut self, _src: &DOMString, _rv: &mut ErrorResult) { + } + + pub fn CurrentSrc(&self) -> DOMString { + null_string + } + + pub fn CrossOrigin(&self) -> DOMString { + null_string + } + + pub fn SetCrossOrigin(&mut self, _cross_origin: &DOMString, _rv: &mut ErrorResult) { + } + + pub fn Preload(&self) -> DOMString { + null_string + } + + pub fn SetPreload(&mut self, _preload: &DOMString, _rv: &mut ErrorResult) { + } + + pub fn Load(&self) { + } + + pub fn CanPlayType(&self, _type: &DOMString) -> DOMString { + null_string + } + + pub fn ReadyState(&self) -> u16 { + 0 + } + + pub fn Seeking(&self) -> bool { + false + } + + pub fn CurrentTime(&self) -> f64 { + 0f64 + } + + pub fn SetCurrentTime(&mut self, _current_time: f64, _rv: &mut ErrorResult) { + } + + pub fn GetDuration(&self) -> f64 { + 0f64 + } + + pub fn Paused(&self) -> bool { + false + } + + pub fn DefaultPlaybackRate(&self) -> f64 { + 0f64 + } + + pub fn SetDefaultPlaybackRate(&mut self, _default_playback_rate: f64, _rv: &mut ErrorResult) { + } + + pub fn PlaybackRate(&self) -> f64 { + 0f64 + } + + pub fn SetPlaybackRate(&mut self, _playback_rate: f64, _rv: &mut ErrorResult) { + } + + pub fn Ended(&self) -> bool { + false + } + + pub fn Autoplay(&self) -> bool { + false + } + + pub fn SetAutoplay(&mut self, _autoplay: bool, _rv: &mut ErrorResult) { + } + + pub fn Loop(&self) -> bool { + false + } + + pub fn SetLoop(&mut self, _loop: bool, _rv: &mut ErrorResult) { + } + + pub fn Play(&self, _rv: &mut ErrorResult) { + } + + pub fn Pause(&self, _rv: &mut ErrorResult) { + } + + pub fn Controls(&self) -> bool { + false + } + + pub fn SetControls(&mut self, _controls: bool, _rv: &mut ErrorResult) { + } + + pub fn Volume(&self) -> f64 { + 0f64 + } + + pub fn SetVolume(&mut self, _volume: f64, _rv: &mut ErrorResult) { + } + + pub fn Muted(&self) -> bool { + false + } + + pub fn SetMuted(&mut self, _muted: bool) { + } + + pub fn DefaultMuted(&self) -> bool { + false + } + + pub fn SetDefaultMuted(&mut self, _default_muted: bool, _rv: &mut ErrorResult) { + } +} diff --git a/src/components/script/script.rc b/src/components/script/script.rc index 4e8f78d974f..a08a354390c 100644 --- a/src/components/script/script.rc +++ b/src/components/script/script.rc @@ -89,6 +89,7 @@ pub mod dom { pub mod htmllielement; pub mod htmllinkelement; pub mod htmlmapelement; + pub mod htmlmediaelement; pub mod htmlmetaelement; pub mod htmlmeterelement; pub mod htmlmodelement; |