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

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

Issue 208483002: Implement the activation behavior of media elements (click to play/pause) (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 9 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
Index: Source/core/html/MediaController.cpp
diff --git a/Source/core/html/MediaController.cpp b/Source/core/html/MediaController.cpp
index 4494b08fe95994a710ae4f9cb7bd65ae3993090b..8f22f4353c827c7445b31f27d3aee45197aed7d5 100644
--- a/Source/core/html/MediaController.cpp
+++ b/Source/core/html/MediaController.cpp
@@ -485,20 +485,50 @@ void MediaController::bringElementUpToSpeed(HTMLMediaElement* element)
element->seek(currentTime(), IGNORE_EXCEPTION);
}
+bool MediaController::isRestrained() const
+{
+ ASSERT(!m_mediaElements.isEmpty());
+
+ // A MediaController is a restrained media controller if the MediaController is a playing media
+ // controller,
+ if (m_paused)
+ return false;
+
+ bool allPaused = true;
+ for (size_t index = 0; index < m_mediaElements.size(); ++index) {
+ HTMLMediaElement* element = m_mediaElements[index];
+
+ // and none of its slaved media elements are blocked media elements,
+ if (element->isBlocked())
+ return false;
+
+ // but either at least one of its slaved media elements whose autoplaying flag is true still
+ // has its paused attribute set to true,
+ if (element->isAutoplaying() && element->paused())
+ return true;
+
+ if (!element->paused())
+ allPaused = false;
acolwell GONE FROM CHROMIUM 2014/03/21 23:30:12 I think you can just return false here and return
philipj_slow 2014/03/23 03:42:49 I had difficulties parsing the spec definition and
+ }
+
+ // or, all of its slaved media elements have their paused attribute set to true.
+ return allPaused;
+}
+
bool MediaController::isBlocked() const
{
+ ASSERT(!m_mediaElements.isEmpty());
+
// A MediaController is a blocked media controller if the MediaController is a paused media
// controller,
if (m_paused)
return true;
- if (m_mediaElements.isEmpty())
- return false;
-
bool allPaused = true;
for (size_t index = 0; index < m_mediaElements.size(); ++index) {
HTMLMediaElement* element = m_mediaElements[index];
- // or if any of its slaved media elements are blocked media elements,
+
+ // or if any of its slaved media elements are blocked media elements,
if (element->isBlocked())
return true;

Powered by Google App Engine
This is Rietveld 408576698