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

Unified Diff: Source/core/html/HTMLMediaElement.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/HTMLMediaElement.h ('k') | Source/core/html/MediaController.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/html/HTMLMediaElement.cpp
diff --git a/Source/core/html/HTMLMediaElement.cpp b/Source/core/html/HTMLMediaElement.cpp
index d140bf8db7e8fa433da5a8bb7cc0d143ee1e05e8..e1660f5e3e032962868c3e5171f00f8a0965f863 100644
--- a/Source/core/html/HTMLMediaElement.cpp
+++ b/Source/core/html/HTMLMediaElement.cpp
@@ -2222,6 +2222,25 @@ bool HTMLMediaElement::canPlay() const
return paused() || ended() || m_readyState < HAVE_METADATA;
}
+void HTMLMediaElement::togglePlayState()
+{
+ ASSERT(controls());
+ // The activation behavior of a media element that is exposing a user interface to the user
+ if (m_mediaController) {
+ if (m_mediaController->isRestrained())
+ m_mediaController->play();
+ else if (m_mediaController->paused())
+ m_mediaController->unpause();
+ else
+ m_mediaController->pause();
+ } else {
+ if (paused())
+ play();
+ else
+ pause();
+ }
+}
+
void HTMLMediaElement::mediaPlayerDidAddTextTrack(WebInbandTextTrack* webTrack)
{
if (!RuntimeEnabledFeatures::videoTrackEnabled())
@@ -3423,6 +3442,10 @@ void HTMLMediaElement::markCaptionAndSubtitleTracksAsUnconfigured()
configureTextTracks();
}
+bool HTMLMediaElement::willRespondToMouseClickEvents()
+{
+ return controls();
+}
void* HTMLMediaElement::preDispatchEventHandler(Event* event)
{
@@ -3432,6 +3455,16 @@ void* HTMLMediaElement::preDispatchEventHandler(Event* event)
return 0;
}
+void HTMLMediaElement::defaultEventHandler(Event* event)
+{
+ if (event->type() == EventTypeNames::click && willRespondToMouseClickEvents()) {
+ togglePlayState();
+ event->setDefaultHandled();
+ return;
+ }
+ HTMLElement::defaultEventHandler(event);
+}
+
void HTMLMediaElement::createMediaPlayer()
{
#if ENABLE(WEB_AUDIO)
« no previous file with comments | « Source/core/html/HTMLMediaElement.h ('k') | Source/core/html/MediaController.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698