summaryrefslogtreecommitdiff
path: root/Source/WebCore/html/track/VideoTrackList.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Source/WebCore/html/track/VideoTrackList.cpp')
-rw-r--r--Source/WebCore/html/track/VideoTrackList.cpp41
1 files changed, 21 insertions, 20 deletions
diff --git a/Source/WebCore/html/track/VideoTrackList.cpp b/Source/WebCore/html/track/VideoTrackList.cpp
index 594ca1b3a..304c601b8 100644
--- a/Source/WebCore/html/track/VideoTrackList.cpp
+++ b/Source/WebCore/html/track/VideoTrackList.cpp
@@ -10,10 +10,10 @@
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
@@ -29,7 +29,6 @@
#include "VideoTrackList.h"
-#include "EventNames.h"
#include "VideoTrack.h"
using namespace WebCore;
@@ -43,48 +42,50 @@ VideoTrackList::~VideoTrackList()
{
}
-void VideoTrackList::append(PassRefPtr<VideoTrack> prpTrack)
+void VideoTrackList::append(Ref<VideoTrack>&& track)
{
- RefPtr<VideoTrack> track = prpTrack;
-
// Insert tracks in the media file order.
size_t index = track->inbandTrackIndex();
- m_inbandTracks.insert(index, track);
+ size_t insertionIndex;
+ for (insertionIndex = 0; insertionIndex < m_inbandTracks.size(); ++insertionIndex) {
+ auto& otherTrack = downcast<VideoTrack>(*m_inbandTracks[insertionIndex]);
+ if (otherTrack.inbandTrackIndex() > index)
+ break;
+ }
+ m_inbandTracks.insert(insertionIndex, track.ptr());
ASSERT(!track->mediaElement() || track->mediaElement() == mediaElement());
track->setMediaElement(mediaElement());
- scheduleAddTrackEvent(track.release());
+ scheduleAddTrackEvent(WTFMove(track));
}
VideoTrack* VideoTrackList::item(unsigned index) const
{
if (index < m_inbandTracks.size())
- return toVideoTrack(m_inbandTracks[index].get());
-
- return 0;
+ return downcast<VideoTrack>(m_inbandTracks[index].get());
+ return nullptr;
}
VideoTrack* VideoTrackList::getTrackById(const AtomicString& id) const
{
- for (size_t i = 0; i < length(); ++i) {
- VideoTrack* track = toVideoTrack(m_inbandTracks[i].get());
- if (track->id() == id)
- return track;
+ for (auto& inbandTracks : m_inbandTracks) {
+ auto& track = downcast<VideoTrack>(*inbandTracks);
+ if (track.id() == id)
+ return &track;
}
- return 0;
+ return nullptr;
}
-long VideoTrackList::selectedIndex() const
+int VideoTrackList::selectedIndex() const
{
// 4.8.10.10.1 AudioTrackList and VideoTrackList objects
// The VideoTrackList.selectedIndex attribute must return the index of the
// currently selected track, if any. If the VideoTrackList object does not
// currently represent any tracks, or if none of the tracks are selected,
// it must instead return −1.
- for (size_t i = 0; i < length(); ++i) {
- VideoTrack* track = toVideoTrack(m_inbandTracks[i].get());
- if (track->selected())
+ for (unsigned i = 0; i < length(); ++i) {
+ if (downcast<VideoTrack>(*m_inbandTracks[i]).selected())
return i;
}
return -1;