| 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)));
|
| + 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)
|
| +{
|
| +
|
| + 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();
|
| +}
|
| +
|
| +}
|
|
|