| 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 10 matching lines...) Expand all Loading... |
| 21 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | 21 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
| 22 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 22 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 25 */ | 25 */ |
| 26 | 26 |
| 27 #include "config.h" | 27 #include "config.h" |
| 28 #include "core/html/shadow/MediaControls.h" | 28 #include "core/html/shadow/MediaControls.h" |
| 29 | 29 |
| 30 #include "bindings/core/v8/ExceptionStatePlaceholder.h" | 30 #include "bindings/core/v8/ExceptionStatePlaceholder.h" |
| 31 #include "core/dom/ClientRect.h" |
| 31 #include "core/events/MouseEvent.h" | 32 #include "core/events/MouseEvent.h" |
| 32 #include "core/frame/Settings.h" | 33 #include "core/frame/Settings.h" |
| 33 #include "core/html/HTMLMediaElement.h" | 34 #include "core/html/HTMLMediaElement.h" |
| 34 #include "core/html/MediaController.h" | 35 #include "core/html/MediaController.h" |
| 35 #include "core/rendering/RenderTheme.h" | 36 #include "core/rendering/RenderTheme.h" |
| 36 | 37 |
| 37 namespace blink { | 38 namespace blink { |
| 38 | 39 |
| 39 // If you change this value, then also update the corresponding value in | 40 // If you change this value, then also update the corresponding value in |
| 40 // LayoutTests/media/media-controls.js. | 41 // LayoutTests/media/media-controls.js. |
| (...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 373 // The reason for the autoplay test is that some pages (e.g. vimeo.com)
have an autoplay background video, which | 374 // The reason for the autoplay test is that some pages (e.g. vimeo.com)
have an autoplay background video, which |
| 374 // doesn't autoplay on Chrome for Android (we prevent it) so starts paus
ed. In such cases we don't want to automatically | 375 // doesn't autoplay on Chrome for Android (we prevent it) so starts paus
ed. In such cases we don't want to automatically |
| 375 // show the cast button, since it looks strange and is unlikely to corre
spond with anything the user wants to do. | 376 // show the cast button, since it looks strange and is unlikely to corre
spond with anything the user wants to do. |
| 376 // If a user does want to cast a paused autoplay video then they can sti
ll do so by touching or clicking on the | 377 // If a user does want to cast a paused autoplay video then they can sti
ll do so by touching or clicking on the |
| 377 // video, which will cause the cast button to appear. | 378 // video, which will cause the cast button to appear. |
| 378 if (!mediaElement().shouldShowControls() && !mediaElement().autoplay() &
& mediaElement().paused()) { | 379 if (!mediaElement().shouldShowControls() && !mediaElement().autoplay() &
& mediaElement().paused()) { |
| 379 showOverlayCastButton(); | 380 showOverlayCastButton(); |
| 380 } else if (mediaElement().shouldShowControls()) { | 381 } else if (mediaElement().shouldShowControls()) { |
| 381 m_overlayCastButton->hide(); | 382 m_overlayCastButton->hide(); |
| 382 m_castButton->show(); | 383 m_castButton->show(); |
| 384 // Check that the cast button actually fits on the bar. |
| 385 if (m_fullScreenButton->getBoundingClientRect()->right() > m_panel->
getBoundingClientRect()->right()) { |
| 386 m_castButton->hide(); |
| 387 m_overlayCastButton->show(); |
| 388 } |
| 383 } | 389 } |
| 384 } else { | 390 } else { |
| 385 m_castButton->hide(); | 391 m_castButton->hide(); |
| 386 m_overlayCastButton->hide(); | 392 m_overlayCastButton->hide(); |
| 387 } | 393 } |
| 388 } | 394 } |
| 389 | 395 |
| 390 void MediaControls::showOverlayCastButton() | 396 void MediaControls::showOverlayCastButton() |
| 391 { | 397 { |
| 392 m_overlayCastButton->show(); | 398 m_overlayCastButton->show(); |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 442 m_isMouseOverControls = false; | 448 m_isMouseOverControls = false; |
| 443 stopHideMediaControlsTimer(); | 449 stopHideMediaControlsTimer(); |
| 444 } | 450 } |
| 445 return; | 451 return; |
| 446 } | 452 } |
| 447 | 453 |
| 448 if (event->type() == EventTypeNames::mousemove) { | 454 if (event->type() == EventTypeNames::mousemove) { |
| 449 // When we get a mouse move, show the media controls, and start a timer | 455 // When we get a mouse move, show the media controls, and start a timer |
| 450 // that will hide the media controls after a 3 seconds without a mouse m
ove. | 456 // that will hide the media controls after a 3 seconds without a mouse m
ove. |
| 451 makeOpaque(); | 457 makeOpaque(); |
| 458 refreshCastButtonVisibility(); |
| 452 if (shouldHideMediaControls(IgnoreVideoHover)) | 459 if (shouldHideMediaControls(IgnoreVideoHover)) |
| 453 startHideMediaControlsTimer(); | 460 startHideMediaControlsTimer(); |
| 454 return; | 461 return; |
| 455 } | 462 } |
| 456 } | 463 } |
| 457 | 464 |
| 458 void MediaControls::hideMediaControlsTimerFired(Timer<MediaControls>*) | 465 void MediaControls::hideMediaControlsTimerFired(Timer<MediaControls>*) |
| 459 { | 466 { |
| 460 if (mediaElement().togglePlayStateWillPlay()) | 467 if (mediaElement().togglePlayStateWillPlay()) |
| 461 return; | 468 return; |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 557 visitor->trace(m_toggleClosedCaptionsButton); | 564 visitor->trace(m_toggleClosedCaptionsButton); |
| 558 visitor->trace(m_fullScreenButton); | 565 visitor->trace(m_fullScreenButton); |
| 559 visitor->trace(m_durationDisplay); | 566 visitor->trace(m_durationDisplay); |
| 560 visitor->trace(m_enclosure); | 567 visitor->trace(m_enclosure); |
| 561 visitor->trace(m_castButton); | 568 visitor->trace(m_castButton); |
| 562 visitor->trace(m_overlayCastButton); | 569 visitor->trace(m_overlayCastButton); |
| 563 HTMLDivElement::trace(visitor); | 570 HTMLDivElement::trace(visitor); |
| 564 } | 571 } |
| 565 | 572 |
| 566 } | 573 } |
| OLD | NEW |