| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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->isMouseEvent() && toM
ouseEvent(event)->derivesFromTouch()); |
| 375 | 372 |
| 376 if (event->type() == EventTypeNames::mouseover) { | 373 if (event->type() == EventTypeNames::mouseover) { |
| 377 if (!containsRelatedTarget(event)) { | 374 if (!containsRelatedTarget(event)) { |
| 378 m_isMouseOverControls = true; | 375 m_isMouseOverControls = true; |
| 379 if (!mediaElement().togglePlayStateWillPlay()) { | 376 if (!mediaElement().togglePlayStateWillPlay()) { |
| 380 makeOpaque(); | 377 makeOpaque(); |
| 381 if (shouldHideMediaControls()) | 378 if (shouldHideMediaControls()) |
| 382 startHideMediaControlsTimer(); | 379 startHideMediaControlsTimer(); |
| 383 } | 380 } |
| 384 } | 381 } |
| (...skipping 17 matching lines...) Expand all Loading... |
| 402 return; | 399 return; |
| 403 } | 400 } |
| 404 } | 401 } |
| 405 | 402 |
| 406 void MediaControls::hideMediaControlsTimerFired(Timer<MediaControls>*) | 403 void MediaControls::hideMediaControlsTimerFired(Timer<MediaControls>*) |
| 407 { | 404 { |
| 408 if (mediaElement().togglePlayStateWillPlay()) | 405 if (mediaElement().togglePlayStateWillPlay()) |
| 409 return; | 406 return; |
| 410 | 407 |
| 411 unsigned behaviorFlags = IgnoreFocus | IgnoreVideoHover; | 408 unsigned behaviorFlags = IgnoreFocus | IgnoreVideoHover; |
| 412 // TODO(igsolla): improve this check, see http://www.crbug.com/401177. | 409 if (m_wasLastEventTouch) { |
| 413 if (!deviceSupportsMouse(document())) { | |
| 414 behaviorFlags |= IgnoreControlsHover; | 410 behaviorFlags |= IgnoreControlsHover; |
| 415 } | 411 } |
| 416 if (!shouldHideMediaControls(behaviorFlags)) | 412 if (!shouldHideMediaControls(behaviorFlags)) |
| 417 return; | 413 return; |
| 418 | 414 |
| 419 makeTransparent(); | 415 makeTransparent(); |
| 420 } | 416 } |
| 421 | 417 |
| 422 void MediaControls::startHideMediaControlsTimer() | 418 void MediaControls::startHideMediaControlsTimer() |
| 423 { | 419 { |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 495 visitor->trace(m_muteButton); | 491 visitor->trace(m_muteButton); |
| 496 visitor->trace(m_volumeSlider); | 492 visitor->trace(m_volumeSlider); |
| 497 visitor->trace(m_toggleClosedCaptionsButton); | 493 visitor->trace(m_toggleClosedCaptionsButton); |
| 498 visitor->trace(m_fullScreenButton); | 494 visitor->trace(m_fullScreenButton); |
| 499 visitor->trace(m_durationDisplay); | 495 visitor->trace(m_durationDisplay); |
| 500 visitor->trace(m_enclosure); | 496 visitor->trace(m_enclosure); |
| 501 HTMLDivElement::trace(visitor); | 497 HTMLDivElement::trace(visitor); |
| 502 } | 498 } |
| 503 | 499 |
| 504 } | 500 } |
| OLD | NEW |