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..23749202a58b0ef0f4847d84376a472cce52927c |
--- /dev/null |
+++ b/Source/core/html/track/VideoTrackList.cpp |
@@ -0,0 +1,70 @@ |
+// 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) |
+{ |
+ RefPtrWillBeRawPtr<VideoTrackList> trackList(adoptRefWillBeRefCountedGarbageCollected(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.
|
+ trackList->suspendIfNeeded(); |
+ return trackList.release(); |
+} |
+ |
+VideoTrackList::~VideoTrackList() |
+{ |
+} |
+ |
+VideoTrackList::VideoTrackList(HTMLMediaElement* mediaElement) |
+ : TrackBaseList(mediaElement) |
+ , 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; |
+} |
+ |
+void VideoTrackList::trackSelected(const AtomicString& selectedTrackID) |
+{ |
+ |
philipj_slow
2014/03/13 10:00:04
remove blank line
acolwell GONE FROM CHROMIUM
2014/03/18 22:02:15
Done.
|
+ bool scheduleEvent = false; |
+ if (m_selectedIndex != -1) { |
+ VideoTrack* oldTrack = anonymousIndexedGetter(m_selectedIndex); |
+ |
+ ASSERT(oldTrack->id() != selectedTrackID); |
+ |
+ oldTrack->clearSelected(); |
+ scheduleEvent = true; |
+ } |
+ |
+ if (selectedTrackID.isEmpty()) { |
+ m_selectedIndex = -1; |
+ } else { |
+ m_selectedIndex = getIndex(selectedTrackID); |
+ scheduleEvent = true; |
+ } |
+ |
+ if (scheduleEvent) |
+ scheduleChangeEvent(); |
+} |
+ |
+} |