Auto merge of #22966 - Goncalerta:22962, r=jdm

Simplify VideoTrackList::set_selected

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: -->
- [ ] `./mach build -d` does not report any errors
- [ ] `./mach test-tidy` does not report any errors
- [x] These changes fix #22962 (GitHub issue number if applicable)
- [x] These changes do not require tests because just refactors existing code

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/22966)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2019-03-11 11:21:10 -04:00 committed by GitHub
commit 6890347cd5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -76,39 +76,18 @@ impl VideoTrackList {
.media_element_task_source_with_canceller(); .media_element_task_source_with_canceller();
if let Some(current) = self.selected_index() { if let Some(current) = self.selected_index() {
if current != idx { self.tracks.borrow()[current].set_selected(false);
self.tracks.borrow()[current].set_selected(false);
track.set_selected(true);
let _ = source.queue_with_canceller(
task!(media_track_change: move || {
let this = this.root();
this.upcast::<EventTarget>().fire_event(atom!("change"));
}),
&canceller,
);
} else {
self.tracks.borrow()[current].set_selected(false);
let _ = source.queue_with_canceller(
task!(media_track_change: move || {
let this = this.root();
this.upcast::<EventTarget>().fire_event(atom!("change"));
}),
&canceller,
);
}
} else {
track.set_selected(true);
let _ = source.queue_with_canceller(
task!(media_track_change: move || {
let this = this.root();
this.upcast::<EventTarget>().fire_event(atom!("change"));
}),
&canceller,
);
} }
track.set_selected(value);
let _ = source.queue_with_canceller(
task!(media_track_change: move || {
let this = this.root();
this.upcast::<EventTarget>().fire_event(atom!("change"));
}),
&canceller,
);
} }
pub fn add(&self, track: &VideoTrack) { pub fn add(&self, track: &VideoTrack) {