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

Unified Diff: Source/core/html/MediaController.cpp

Issue 612873002: Simplify MediaController with C++11 range-base for loops (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 3 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/html/MediaController.cpp
diff --git a/Source/core/html/MediaController.cpp b/Source/core/html/MediaController.cpp
index 0a72d6f3fe1934fbde326f01e91e2a93ae96245e..f7fa1f08920a336aa4b2c7221d97cbdd047d55a0 100644
--- a/Source/core/html/MediaController.cpp
+++ b/Source/core/html/MediaController.cpp
@@ -134,8 +134,8 @@ double MediaController::duration() const
// FIXME: Investigate caching the maximum duration and only updating the cached value
// when the slaved media elements' durations change.
double maxDuration = 0;
- for (MediaElementSequence::const_iterator it = m_mediaElements.begin(); it != m_mediaElements.end(); ++it) {
- double duration = (*it)->duration();
+ for (const HTMLMediaElement* element : m_mediaElements) {
+ double duration = element->duration();
if (std::isnan(duration))
continue;
maxDuration = std::max(maxDuration, duration);
@@ -173,8 +173,8 @@ void MediaController::setCurrentTime(double time)
m_clock->setCurrentTime(time);
// Seek each slaved media element to the new playback position relative to the media element timeline.
- for (MediaElementSequence::const_iterator it = m_mediaElements.begin(); it != m_mediaElements.end(); ++it)
- (*it)->seek(time);
+ for (HTMLMediaElement* element : m_mediaElements)
+ element->seek(time);
scheduleTimeupdateEvent();
}
@@ -197,8 +197,8 @@ void MediaController::play()
{
// When the play() method is invoked, the user agent must invoke the play method of each
// slaved media element in turn,
- for (MediaElementSequence::const_iterator it = m_mediaElements.begin(); it != m_mediaElements.end(); ++it)
- (*it)->play();
+ for (HTMLMediaElement* element : m_mediaElements)
+ element->play();
// and then invoke the unpause method of the MediaController.
unpause();
@@ -245,8 +245,8 @@ void MediaController::setPlaybackRate(double rate)
// playback rate to the new value,
m_clock->setPlayRate(rate);
- for (MediaElementSequence::const_iterator it = m_mediaElements.begin(); it != m_mediaElements.end(); ++it)
- (*it)->updatePlaybackRate();
+ for (HTMLMediaElement* element : m_mediaElements)
+ element->updatePlaybackRate();
// then queue a task to fire a simple event named ratechange at the MediaController.
scheduleEvent(EventTypeNames::ratechange);
@@ -271,8 +271,8 @@ void MediaController::setVolume(double level, ExceptionState& exceptionState)
// and queue a task to fire a simple event named volumechange at the MediaController.
scheduleEvent(EventTypeNames::volumechange);
- for (MediaElementSequence::const_iterator it = m_mediaElements.begin(); it != m_mediaElements.end(); ++it)
- (*it)->updateVolume();
+ for (HTMLMediaElement* element : m_mediaElements)
+ element->updateVolume();
}
void MediaController::setMuted(bool flag)
@@ -287,8 +287,8 @@ void MediaController::setMuted(bool flag)
// and queue a task to fire a simple event named volumechange at the MediaController.
scheduleEvent(EventTypeNames::volumechange);
- for (MediaElementSequence::const_iterator it = m_mediaElements.begin(); it != m_mediaElements.end(); ++it)
- (*it)->updateVolume();
+ for (HTMLMediaElement* element : m_mediaElements)
+ element->updateVolume();
}
static const AtomicString& playbackStateWaiting()
@@ -471,8 +471,8 @@ void MediaController::updatePlaybackState()
void MediaController::updateMediaElements()
{
- for (MediaElementSequence::const_iterator it = m_mediaElements.begin(); it != m_mediaElements.end(); ++it)
- (*it)->updatePlayState();
+ for (HTMLMediaElement* element : m_mediaElements)
+ element->updatePlayState();
}
void MediaController::bringElementUpToSpeed(HTMLMediaElement* element)
@@ -500,9 +500,7 @@ bool MediaController::isRestrained() const
bool anyAutoplayingAndPaused = false;
bool allPaused = true;
- for (MediaElementSequence::const_iterator it = m_mediaElements.begin(); it != m_mediaElements.end(); ++it) {
- HTMLMediaElement* element = *it;
-
+ for (const HTMLMediaElement* element : m_mediaElements) {
if (element->isAutoplaying() && element->paused())
anyAutoplayingAndPaused = true;
@@ -526,9 +524,7 @@ bool MediaController::isBlocked() const
return true;
bool allPaused = true;
- for (MediaElementSequence::const_iterator it = m_mediaElements.begin(); it != m_mediaElements.end(); ++it) {
- HTMLMediaElement* element = *it;
-
+ for (const HTMLMediaElement* element : m_mediaElements) {
// or if any of its slaved media elements are blocked media elements,
if (element->isBlocked())
return true;
@@ -558,8 +554,8 @@ bool MediaController::hasEnded() const
return false;
bool allHaveEnded = true;
- for (MediaElementSequence::const_iterator it = m_mediaElements.begin(); it != m_mediaElements.end(); ++it) {
- if (!(*it)->ended())
+ for (const HTMLMediaElement* element : m_mediaElements) {
+ if (!element->ended())
allHaveEnded = false;
}
return allHaveEnded;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698