From f2add7f0a7f1e560d3cf54a41a4f1f6c6311bb22 Mon Sep 17 00:00:00 2001 From: Rick Eyre Date: Wed, 19 Mar 2014 11:27:39 -0400 Subject: [PATCH] Bug 891381 - Tracks loaded via TrackElement should have the same id as the TrackElement. r=cpearce --- content/media/TextTrack.cpp | 10 ++++++++++ content/media/TextTrack.h | 6 +----- content/media/test/test_texttrack.html | 9 +++++---- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/content/media/TextTrack.cpp b/content/media/TextTrack.cpp index 912f0d536db..42d12a945cd 100644 --- a/content/media/TextTrack.cpp +++ b/content/media/TextTrack.cpp @@ -95,6 +95,16 @@ TextTrack::SetMode(TextTrackMode aValue) } } +void +TextTrack::GetId(nsAString& aId) const +{ + // If the track has a track element then its id should be the same as the + // track element's id. + if (mTrackElement) { + mTrackElement->GetAttribute(NS_LITERAL_STRING("id"), aId); + } +} + void TextTrack::AddCue(TextTrackCue& aCue) { diff --git a/content/media/TextTrack.h b/content/media/TextTrack.h index 9dc893ebbff..efbb4501a4b 100644 --- a/content/media/TextTrack.h +++ b/content/media/TextTrack.h @@ -84,10 +84,7 @@ public: { aType = mType; } - void GetId(nsAString& aId) const - { - aId = mId; - } + void GetId(nsAString& aId) const; TextTrackMode Mode() const { @@ -134,7 +131,6 @@ private: nsString mLabel; nsString mLanguage; nsString mType; - nsString mId; TextTrackMode mMode; nsRefPtr mCueList; diff --git a/content/media/test/test_texttrack.html b/content/media/test/test_texttrack.html index 988aa91cb03..74bef3d4309 100644 --- a/content/media/test/test_texttrack.html +++ b/content/media/test/test_texttrack.html @@ -67,6 +67,7 @@ SpecialPowers.pushPrefEnv({"set": [["media.webvtt.enabled", true], trackOne.label = "first"; trackOne.src = "basic.vtt"; trackOne.default = true; + trackOne.id = "2"; video.appendChild(trackOne); video.addTextTrack("subtitles", "fourth", "en-CA"); @@ -102,10 +103,10 @@ SpecialPowers.pushPrefEnv({"set": [["media.webvtt.enabled", true], // method, will occupy the last two indexes in the order that they were // added in. var trackData = [ - { label: "first", mode: "showing" }, - { label: "second", mode: "disabled" }, - { label: "third", mode: "hidden" }, - { label: "fourth", mode: "hidden"} + { label: "first", mode: "showing", id: "2" }, + { label: "second", mode: "disabled", id: "" }, + { label: "third", mode: "hidden", id: "" }, + { label: "fourth", mode: "hidden", id: "" } ]; is(video.textTracks.length, trackData.length, "TextTracks length should be " + trackData.length); for (var i = 0; i < trackData.length; i++) {