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

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: /s/TODO/FIXME 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
« no previous file with comments | « Source/core/html/shadow/MediaControls.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 27 matching lines...) Expand all
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 fullscreenIsSupported(const Document& document) 43 static bool fullscreenIsSupported(const Document& document)
44 { 44 {
45 return !document.settings() || document.settings()->fullscreenSupported(); 45 return !document.settings() || document.settings()->fullscreenSupported();
46 } 46 }
47 47
48 static bool deviceSupportsMouse(const Document& document)
49 {
50 return !document.settings() || document.settings()->deviceSupportsMouse();
51 }
52
48 MediaControls::MediaControls(HTMLMediaElement& mediaElement) 53 MediaControls::MediaControls(HTMLMediaElement& mediaElement)
49 : HTMLDivElement(mediaElement.document()) 54 : HTMLDivElement(mediaElement.document())
50 , m_mediaElement(&mediaElement) 55 , m_mediaElement(&mediaElement)
51 , m_panel(nullptr) 56 , m_panel(nullptr)
52 , m_textDisplayContainer(nullptr) 57 , m_textDisplayContainer(nullptr)
53 , m_overlayPlayButton(nullptr) 58 , m_overlayPlayButton(nullptr)
54 , m_overlayEnclosure(nullptr) 59 , m_overlayEnclosure(nullptr)
55 , m_playButton(nullptr) 60 , m_playButton(nullptr)
56 , m_currentTimeDisplay(nullptr) 61 , m_currentTimeDisplay(nullptr)
57 , m_timeline(nullptr) 62 , m_timeline(nullptr)
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 void MediaControls::makeTransparent() 227 void MediaControls::makeTransparent()
223 { 228 {
224 m_panel->makeTransparent(); 229 m_panel->makeTransparent();
225 } 230 }
226 231
227 bool MediaControls::shouldHideMediaControls(unsigned behaviorFlags) const 232 bool MediaControls::shouldHideMediaControls(unsigned behaviorFlags) const
228 { 233 {
229 // Never hide for a media element without visual representation. 234 // Never hide for a media element without visual representation.
230 if (!mediaElement().hasVideo()) 235 if (!mediaElement().hasVideo())
231 return false; 236 return false;
232 // Don't hide if the controls are hovered or the mouse is over the video are a. 237 // Don't hide if the mouse is over the controls.
238 const bool ignoreControlsHover = behaviorFlags & IgnoreControlsHover;
239 if (!ignoreControlsHover && m_panel->hovered())
240 return false;
241 // Don't hide if the mouse is over the video area.
233 const bool ignoreVideoHover = behaviorFlags & IgnoreVideoHover; 242 const bool ignoreVideoHover = behaviorFlags & IgnoreVideoHover;
234 if (m_panel->hovered() || (!ignoreVideoHover && m_isMouseOverControls)) 243 if (!ignoreVideoHover && m_isMouseOverControls)
235 return false; 244 return false;
236 // Don't hide if focus is on the HTMLMediaElement or within the 245 // Don't hide if focus is on the HTMLMediaElement or within the
237 // controls/shadow tree. (Perform the checks separately to avoid going 246 // controls/shadow tree. (Perform the checks separately to avoid going
238 // through all the potential ancestor hosts for the focused element.) 247 // through all the potential ancestor hosts for the focused element.)
239 const bool ignoreFocus = behaviorFlags & IgnoreFocus; 248 const bool ignoreFocus = behaviorFlags & IgnoreFocus;
240 if (!ignoreFocus && (mediaElement().focused() || contains(document().focused Element()))) 249 if (!ignoreFocus && (mediaElement().focused() || contains(document().focused Element())))
241 return false; 250 return false;
242 return true; 251 return true;
243 } 252 }
244 253
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
392 startHideMediaControlsTimer(); 401 startHideMediaControlsTimer();
393 return; 402 return;
394 } 403 }
395 } 404 }
396 405
397 void MediaControls::hideMediaControlsTimerFired(Timer<MediaControls>*) 406 void MediaControls::hideMediaControlsTimerFired(Timer<MediaControls>*)
398 { 407 {
399 if (mediaElement().togglePlayStateWillPlay()) 408 if (mediaElement().togglePlayStateWillPlay())
400 return; 409 return;
401 410
402 if (!shouldHideMediaControls(IgnoreFocus | IgnoreVideoHover)) 411 unsigned behaviorFlags = IgnoreFocus | IgnoreVideoHover;
412 // FIXME: improve this check, see http://www.crbug.com/401177.
413 if (!deviceSupportsMouse(document())) {
414 behaviorFlags |= IgnoreControlsHover;
415 }
416 if (!shouldHideMediaControls(behaviorFlags))
403 return; 417 return;
404 418
405 makeTransparent(); 419 makeTransparent();
406 } 420 }
407 421
408 void MediaControls::startHideMediaControlsTimer() 422 void MediaControls::startHideMediaControlsTimer()
409 { 423 {
410 m_hideMediaControlsTimer.startOneShot(timeWithoutMouseMovementBeforeHidingMe diaControls, FROM_HERE); 424 m_hideMediaControlsTimer.startOneShot(timeWithoutMouseMovementBeforeHidingMe diaControls, FROM_HERE);
411 } 425 }
412 426
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
481 visitor->trace(m_muteButton); 495 visitor->trace(m_muteButton);
482 visitor->trace(m_volumeSlider); 496 visitor->trace(m_volumeSlider);
483 visitor->trace(m_toggleClosedCaptionsButton); 497 visitor->trace(m_toggleClosedCaptionsButton);
484 visitor->trace(m_fullScreenButton); 498 visitor->trace(m_fullScreenButton);
485 visitor->trace(m_durationDisplay); 499 visitor->trace(m_durationDisplay);
486 visitor->trace(m_enclosure); 500 visitor->trace(m_enclosure);
487 HTMLDivElement::trace(visitor); 501 HTMLDivElement::trace(visitor);
488 } 502 }
489 503
490 } 504 }
OLDNEW
« no previous file with comments | « Source/core/html/shadow/MediaControls.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698