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

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: cancel activation behavior in a failing fullscreen test 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
« no previous file with comments | « Source/core/html/MediaController.h ('k') | Source/core/html/shadow/MediaControlElements.h » ('j') | 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 4494b08fe95994a710ae4f9cb7bd65ae3993090b..26ad8359ede7a673c9205cd615e4bba043aa0774 100644
--- a/Source/core/html/MediaController.cpp
+++ b/Source/core/html/MediaController.cpp
@@ -485,20 +485,51 @@ 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 anyAutoplayingAndPaused = 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;
+
+ if (element->isAutoplaying() && element->paused())
+ anyAutoplayingAndPaused = true;
+
+ if (!element->paused())
+ allPaused = false;
+ }
+
+ // but either at least one of its slaved media elements whose autoplaying flag is true still has
+ // its paused attribute set to true, or, all of its slaved media elements have their paused
+ // attribute set to true.
+ return anyAutoplayingAndPaused || 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;
« no previous file with comments | « Source/core/html/MediaController.h ('k') | Source/core/html/shadow/MediaControlElements.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698