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

Unified Diff: Source/core/html/shadow/MediaControls.cpp

Issue 914043002: Tap on the video element toggles controls visibility (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebased, process mouse only for non-synthetic events. Created 5 years, 10 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/shadow/MediaControls.cpp
diff --git a/Source/core/html/shadow/MediaControls.cpp b/Source/core/html/shadow/MediaControls.cpp
index 2f827bd203aee4f1c7007dc251071ed56f3c3b56..d107aacd99ae3690ac50f86513ebe1513ca1990b 100644
--- a/Source/core/html/shadow/MediaControls.cpp
+++ b/Source/core/html/shadow/MediaControls.cpp
@@ -360,6 +360,11 @@ void MediaControls::textTracksChanged()
refreshClosedCaptionsButtonVisibility();
}
+void MediaControls::timelineKnobDragged()
+{
+ resetHideMediaControlsTimer();
+}
+
static Element* elementFromCenter(Element& element)
{
RefPtrWillBeRawPtr<ClientRect> clientRect = element.getBoundingClientRect();
@@ -435,6 +440,17 @@ void MediaControls::stoppedCasting()
m_overlayCastButton->setIsPlayingRemotely(false);
}
+bool MediaControls::isInactiveElement(Node* node) const
philipj_slow 2015/02/16 10:45:19 If isn't mate moot by other changes, would willRes
+{
+ if (node == m_mediaElement
+ || node == m_textDisplayContainer
+ || node == m_overlayEnclosure
+ || node == m_enclosure)
+ return true;
+
+ return false;
+}
+
void MediaControls::defaultEventHandler(Event* event)
{
HTMLDivElement::defaultEventHandler(event);
@@ -443,11 +459,40 @@ void MediaControls::defaultEventHandler(Event* event)
// to allow the hide-timer to do the right thing when it fires.
// FIXME: Preferably we would only do this when we're actually handling the event
// here ourselves.
+ bool mouseIsSynthetic = event->isMouseEvent() && toMouseEvent(event)->fromTouch();
philipj_slow 2015/02/16 10:45:19 Perhaps isMouseEventFromTouch will make sound less
bool wasLastEventTouch = event->isTouchEvent() || event->isGestureEvent()
philipj_slow 2015/02/16 10:45:18 I just renamed this, but actually isTouchEvent wou
- || (event->isMouseEvent() && toMouseEvent(event)->fromTouch());
+ || mouseIsSynthetic;
+
m_hideTimerBehaviorFlags |= wasLastEventTouch ? IgnoreControlsHover : IgnoreNone;
- if (event->type() == EventTypeNames::mouseover) {
+ // Separate tap gestures from mouse clicks unless the tap
+ // is intended for an input element like a button.
+ if (event->type() == EventTypeNames::gesturetap) {
philipj_slow 2015/02/16 10:45:19 Did you first try using the touchstart and click e
Tima Vaisburd 2015/02/16 20:32:11 No, I must admit I haven't tried the touchstart ev
philipj_slow 2015/02/17 02:37:24 Overriding Node::willRespondToTouchEvents() ought
Tima Vaisburd 2015/02/19 19:32:28 I was wrong: whether touch events propagate or not
+ Node * targetNode = event->target() ? event->target()->toNode() : nullptr;
+ if (!targetNode || isInactiveElement(targetNode)) {
+ // Do not generate mouse events from this tap,
+ // otherwise a tap to show controls might also
+ // trigger some unexpected action like stop or seek.
+ event->preventDefault();
philipj_slow 2015/02/16 10:45:19 This will be observable to Web content. An alterna
+
+ if (!m_panel->isOpaque()) {
+ makeOpaque();
+ startHideMediaControlsTimer();
+ // Prevent immediate hiding by playbackProgressed()
+ m_isMouseOverControls = true;
philipj_slow 2015/02/16 10:45:19 This seems like an abuse of this state variable, a
+ } else {
+ stopHideMediaControlsTimer();
+ makeTransparent();
+ }
+ } else {
+ // Prevent the controls from disappearing while we are working with them
+ if (m_panel->isOpaque())
+ resetHideMediaControlsTimer();
+ }
+ return;
+ }
+
+ if (event->type() == EventTypeNames::mouseover && !mouseIsSynthetic) {
if (!containsRelatedTarget(event)) {
m_isMouseOverControls = true;
if (!mediaElement().togglePlayStateWillPlay()) {
@@ -459,7 +504,7 @@ void MediaControls::defaultEventHandler(Event* event)
return;
}
- if (event->type() == EventTypeNames::mouseout) {
+ if (event->type() == EventTypeNames::mouseout && !mouseIsSynthetic) {
if (!containsRelatedTarget(event)) {
m_isMouseOverControls = false;
stopHideMediaControlsTimer();
@@ -467,7 +512,7 @@ void MediaControls::defaultEventHandler(Event* event)
return;
}
- if (event->type() == EventTypeNames::mousemove) {
+ if (event->type() == EventTypeNames::mousemove && !mouseIsSynthetic) {
// When we get a mouse move, show the media controls, and start a timer
// that will hide the media controls after a 3 seconds without a mouse move.
makeOpaque();
« Source/core/html/shadow/MediaControlElements.cpp ('K') | « Source/core/html/shadow/MediaControls.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698