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

Unified 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: Created 6 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: Source/core/html/track/VideoTrackList.cpp
diff --git a/Source/core/html/track/VideoTrackList.cpp b/Source/core/html/track/VideoTrackList.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..0c3b210684ba0bd11330136c78b5af2b0f312335
--- /dev/null
+++ b/Source/core/html/track/VideoTrackList.cpp
@@ -0,0 +1,68 @@
+// 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 {
+
+VideoTrackList::~VideoTrackList()
+{
+}
+
+VideoTrackList::VideoTrackList(HTMLMediaElement* owner)
+ : TrackBaseList(owner)
+ , m_selectedIndex(-1)
+{
+ ScriptWrappable::init(this);
+}
+
+VideoTrack* VideoTrackList::anonymousIndexedGetter(unsigned index) const
+{
+ return static_cast<VideoTrack*>(getByIndex(index));
+}
+
+VideoTrack* VideoTrackList::getTrackById(const AtomicString& id) const
+{
+ return static_cast<VideoTrack*>(getById(id));
+}
+
+const AtomicString& VideoTrackList::interfaceName() const
+{
+ return EventTargetNames::VideoTrackList;
+}
+
+ExecutionContext* VideoTrackList::executionContext() const
+{
+ return owner()->executionContext();
fs 2014/02/24 10:32:36 See comment in AudioTrackList::executionContext().
acolwell GONE FROM CHROMIUM 2014/03/07 22:08:43 Done.
+}
+
+void VideoTrackList::trackSelected(VideoTrack* track)
+{
+ AtomicString oldTrackID;
+ AtomicString newTrackID;
+
+ if (m_selectedIndex != -1) {
+ VideoTrack* oldSelectedTrack = anonymousIndexedGetter(m_selectedIndex);
+ oldSelectedTrack->clearSelected();
+ oldTrackID = oldSelectedTrack->id();
+ }
+
+ if (track) {
+ m_selectedIndex = getIndex(track);
+ newTrackID = track->id();
+ } else {
+ m_selectedIndex = -1;
+ }
+
+ if (owner())
+ owner()->didSelectedVideoTrackChange(oldTrackID, newTrackID);
+
+ scheduleChangeEvent();
+}
+
+}

Powered by Google App Engine
This is Rietveld 408576698