aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/audiotrack.rs
diff options
context:
space:
mode:
authorKunal Mohan <kunalmohan99@gmail.com>2019-12-22 21:00:10 +0530
committerKunal Mohan <kunalmohan99@gmail.com>2019-12-23 01:06:58 +0530
commit9b59b9602cdf41a77b8cf111b680c034638a06c0 (patch)
tree4fc75eed115f8cd9916e3452655fe0dfc47f1d9b /components/script/dom/audiotrack.rs
parent43a5f65940f85a30ba3f7fb9cbb96b194cde81b6 (diff)
downloadservo-9b59b9602cdf41a77b8cf111b680c034638a06c0.tar.gz
servo-9b59b9602cdf41a77b8cf111b680c034638a06c0.zip
Add `track_list` member to AudioTrack, VideoTrack, TextTrack structs
Add member to the track structs pointing at their associated tracklist and update it when the track is added or removed from a tracklist.
Diffstat (limited to 'components/script/dom/audiotrack.rs')
-rw-r--r--components/script/dom/audiotrack.rs15
1 files changed, 12 insertions, 3 deletions
diff --git a/components/script/dom/audiotrack.rs b/components/script/dom/audiotrack.rs
index b66ea5bf4cc..af237bc8b1a 100644
--- a/components/script/dom/audiotrack.rs
+++ b/components/script/dom/audiotrack.rs
@@ -3,6 +3,7 @@
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
use crate::dom::audiotracklist::AudioTrackList;
+use crate::dom::bindings::cell::DomRefCell;
use crate::dom::bindings::codegen::Bindings::AudioTrackBinding::{self, AudioTrackMethods};
use crate::dom::bindings::reflector::{reflect_dom_object, Reflector};
use crate::dom::bindings::root::{Dom, DomRoot};
@@ -19,7 +20,7 @@ pub struct AudioTrack {
label: DOMString,
language: DOMString,
enabled: Cell<bool>,
- track_list: Option<Dom<AudioTrackList>>,
+ track_list: DomRefCell<Option<Dom<AudioTrackList>>>,
}
impl AudioTrack {
@@ -37,7 +38,7 @@ impl AudioTrack {
label: label.into(),
language: language.into(),
enabled: Cell::new(false),
- track_list: track_list.map(|t| Dom::from_ref(t)),
+ track_list: DomRefCell::new(track_list.map(|t| Dom::from_ref(t))),
}
}
@@ -73,6 +74,14 @@ impl AudioTrack {
pub fn set_enabled(&self, value: bool) {
self.enabled.set(value);
}
+
+ pub fn add_track_list(&self, track_list: &AudioTrackList) {
+ *self.track_list.borrow_mut() = Some(Dom::from_ref(track_list));
+ }
+
+ pub fn remove_track_list(&self) {
+ *self.track_list.borrow_mut() = None;
+ }
}
impl AudioTrackMethods for AudioTrack {
@@ -103,7 +112,7 @@ impl AudioTrackMethods for AudioTrack {
// https://html.spec.whatwg.org/multipage/#dom-audiotrack-enabled
fn SetEnabled(&self, value: bool) {
- if let Some(list) = self.track_list.as_ref() {
+ if let Some(list) = self.track_list.borrow().as_ref() {
if let Some(idx) = list.find(self) {
list.set_enabled(idx, value);
}