summaryrefslogtreecommitdiffstats
path: root/chromium/third_party/WebKit/Source/core/html/track/VideoTrackList.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/third_party/WebKit/Source/core/html/track/VideoTrackList.cpp')
-rw-r--r--chromium/third_party/WebKit/Source/core/html/track/VideoTrackList.cpp60
1 files changed, 60 insertions, 0 deletions
diff --git a/chromium/third_party/WebKit/Source/core/html/track/VideoTrackList.cpp b/chromium/third_party/WebKit/Source/core/html/track/VideoTrackList.cpp
new file mode 100644
index 00000000000..e107717dfa4
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/core/html/track/VideoTrackList.cpp
@@ -0,0 +1,60 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "config.h"
+#include "core/html/track/VideoTrackList.h"
+
+#include "core/html/HTMLMediaElement.h"
+#include "core/html/track/VideoTrack.h"
+
+namespace WebCore {
+
+PassRefPtrWillBeRawPtr<VideoTrackList> VideoTrackList::create(HTMLMediaElement& mediaElement)
+{
+ return adoptRefWillBeRefCountedGarbageCollected(new VideoTrackList(mediaElement));
+}
+
+VideoTrackList::~VideoTrackList()
+{
+}
+
+VideoTrackList::VideoTrackList(HTMLMediaElement& mediaElement)
+ : TrackListBase<VideoTrack>(&mediaElement)
+{
+ ScriptWrappable::init(this);
+}
+
+const AtomicString& VideoTrackList::interfaceName() const
+{
+ return EventTargetNames::VideoTrackList;
+}
+
+int VideoTrackList::selectedIndex() const
+{
+ for (unsigned i = 0; i < length(); ++i) {
+ VideoTrack* track = anonymousIndexedGetter(i);
+
+ if (track->selected())
+ return i;
+ }
+
+ return -1;
+}
+
+void VideoTrackList::trackSelected(blink::WebMediaPlayer::TrackId selectedTrackId)
+{
+ // Clear the selected flag on the previously selected track, if any.
+ for (unsigned i = 0; i < length(); ++i) {
+ VideoTrack* track = anonymousIndexedGetter(i);
+
+ if (track->trackId() != selectedTrackId)
+ track->clearSelected();
+ else
+ ASSERT(track->selected());
+ }
+
+ scheduleChangeEvent();
+}
+
+}