mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
Add stubs for src and currentSrc for HTMLMediaElement.
This commit is contained in:
parent
b8b4be34c0
commit
53f9307fb7
5 changed files with 45 additions and 344 deletions
|
@ -2,10 +2,15 @@
|
|||
* 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::attr::Attr;
|
||||
use dom::bindings::cell::DOMRefCell;
|
||||
use dom::bindings::codegen::Bindings::HTMLMediaElementBinding::HTMLMediaElementMethods;
|
||||
use dom::bindings::codegen::Bindings::HTMLMediaElementBinding::HTMLMediaElementConstants;
|
||||
use dom::bindings::inheritance::Castable;
|
||||
use dom::document::Document;
|
||||
use dom::element::AttributeMutation;
|
||||
use dom::htmlelement::HTMLElement;
|
||||
use dom::virtualmethods::VirtualMethods;
|
||||
use std::cell::Cell;
|
||||
use string_cache::Atom;
|
||||
use util::str::DOMString;
|
||||
|
@ -15,6 +20,7 @@ pub struct HTMLMediaElement {
|
|||
htmlelement: HTMLElement,
|
||||
network_state: Cell<u16>,
|
||||
ready_state: Cell<u16>,
|
||||
current_src: DOMRefCell<String>,
|
||||
}
|
||||
|
||||
impl HTMLMediaElement {
|
||||
|
@ -26,6 +32,7 @@ impl HTMLMediaElement {
|
|||
HTMLElement::new_inherited(tag_name, prefix, document),
|
||||
network_state: Cell::new(HTMLMediaElementConstants::NETWORK_EMPTY),
|
||||
ready_state: Cell::new(HTMLMediaElementConstants::HAVE_NOTHING),
|
||||
current_src: DOMRefCell::new("".to_owned()),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -33,6 +40,9 @@ impl HTMLMediaElement {
|
|||
pub fn htmlelement(&self) -> &HTMLElement {
|
||||
&self.htmlelement
|
||||
}
|
||||
|
||||
fn media_element_load_algorithm(&self, _src: &str) {
|
||||
}
|
||||
}
|
||||
|
||||
impl HTMLMediaElementMethods for HTMLMediaElement {
|
||||
|
@ -43,4 +53,33 @@ impl HTMLMediaElementMethods for HTMLMediaElement {
|
|||
fn ReadyState(&self) -> u16 {
|
||||
self.ready_state.get()
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#dom-media-src
|
||||
make_url_getter!(Src, "src");
|
||||
// https://html.spec.whatwg.org/multipage/#dom-media-src
|
||||
make_setter!(SetSrc, "src");
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#dom-media-currentsrc
|
||||
fn CurrentSrc(&self) -> DOMString {
|
||||
DOMString::from(self.current_src.borrow().clone())
|
||||
}
|
||||
}
|
||||
|
||||
impl VirtualMethods for HTMLMediaElement {
|
||||
fn super_type(&self) -> Option<&VirtualMethods> {
|
||||
Some(self.upcast::<HTMLElement>() as &VirtualMethods)
|
||||
}
|
||||
|
||||
fn attribute_mutated(&self, attr: &Attr, mutation: AttributeMutation) {
|
||||
self.super_type().unwrap().attribute_mutated(attr, mutation);
|
||||
|
||||
match attr.local_name() {
|
||||
&atom!("src") => {
|
||||
if let Some(value) = mutation.new_value(attr) {
|
||||
self.media_element_load_algorithm(&value);
|
||||
}
|
||||
}
|
||||
_ => (),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,6 +29,7 @@ use dom::htmlimageelement::HTMLImageElement;
|
|||
use dom::htmlinputelement::HTMLInputElement;
|
||||
use dom::htmllabelelement::HTMLLabelElement;
|
||||
use dom::htmllinkelement::HTMLLinkElement;
|
||||
use dom::htmlmediaelement::HTMLMediaElement;
|
||||
use dom::htmlmetaelement::HTMLMetaElement;
|
||||
use dom::htmlobjectelement::HTMLObjectElement;
|
||||
use dom::htmloptgroupelement::HTMLOptGroupElement;
|
||||
|
@ -181,6 +182,9 @@ pub fn vtable_for(node: &Node) -> &VirtualMethods {
|
|||
NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLLinkElement)) => {
|
||||
node.downcast::<HTMLLinkElement>().unwrap() as &VirtualMethods
|
||||
}
|
||||
NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLMediaElement(_))) => {
|
||||
node.downcast::<HTMLMediaElement>().unwrap() as &VirtualMethods
|
||||
}
|
||||
NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLMetaElement)) => {
|
||||
node.downcast::<HTMLMetaElement>().unwrap() as &VirtualMethods
|
||||
}
|
||||
|
|
|
@ -11,8 +11,8 @@ interface HTMLMediaElement : HTMLElement {
|
|||
//readonly attribute MediaError? error;
|
||||
|
||||
// network state
|
||||
// attribute DOMString src;
|
||||
//readonly attribute DOMString currentSrc;
|
||||
attribute DOMString src;
|
||||
readonly attribute DOMString currentSrc;
|
||||
// attribute DOMString crossOrigin;
|
||||
const unsigned short NETWORK_EMPTY = 0;
|
||||
const unsigned short NETWORK_IDLE = 1;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue