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

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

Issue 284513003: Implement AudioTrack, AudioTrackList, VideoTrack, and VideoTrackList (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: nits Created 6 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/html/track/VideoTrackList.h ('k') | Source/core/html/track/VideoTrackList.idl » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 return adoptRefWillBeRefCountedGarbageCollected(new VideoTrackList(mediaElem ent));
16 }
17
18 VideoTrackList::~VideoTrackList()
19 {
20 }
21
22 VideoTrackList::VideoTrackList(HTMLMediaElement& mediaElement)
23 : TrackListBase<VideoTrack>(&mediaElement)
24 {
25 ScriptWrappable::init(this);
26 }
27
28 const AtomicString& VideoTrackList::interfaceName() const
29 {
30 return EventTargetNames::VideoTrackList;
31 }
32
33 int VideoTrackList::selectedIndex() const
34 {
35 for (unsigned i = 0; i < length(); ++i) {
36 VideoTrack* track = anonymousIndexedGetter(i);
37
38 if (track->selected())
39 return i;
40 }
41
42 return -1;
43 }
44
45 void VideoTrackList::trackSelected(blink::WebMediaPlayer::TrackId selectedTrackI d)
46 {
47 // Clear the selected flag on the previously selected track, if any.
48 for (unsigned i = 0; i < length(); ++i) {
49 VideoTrack* track = anonymousIndexedGetter(i);
50
51 if (track->trackId() != selectedTrackId)
52 track->clearSelected();
53 else
54 ASSERT(track->selected());
55 }
56
57 scheduleChangeEvent();
58 }
59
60 }
OLDNEW
« no previous file with comments | « Source/core/html/track/VideoTrackList.h ('k') | Source/core/html/track/VideoTrackList.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698