Chromium Code Reviews| 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..20ec28dc7e1e4d01e0e288a1394c89890c462777 |
| --- /dev/null |
| +++ b/Source/core/html/track/VideoTrackList.cpp |
| @@ -0,0 +1,64 @@ |
| +// 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)); |
|
haraken
2014/06/12 01:22:07
adoptRefWillBeNoop().
|
| +} |
| + |
| +VideoTrackList::~VideoTrackList() |
| +{ |
| +} |
| + |
| +VideoTrackList::VideoTrackList(HTMLMediaElement& mediaElement) |
| + : TrackListBase<VideoTrack>(&mediaElement) |
| + , m_selectedIndex(-1) |
| +{ |
| + ScriptWrappable::init(this); |
| +} |
| + |
| +const AtomicString& VideoTrackList::interfaceName() const |
| +{ |
| + return EventTargetNames::VideoTrackList; |
| +} |
| + |
| +void VideoTrackList::trackSelected(blink::WebMediaPlayer::TrackId* selectedTrackId) |
| +{ |
| + bool scheduleEvent = false; |
| + if (m_selectedIndex != -1) { |
| + VideoTrack* oldTrack = anonymousIndexedGetter(m_selectedIndex); |
| + |
| + ASSERT(!selectedTrackId || oldTrack->trackId() != *selectedTrackId); |
| + |
| + oldTrack->clearSelected(); |
| + m_selectedIndex = -1; |
| + scheduleEvent = true; |
| + } |
| + |
| + if (selectedTrackId) { |
| + for (unsigned i = 0; i < length(); ++i) { |
| + VideoTrack* track = anonymousIndexedGetter(i); |
| + |
| + if (track->trackId() != *selectedTrackId) |
| + continue; |
| + |
| + m_selectedIndex = i; |
| + scheduleEvent = true; |
| + break; |
| + } |
| + } |
| + |
| + if (scheduleEvent) |
| + scheduleChangeEvent(); |
| +} |
| + |
| +} |