Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(51)

Side by Side Diff: Source/core/html/track/VideoTrackList.cpp

Issue 170233009: Initial implementation of AudioTrack, AudioTrackList, VideoTrack, and VideoTrackList. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@blink-master
Patch Set: Rebase Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "config.h"
6 #include "core/html/track/VideoTrackList.h"
7
8 #include "core/html/HTMLMediaElement.h"
9 #include "core/html/track/VideoTrack.h"
10
11 namespace WebCore {
12
13 PassRefPtrWillBeRawPtr<VideoTrackList> VideoTrackList::create(HTMLMediaElement* mediaElement)
14 {
15 RefPtrWillBeRawPtr<VideoTrackList> trackList(adoptRefWillBeRefCountedGarbage Collected(new VideoTrackList(mediaElement)));
sof 2014/03/13 12:19:20 Switch to RefPtr and adoptRef()
acolwell GONE FROM CHROMIUM 2014/03/18 22:02:15 Done.
16 trackList->suspendIfNeeded();
17 return trackList.release();
18 }
19
20 VideoTrackList::~VideoTrackList()
21 {
22 }
23
24 VideoTrackList::VideoTrackList(HTMLMediaElement* mediaElement)
25 : TrackBaseList(mediaElement)
26 , m_selectedIndex(-1)
27 {
28 ScriptWrappable::init(this);
29 }
30
31 VideoTrack* VideoTrackList::anonymousIndexedGetter(unsigned index) const
32 {
33 return static_cast<VideoTrack*>(getByIndex(index));
34 }
35
36 VideoTrack* VideoTrackList::getTrackById(const AtomicString& id) const
37 {
38 return static_cast<VideoTrack*>(getById(id));
39 }
40
41 const AtomicString& VideoTrackList::interfaceName() const
42 {
43 return EventTargetNames::VideoTrackList;
44 }
45
46 void VideoTrackList::trackSelected(const AtomicString& selectedTrackID)
47 {
48
philipj_slow 2014/03/13 10:00:04 remove blank line
acolwell GONE FROM CHROMIUM 2014/03/18 22:02:15 Done.
49 bool scheduleEvent = false;
50 if (m_selectedIndex != -1) {
51 VideoTrack* oldTrack = anonymousIndexedGetter(m_selectedIndex);
52
53 ASSERT(oldTrack->id() != selectedTrackID);
54
55 oldTrack->clearSelected();
56 scheduleEvent = true;
57 }
58
59 if (selectedTrackID.isEmpty()) {
60 m_selectedIndex = -1;
61 } else {
62 m_selectedIndex = getIndex(selectedTrackID);
63 scheduleEvent = true;
64 }
65
66 if (scheduleEvent)
67 scheduleChangeEvent();
68 }
69
70 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698