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

Side by Side Diff: Source/core/html/shadow/MediaControls.cpp

Issue 441193003: Hide video controls after touch when hideMediaControlsTimerFired fires. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Add bug number to comment Created 6 years, 4 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011, 2012 Apple Inc. All rights reserved. 2 * Copyright (C) 2011, 2012 Apple Inc. All rights reserved.
3 * Copyright (C) 2011, 2012 Google Inc. All rights reserved. 3 * Copyright (C) 2011, 2012 Google Inc. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 22 matching lines...) Expand all
33 #include "core/html/HTMLMediaElement.h" 33 #include "core/html/HTMLMediaElement.h"
34 #include "core/html/MediaController.h" 34 #include "core/html/MediaController.h"
35 #include "core/rendering/RenderTheme.h" 35 #include "core/rendering/RenderTheme.h"
36 36
37 namespace blink { 37 namespace blink {
38 38
39 // If you change this value, then also update the corresponding value in 39 // If you change this value, then also update the corresponding value in
40 // LayoutTests/media/media-controls.js. 40 // LayoutTests/media/media-controls.js.
41 static const double timeWithoutMouseMovementBeforeHidingMediaControls = 3; 41 static const double timeWithoutMouseMovementBeforeHidingMediaControls = 3;
42 42
43 static bool deviceSupportsMouse(const Document& document)
44 {
45 return !document.settings() || document.settings()->deviceSupportsMouse();
46 }
47
43 MediaControls::MediaControls(HTMLMediaElement& mediaElement) 48 MediaControls::MediaControls(HTMLMediaElement& mediaElement)
44 : HTMLDivElement(mediaElement.document()) 49 : HTMLDivElement(mediaElement.document())
45 , m_mediaElement(&mediaElement) 50 , m_mediaElement(&mediaElement)
46 , m_panel(nullptr) 51 , m_panel(nullptr)
47 , m_textDisplayContainer(nullptr) 52 , m_textDisplayContainer(nullptr)
48 , m_overlayPlayButton(nullptr) 53 , m_overlayPlayButton(nullptr)
49 , m_overlayEnclosure(nullptr) 54 , m_overlayEnclosure(nullptr)
50 , m_playButton(nullptr) 55 , m_playButton(nullptr)
51 , m_currentTimeDisplay(nullptr) 56 , m_currentTimeDisplay(nullptr)
52 , m_timeline(nullptr) 57 , m_timeline(nullptr)
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 void MediaControls::makeTransparent() 222 void MediaControls::makeTransparent()
218 { 223 {
219 m_panel->makeTransparent(); 224 m_panel->makeTransparent();
220 } 225 }
221 226
222 bool MediaControls::shouldHideMediaControls(unsigned behaviorFlags) const 227 bool MediaControls::shouldHideMediaControls(unsigned behaviorFlags) const
223 { 228 {
224 // Never hide for a media element without visual representation. 229 // Never hide for a media element without visual representation.
225 if (!mediaElement().hasVideo()) 230 if (!mediaElement().hasVideo())
226 return false; 231 return false;
227 // Don't hide if the controls are hovered or the mouse is over the video are a. 232 // Don't hide if the mouse is over the controls.
233 const bool ignoreControlsHover = behaviorFlags & IgnoreControlsHover;
234 if (!ignoreControlsHover && m_panel->hovered())
235 return false;
236 // Don't hide if the mouse is over the video area.
228 const bool ignoreVideoHover = behaviorFlags & IgnoreVideoHover; 237 const bool ignoreVideoHover = behaviorFlags & IgnoreVideoHover;
229 if (m_panel->hovered() || (!ignoreVideoHover && m_isMouseOverControls)) 238 if (!ignoreVideoHover && m_isMouseOverControls)
230 return false; 239 return false;
231 // Don't hide if focus is on the HTMLMediaElement or within the 240 // Don't hide if focus is on the HTMLMediaElement or within the
232 // controls/shadow tree. (Perform the checks separately to avoid going 241 // controls/shadow tree. (Perform the checks separately to avoid going
233 // through all the potential ancestor hosts for the focused element.) 242 // through all the potential ancestor hosts for the focused element.)
234 const bool ignoreFocus = behaviorFlags & IgnoreFocus; 243 const bool ignoreFocus = behaviorFlags & IgnoreFocus;
235 if (!ignoreFocus && (mediaElement().focused() || contains(document().focused Element()))) 244 if (!ignoreFocus && (mediaElement().focused() || contains(document().focused Element())))
236 return false; 245 return false;
237 return true; 246 return true;
238 } 247 }
239 248
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
387 startHideMediaControlsTimer(); 396 startHideMediaControlsTimer();
388 return; 397 return;
389 } 398 }
390 } 399 }
391 400
392 void MediaControls::hideMediaControlsTimerFired(Timer<MediaControls>*) 401 void MediaControls::hideMediaControlsTimerFired(Timer<MediaControls>*)
393 { 402 {
394 if (mediaElement().togglePlayStateWillPlay()) 403 if (mediaElement().togglePlayStateWillPlay())
395 return; 404 return;
396 405
397 if (!shouldHideMediaControls(IgnoreFocus | IgnoreVideoHover)) 406 unsigned behaviorFlags = IgnoreFocus | IgnoreVideoHover;
407 // This check could be improved, see http://www.crbug.com/401177.
408 if (!deviceSupportsMouse(document())) {
409 behaviorFlags |= IgnoreControlsHover;
410 }
411 if (!shouldHideMediaControls(behaviorFlags))
398 return; 412 return;
399 413
400 makeTransparent(); 414 makeTransparent();
401 } 415 }
402 416
403 void MediaControls::startHideMediaControlsTimer() 417 void MediaControls::startHideMediaControlsTimer()
404 { 418 {
405 m_hideMediaControlsTimer.startOneShot(timeWithoutMouseMovementBeforeHidingMe diaControls, FROM_HERE); 419 m_hideMediaControlsTimer.startOneShot(timeWithoutMouseMovementBeforeHidingMe diaControls, FROM_HERE);
406 } 420 }
407 421
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
476 visitor->trace(m_muteButton); 490 visitor->trace(m_muteButton);
477 visitor->trace(m_volumeSlider); 491 visitor->trace(m_volumeSlider);
478 visitor->trace(m_toggleClosedCaptionsButton); 492 visitor->trace(m_toggleClosedCaptionsButton);
479 visitor->trace(m_fullScreenButton); 493 visitor->trace(m_fullScreenButton);
480 visitor->trace(m_durationDisplay); 494 visitor->trace(m_durationDisplay);
481 visitor->trace(m_enclosure); 495 visitor->trace(m_enclosure);
482 HTMLDivElement::trace(visitor); 496 HTMLDivElement::trace(visitor);
483 } 497 }
484 498
485 } 499 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698