diff --git a/Cargo.lock b/Cargo.lock index b6cf6d284d5..636458f21ba 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1698,7 +1698,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", "mac 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "markup5ever 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", + "markup5ever 0.7.5 (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)", "syn 0.15.22 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2305,7 +2305,7 @@ dependencies = [ [[package]] name = "markup5ever" -version = "0.7.1" +version = "0.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "phf 0.7.23 (registry+https://github.com/rust-lang/crates.io-index)", @@ -4798,7 +4798,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", "mac 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "markup5ever 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", + "markup5ever 0.7.5 (registry+https://github.com/rust-lang/crates.io-index)", "time 0.1.37 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -5011,7 +5011,7 @@ dependencies = [ "checksum mac 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c41e0c4fef86961ac6d6f8a82609f55f31b05e4fce149ac5710e439df7619ba4" "checksum mach 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "86dd2487cdfea56def77b88438a2c915fb45113c5319bfe7e14306ca4cd0b0e1" "checksum malloc_buf 0.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "62bb907fe88d54d8d9ce32a3cceab4218ed2f6b7d35617cafe9adf84e43919cb" -"checksum markup5ever 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c220b3a3d75543b76e5c1fcab6635a8430ab5f9bfa011d003c3787ae0abf4ffa" +"checksum markup5ever 0.7.5 (registry+https://github.com/rust-lang/crates.io-index)" = "897636f9850c3eef4905a5540683ed53dc9393860f0846cab2c2ddf9939862ff" "checksum matches 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "efd7622e3022e1a6eaa602c4cea8912254e5582c9c692e9167714182244801b1" "checksum memchr 2.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0a3eb002f0535929f1199681417029ebea04aadc0c7a4224b46be99c7f5d6a16" "checksum memmap 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e2ffa2c986de11a9df78620c01eeaaf27d94d3ff02bf81bfcca953102dd0c6ff" diff --git a/components/atoms/static_atoms.txt b/components/atoms/static_atoms.txt index ebe3e890145..a20aa11c816 100644 --- a/components/atoms/static_atoms.txt +++ b/components/atoms/static_atoms.txt @@ -40,6 +40,7 @@ input invalid keydown keypress +kind left ltr load @@ -89,6 +90,7 @@ seeked seeking select serif +srclang statechange storage submit diff --git a/components/script/dom/htmltrackelement.rs b/components/script/dom/htmltrackelement.rs index 53893215101..caa8932b415 100644 --- a/components/script/dom/htmltrackelement.rs +++ b/components/script/dom/htmltrackelement.rs @@ -2,17 +2,35 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ -use crate::dom::bindings::codegen::Bindings::HTMLTrackElementBinding; -use crate::dom::bindings::root::DomRoot; +use crate::dom::bindings::codegen::Bindings::HTMLTrackElementBinding::{ + self, HTMLTrackElementConstants, HTMLTrackElementMethods, +}; +use crate::dom::bindings::inheritance::Castable; +use crate::dom::bindings::root::{Dom, DomRoot}; +use crate::dom::bindings::str::{DOMString, USVString}; use crate::dom::document::Document; +use crate::dom::element::Element; use crate::dom::htmlelement::HTMLElement; use crate::dom::node::Node; +use crate::dom::texttrack::TextTrack; use dom_struct::dom_struct; use html5ever::{LocalName, Prefix}; +#[derive(Clone, Copy, JSTraceable, MallocSizeOf, PartialEq)] +#[repr(u16)] +#[allow(unused)] +pub enum ReadyState { + None = HTMLTrackElementConstants::NONE, + Loading = HTMLTrackElementConstants::LOADING, + Loaded = HTMLTrackElementConstants::LOADED, + Error = HTMLTrackElementConstants::ERROR, +} + #[dom_struct] pub struct HTMLTrackElement { htmlelement: HTMLElement, + ready_state: ReadyState, + track: Dom, } impl HTMLTrackElement { @@ -20,24 +38,98 @@ impl HTMLTrackElement { local_name: LocalName, prefix: Option, document: &Document, + track: &TextTrack, ) -> HTMLTrackElement { HTMLTrackElement { htmlelement: HTMLElement::new_inherited(local_name, prefix, document), + ready_state: ReadyState::None, + track: Dom::from_ref(&track), } } - #[allow(unrooted_must_root)] pub fn new( local_name: LocalName, prefix: Option, document: &Document, ) -> DomRoot { + let track = TextTrack::new( + &document.window(), + Default::default(), + Default::default(), + Default::default(), + Default::default(), + Default::default(), + ); Node::reflect_node( Box::new(HTMLTrackElement::new_inherited( - local_name, prefix, document, + local_name, prefix, document, &track, )), document, HTMLTrackElementBinding::Wrap, ) } } + +impl HTMLTrackElementMethods for HTMLTrackElement { + // https://html.spec.whatwg.org/multipage/#dom-track-kind + fn Kind(&self) -> DOMString { + let element = self.upcast::(); + // Get the value of "kind" and transform all uppercase + // chars into lowercase. + let kind = element + .get_string_attribute(&local_name!("kind")) + .to_lowercase(); + match &*kind { + "subtitles" | "captions" | "descriptions" | "chapters" | "metadata" => { + // The value of "kind" is valid. Return the lowercase version + // of it. + DOMString::from(kind) + }, + _ if kind.is_empty() => { + // The default value should be "subtitles". If "kind" has not + // been set, the real value for "kind" is "subtitles" + DOMString::from("subtitles") + }, + _ => { + // If "kind" has been set but it is not one of the valid + // values, return the default invalid value of "metadata" + DOMString::from("metadata") + }, + } + } + + // https://html.spec.whatwg.org/multipage/#dom-track-kind + // Do no transformations on the value of "kind" when setting it. + // All transformations should be done in the get method. + make_setter!(SetKind, "kind"); + + // https://html.spec.whatwg.org/multipage/#dom-track-src + make_url_getter!(Src, "src"); + // https://html.spec.whatwg.org/multipage/#dom-track-src + make_url_setter!(SetSrc, "src"); + + // https://html.spec.whatwg.org/multipage/#dom-track-srclang + make_getter!(Srclang, "srclang"); + // https://html.spec.whatwg.org/multipage/#dom-track-srclang + make_setter!(SetSrclang, "srclang"); + + // https://html.spec.whatwg.org/multipage/#dom-track-label + make_getter!(Label, "label"); + // https://html.spec.whatwg.org/multipage/#dom-track-label + make_setter!(SetLabel, "label"); + + // https://html.spec.whatwg.org/multipage/#dom-track-default + make_bool_getter!(Default, "default"); + // https://html.spec.whatwg.org/multipage/#dom-track-default + make_bool_setter!(SetDefault, "default"); + + // https://html.spec.whatwg.org/multipage/#dom-track-readystate + fn ReadyState(&self) -> u16 { + self.ready_state as u16 + } + + // https://html.spec.whatwg.org/multipage/#dom-track-track + fn Track(&self) -> DomRoot { + DomRoot::from_ref(&*self.track) + } +} diff --git a/components/script/dom/webidls/HTMLTrackElement.webidl b/components/script/dom/webidls/HTMLTrackElement.webidl index e15f29c8426..c86c745deee 100644 --- a/components/script/dom/webidls/HTMLTrackElement.webidl +++ b/components/script/dom/webidls/HTMLTrackElement.webidl @@ -5,22 +5,22 @@ // https://html.spec.whatwg.org/multipage/#htmltrackelement [HTMLConstructor] interface HTMLTrackElement : HTMLElement { - // [CEReactions] - // attribute DOMString kind; - // [CEReactions] - // attribute DOMString src; - // [CEReactions] - // attribute DOMString srclang; - // [CEReactions] - // attribute DOMString label; - // [CEReactions] - // attribute boolean default; + [CEReactions] + attribute DOMString kind; + [CEReactions] + attribute USVString src; + [CEReactions] + attribute DOMString srclang; + [CEReactions] + attribute DOMString label; + [CEReactions] + attribute boolean default; - // const unsigned short NONE = 0; - // const unsigned short LOADING = 1; - // const unsigned short LOADED = 2; - // const unsigned short ERROR = 3; - // readonly attribute unsigned short readyState; + const unsigned short NONE = 0; + const unsigned short LOADING = 1; + const unsigned short LOADED = 2; + const unsigned short ERROR = 3; + readonly attribute unsigned short readyState; - // readonly attribute TextTrack track; + readonly attribute TextTrack track; }; diff --git a/tests/wpt/metadata/html/dom/interfaces.https.html.ini b/tests/wpt/metadata/html/dom/interfaces.https.html.ini index 18d6ddab4c4..a57d52ae950 100644 --- a/tests/wpt/metadata/html/dom/interfaces.https.html.ini +++ b/tests/wpt/metadata/html/dom/interfaces.https.html.ini @@ -6897,84 +6897,6 @@ [HTMLMediaElement interface: new Audio() must inherit property "videoTracks" with the proper type] expected: FAIL - [HTMLTrackElement interface: attribute kind] - expected: FAIL - - [HTMLTrackElement interface: attribute src] - expected: FAIL - - [HTMLTrackElement interface: attribute srclang] - expected: FAIL - - [HTMLTrackElement interface: attribute label] - expected: FAIL - - [HTMLTrackElement interface: attribute default] - expected: FAIL - - [HTMLTrackElement interface: constant NONE on interface object] - expected: FAIL - - [HTMLTrackElement interface: constant NONE on interface prototype object] - expected: FAIL - - [HTMLTrackElement interface: constant LOADING on interface object] - expected: FAIL - - [HTMLTrackElement interface: constant LOADING on interface prototype object] - expected: FAIL - - [HTMLTrackElement interface: constant LOADED on interface object] - expected: FAIL - - [HTMLTrackElement interface: constant LOADED on interface prototype object] - expected: FAIL - - [HTMLTrackElement interface: constant ERROR on interface object] - expected: FAIL - - [HTMLTrackElement interface: constant ERROR on interface prototype object] - expected: FAIL - - [HTMLTrackElement interface: attribute readyState] - expected: FAIL - - [HTMLTrackElement interface: attribute track] - expected: FAIL - - [HTMLTrackElement interface: document.createElement("track") must inherit property "kind" with the proper type] - expected: FAIL - - [HTMLTrackElement interface: document.createElement("track") must inherit property "src" with the proper type] - expected: FAIL - - [HTMLTrackElement interface: document.createElement("track") must inherit property "srclang" with the proper type] - expected: FAIL - - [HTMLTrackElement interface: document.createElement("track") must inherit property "label" with the proper type] - expected: FAIL - - [HTMLTrackElement interface: document.createElement("track") must inherit property "default" with the proper type] - expected: FAIL - - [HTMLTrackElement interface: document.createElement("track") must inherit property "NONE" with the proper type] - expected: FAIL - - [HTMLTrackElement interface: document.createElement("track") must inherit property "LOADING" with the proper type] - expected: FAIL - - [HTMLTrackElement interface: document.createElement("track") must inherit property "LOADED" with the proper type] - expected: FAIL - - [HTMLTrackElement interface: document.createElement("track") must inherit property "ERROR" with the proper type] - expected: FAIL - - [HTMLTrackElement interface: document.createElement("track") must inherit property "readyState" with the proper type] - expected: FAIL - - [HTMLTrackElement interface: document.createElement("track") must inherit property "track" with the proper type] - expected: FAIL - [HTMLMediaElement interface: attribute crossOrigin] expected: FAIL @@ -9659,51 +9581,12 @@ [TextTrack interface: attribute activeCues] expected: FAIL - [TextTrack must be primary interface of document.createElement("track").track] - expected: FAIL - - [Stringification of document.createElement("track").track] - expected: FAIL - - [TextTrack interface: document.createElement("track").track must inherit property "kind" with the proper type] - expected: FAIL - - [TextTrack interface: document.createElement("track").track must inherit property "label" with the proper type] - expected: FAIL - - [TextTrack interface: document.createElement("track").track must inherit property "language" with the proper type] - expected: FAIL - - [TextTrack interface: document.createElement("track").track must inherit property "id" with the proper type] - expected: FAIL - [TextTrack interface: document.createElement("track").track must inherit property "inBandMetadataTrackDispatchType" with the proper type] expected: FAIL - [TextTrack interface: document.createElement("track").track must inherit property "mode" with the proper type] - expected: FAIL - - [TextTrack interface: document.createElement("track").track must inherit property "cues" with the proper type] - expected: FAIL - [TextTrack interface: document.createElement("track").track must inherit property "activeCues" with the proper type] expected: FAIL - [TextTrack interface: document.createElement("track").track must inherit property "addCue(TextTrackCue)" with the proper type] - expected: FAIL - - [TextTrack interface: calling addCue(TextTrackCue) on document.createElement("track").track with too few arguments must throw TypeError] - expected: FAIL - - [TextTrack interface: document.createElement("track").track must inherit property "removeCue(TextTrackCue)" with the proper type] - expected: FAIL - - [TextTrack interface: calling removeCue(TextTrackCue) on document.createElement("track").track with too few arguments must throw TypeError] - expected: FAIL - - [TextTrack interface: document.createElement("track").track must inherit property "oncuechange" with the proper type] - expected: FAIL - [TimeRanges must be primary interface of document.createElement("video").buffered] expected: FAIL diff --git a/tests/wpt/metadata/html/infrastructure/urls/dynamic-changes-to-base-urls/dynamic-urls.sub.html.ini b/tests/wpt/metadata/html/infrastructure/urls/dynamic-changes-to-base-urls/dynamic-urls.sub.html.ini index 2ea46b64a2a..292ce2f49a6 100644 --- a/tests/wpt/metadata/html/infrastructure/urls/dynamic-changes-to-base-urls/dynamic-urls.sub.html.ini +++ b/tests/wpt/metadata/html/infrastructure/urls/dynamic-changes-to-base-urls/dynamic-urls.sub.html.ini @@ -5,9 +5,6 @@ [The 'href' attribute of the 'area' element] expected: FAIL - [The 'src' attribute of the 'track' element] - expected: FAIL - [The 'cite' attribute of the 'q' element] expected: FAIL diff --git a/tests/wpt/metadata/html/infrastructure/urls/dynamic-changes-to-base-urls/historical.sub.xhtml.ini b/tests/wpt/metadata/html/infrastructure/urls/dynamic-changes-to-base-urls/historical.sub.xhtml.ini index 2e2bed9d6dc..48923797328 100644 --- a/tests/wpt/metadata/html/infrastructure/urls/dynamic-changes-to-base-urls/historical.sub.xhtml.ini +++ b/tests/wpt/metadata/html/infrastructure/urls/dynamic-changes-to-base-urls/historical.sub.xhtml.ini @@ -5,9 +5,6 @@ [The 'href' attribute of the 'area' element] expected: FAIL - [The 'src' attribute of the 'track' element] - expected: FAIL - [The 'cite' attribute of the 'q' element] expected: FAIL diff --git a/tests/wpt/metadata/html/semantics/embedded-content/media-elements/autoplay-with-broken-track.html.ini b/tests/wpt/metadata/html/semantics/embedded-content/media-elements/autoplay-with-broken-track.html.ini index 682f787961f..28ebc56f4dc 100644 --- a/tests/wpt/metadata/html/semantics/embedded-content/media-elements/autoplay-with-broken-track.html.ini +++ b/tests/wpt/metadata/html/semantics/embedded-content/media-elements/autoplay-with-broken-track.html.ini @@ -3,3 +3,11 @@ [