OLD | NEW |
---|---|
(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 PassRefPtr<VideoTrackList> VideoTrackList::create(HTMLMediaElement& mediaElement ) | |
sof
2014/05/22 11:47:36
Needs to be adjusted also (return type + adoptRef(
| |
14 { | |
15 return adoptRef(new VideoTrackList(mediaElement)); | |
16 } | |
17 | |
18 VideoTrackList::~VideoTrackList() | |
19 { | |
20 } | |
21 | |
22 VideoTrackList::VideoTrackList(HTMLMediaElement& mediaElement) | |
23 : TrackListBase<VideoTrack>(&mediaElement) | |
24 , m_selectedIndex(-1) | |
25 { | |
26 ScriptWrappable::init(this); | |
27 } | |
28 | |
29 const AtomicString& VideoTrackList::interfaceName() const | |
30 { | |
31 return EventTargetNames::VideoTrackList; | |
32 } | |
33 | |
34 void VideoTrackList::trackSelected(blink::WebTrackId* selectedTrackId) | |
35 { | |
36 bool scheduleEvent = false; | |
37 if (m_selectedIndex != -1) { | |
38 VideoTrack* oldTrack = anonymousIndexedGetter(m_selectedIndex); | |
39 | |
40 ASSERT(!selectedTrackId || oldTrack->webId() != *selectedTrackId); | |
41 | |
42 oldTrack->clearSelected(); | |
43 m_selectedIndex = -1; | |
44 scheduleEvent = true; | |
45 } | |
46 | |
47 if (selectedTrackId) { | |
48 for (unsigned i = 0; i < length(); ++i) { | |
49 VideoTrack* track = anonymousIndexedGetter(i); | |
50 | |
51 if (track->webId() != *selectedTrackId) | |
52 continue; | |
53 | |
54 m_selectedIndex = i; | |
55 scheduleEvent = true; | |
56 break; | |
57 } | |
58 } | |
59 | |
60 if (scheduleEvent) | |
61 scheduleChangeEvent(); | |
62 } | |
63 | |
64 } | |
OLD | NEW |