diff options
author | bors-servo <lbergstrom+bors@mozilla.com> | 2020-01-02 21:34:24 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-01-02 21:34:24 -0500 |
commit | d47f0ad1f672c7f1543eb753fc87c6acdf9f16e8 (patch) | |
tree | 1f268254b8b9657faa2f4b1d9b899e45401d0478 /components/script/dom/texttrack.rs | |
parent | 097a91112e5e83775b589e74c8412f0c37a07f75 (diff) | |
parent | 9b59b9602cdf41a77b8cf111b680c034638a06c0 (diff) | |
download | servo-d47f0ad1f672c7f1543eb753fc87c6acdf9f16e8.tar.gz servo-d47f0ad1f672c7f1543eb753fc87c6acdf9f16e8.zip |
Auto merge of #25364 - kunalmohan:22912-MediaTracks, r=jdm
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.
r?@jdm
<!-- Please describe your changes on the following line: -->
---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] These changes fix #22912 (GitHub issue number if applicable)
<!-- Either: -->
- [X] There are tests for these changes
<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->
<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
Diffstat (limited to 'components/script/dom/texttrack.rs')
-rw-r--r-- | components/script/dom/texttrack.rs | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/components/script/dom/texttrack.rs b/components/script/dom/texttrack.rs index 88c4859e05e..7c2b54adcd9 100644 --- a/components/script/dom/texttrack.rs +++ b/components/script/dom/texttrack.rs @@ -2,16 +2,18 @@ * 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::cell::DomRefCell; use crate::dom::bindings::codegen::Bindings::TextTrackBinding::{ self, TextTrackKind, TextTrackMethods, TextTrackMode, }; use crate::dom::bindings::error::{Error, ErrorResult}; use crate::dom::bindings::reflector::{reflect_dom_object, DomObject}; -use crate::dom::bindings::root::{DomRoot, MutNullableDom}; +use crate::dom::bindings::root::{Dom, DomRoot, MutNullableDom}; use crate::dom::bindings::str::DOMString; use crate::dom::eventtarget::EventTarget; use crate::dom::texttrackcue::TextTrackCue; use crate::dom::texttrackcuelist::TextTrackCueList; +use crate::dom::texttracklist::TextTrackList; use crate::dom::window::Window; use dom_struct::dom_struct; use std::cell::Cell; @@ -25,6 +27,7 @@ pub struct TextTrack { id: String, mode: Cell<TextTrackMode>, cue_list: MutNullableDom<TextTrackCueList>, + track_list: DomRefCell<Option<Dom<TextTrackList>>>, } impl TextTrack { @@ -34,6 +37,7 @@ impl TextTrack { label: DOMString, language: DOMString, mode: TextTrackMode, + track_list: Option<&TextTrackList>, ) -> TextTrack { TextTrack { eventtarget: EventTarget::new_inherited(), @@ -43,6 +47,7 @@ impl TextTrack { id: id.into(), mode: Cell::new(mode), cue_list: Default::default(), + track_list: DomRefCell::new(track_list.map(|t| Dom::from_ref(t))), } } @@ -53,9 +58,12 @@ impl TextTrack { label: DOMString, language: DOMString, mode: TextTrackMode, + track_list: Option<&TextTrackList>, ) -> DomRoot<TextTrack> { reflect_dom_object( - Box::new(TextTrack::new_inherited(id, kind, label, language, mode)), + Box::new(TextTrack::new_inherited( + id, kind, label, language, mode, track_list, + )), window, TextTrackBinding::Wrap, ) @@ -69,6 +77,14 @@ impl TextTrack { pub fn id(&self) -> &str { &self.id } + + pub fn add_track_list(&self, track_list: &TextTrackList) { + *self.track_list.borrow_mut() = Some(Dom::from_ref(track_list)); + } + + pub fn remove_track_list(&self) { + *self.track_list.borrow_mut() = None; + } } impl TextTrackMethods for TextTrack { |