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

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

Issue 453493002: Improve detection of touch events when hiding media controls. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@autoHideControls
Patch Set: Revert Patch Set 8 Created 6 years, 3 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') | Source/core/inspector/InspectorInputAgent.cpp » ('j') | 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
53 MediaControls::MediaControls(HTMLMediaElement& mediaElement) 48 MediaControls::MediaControls(HTMLMediaElement& mediaElement)
54 : HTMLDivElement(mediaElement.document()) 49 : HTMLDivElement(mediaElement.document())
55 , m_mediaElement(&mediaElement) 50 , m_mediaElement(&mediaElement)
56 , m_panel(nullptr) 51 , m_panel(nullptr)
57 , m_textDisplayContainer(nullptr) 52 , m_textDisplayContainer(nullptr)
58 , m_overlayPlayButton(nullptr) 53 , m_overlayPlayButton(nullptr)
59 , m_overlayEnclosure(nullptr) 54 , m_overlayEnclosure(nullptr)
60 , m_playButton(nullptr) 55 , m_playButton(nullptr)
61 , m_currentTimeDisplay(nullptr) 56 , m_currentTimeDisplay(nullptr)
62 , m_timeline(nullptr) 57 , m_timeline(nullptr)
63 , m_muteButton(nullptr) 58 , m_muteButton(nullptr)
64 , m_volumeSlider(nullptr) 59 , m_volumeSlider(nullptr)
65 , m_toggleClosedCaptionsButton(nullptr) 60 , m_toggleClosedCaptionsButton(nullptr)
66 , m_fullScreenButton(nullptr) 61 , m_fullScreenButton(nullptr)
67 , m_durationDisplay(nullptr) 62 , m_durationDisplay(nullptr)
68 , m_enclosure(nullptr) 63 , m_enclosure(nullptr)
69 , m_hideMediaControlsTimer(this, &MediaControls::hideMediaControlsTimerFired ) 64 , m_hideMediaControlsTimer(this, &MediaControls::hideMediaControlsTimerFired )
70 , m_isMouseOverControls(false) 65 , m_isMouseOverControls(false)
71 , m_isPausedForScrubbing(false) 66 , m_isPausedForScrubbing(false)
67 , m_wasLastEventTouch(false)
72 { 68 {
73 } 69 }
74 70
75 PassRefPtrWillBeRawPtr<MediaControls> MediaControls::create(HTMLMediaElement& me diaElement) 71 PassRefPtrWillBeRawPtr<MediaControls> MediaControls::create(HTMLMediaElement& me diaElement)
76 { 72 {
77 RefPtrWillBeRawPtr<MediaControls> controls = adoptRefWillBeNoop(new MediaCon trols(mediaElement)); 73 RefPtrWillBeRawPtr<MediaControls> controls = adoptRefWillBeNoop(new MediaCon trols(mediaElement));
78 74
79 if (controls->initializeControls()) 75 if (controls->initializeControls())
80 return controls.release(); 76 return controls.release();
81 77
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after
365 void MediaControls::exitedFullscreen() 361 void MediaControls::exitedFullscreen()
366 { 362 {
367 m_fullScreenButton->setIsFullscreen(false); 363 m_fullScreenButton->setIsFullscreen(false);
368 stopHideMediaControlsTimer(); 364 stopHideMediaControlsTimer();
369 startHideMediaControlsTimer(); 365 startHideMediaControlsTimer();
370 } 366 }
371 367
372 void MediaControls::defaultEventHandler(Event* event) 368 void MediaControls::defaultEventHandler(Event* event)
373 { 369 {
374 HTMLDivElement::defaultEventHandler(event); 370 HTMLDivElement::defaultEventHandler(event);
371 m_wasLastEventTouch = event->isTouchEvent() || event->isGestureEvent()
372 || (event->isMouseEvent() && toMouseEvent(event)->fromTouch());
375 373
376 if (event->type() == EventTypeNames::mouseover) { 374 if (event->type() == EventTypeNames::mouseover) {
377 if (!containsRelatedTarget(event)) { 375 if (!containsRelatedTarget(event)) {
378 m_isMouseOverControls = true; 376 m_isMouseOverControls = true;
379 if (!mediaElement().togglePlayStateWillPlay()) { 377 if (!mediaElement().togglePlayStateWillPlay()) {
380 makeOpaque(); 378 makeOpaque();
381 if (shouldHideMediaControls()) 379 if (shouldHideMediaControls())
382 startHideMediaControlsTimer(); 380 startHideMediaControlsTimer();
383 } 381 }
384 } 382 }
(...skipping 17 matching lines...) Expand all
402 return; 400 return;
403 } 401 }
404 } 402 }
405 403
406 void MediaControls::hideMediaControlsTimerFired(Timer<MediaControls>*) 404 void MediaControls::hideMediaControlsTimerFired(Timer<MediaControls>*)
407 { 405 {
408 if (mediaElement().togglePlayStateWillPlay()) 406 if (mediaElement().togglePlayStateWillPlay())
409 return; 407 return;
410 408
411 unsigned behaviorFlags = IgnoreFocus | IgnoreVideoHover; 409 unsigned behaviorFlags = IgnoreFocus | IgnoreVideoHover;
412 // FIXME: improve this check, see http://www.crbug.com/401177. 410 if (m_wasLastEventTouch) {
413 if (!deviceSupportsMouse(document())) {
414 behaviorFlags |= IgnoreControlsHover; 411 behaviorFlags |= IgnoreControlsHover;
415 } 412 }
416 if (!shouldHideMediaControls(behaviorFlags)) 413 if (!shouldHideMediaControls(behaviorFlags))
417 return; 414 return;
418 415
419 makeTransparent(); 416 makeTransparent();
420 } 417 }
421 418
422 void MediaControls::startHideMediaControlsTimer() 419 void MediaControls::startHideMediaControlsTimer()
423 { 420 {
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
495 visitor->trace(m_muteButton); 492 visitor->trace(m_muteButton);
496 visitor->trace(m_volumeSlider); 493 visitor->trace(m_volumeSlider);
497 visitor->trace(m_toggleClosedCaptionsButton); 494 visitor->trace(m_toggleClosedCaptionsButton);
498 visitor->trace(m_fullScreenButton); 495 visitor->trace(m_fullScreenButton);
499 visitor->trace(m_durationDisplay); 496 visitor->trace(m_durationDisplay);
500 visitor->trace(m_enclosure); 497 visitor->trace(m_enclosure);
501 HTMLDivElement::trace(visitor); 498 HTMLDivElement::trace(visitor);
502 } 499 }
503 500
504 } 501 }
OLDNEW
« no previous file with comments | « Source/core/html/shadow/MediaControls.h ('k') | Source/core/inspector/InspectorInputAgent.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698