| 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 15 matching lines...) Expand all Loading... |
| 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/dom/ClientRect.h" |
| 32 #include "core/dom/Fullscreen.h" | 32 #include "core/dom/Fullscreen.h" |
| 33 #include "core/events/MouseEvent.h" | 33 #include "core/events/MouseEvent.h" |
| 34 #include "core/frame/Settings.h" | 34 #include "core/frame/Settings.h" |
| 35 #include "core/html/HTMLMediaElement.h" | 35 #include "core/html/HTMLMediaElement.h" |
| 36 #include "core/html/MediaController.h" | |
| 37 #include "core/html/track/TextTrackContainer.h" | 36 #include "core/html/track/TextTrackContainer.h" |
| 38 #include "core/layout/LayoutTheme.h" | 37 #include "core/layout/LayoutTheme.h" |
| 39 | 38 |
| 40 namespace blink { | 39 namespace blink { |
| 41 | 40 |
| 42 // If you change this value, then also update the corresponding value in | 41 // If you change this value, then also update the corresponding value in |
| 43 // LayoutTests/media/media-controls.js. | 42 // LayoutTests/media/media-controls.js. |
| 44 static const double timeWithoutMouseMovementBeforeHidingMediaControls = 3; | 43 static const double timeWithoutMouseMovementBeforeHidingMediaControls = 3; |
| 45 | 44 |
| 46 static bool shouldShowFullscreenButton(const HTMLMediaElement& mediaElement) | 45 static bool shouldShowFullscreenButton(const HTMLMediaElement& mediaElement) |
| (...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 372 if (m_isPausedForScrubbing) | 371 if (m_isPausedForScrubbing) |
| 373 return; | 372 return; |
| 374 | 373 |
| 375 if (m_overlayPlayButton) | 374 if (m_overlayPlayButton) |
| 376 m_overlayPlayButton->updateDisplayType(); | 375 m_overlayPlayButton->updateDisplayType(); |
| 377 m_playButton->updateDisplayType(); | 376 m_playButton->updateDisplayType(); |
| 378 } | 377 } |
| 379 | 378 |
| 380 void MediaControls::beginScrubbing() | 379 void MediaControls::beginScrubbing() |
| 381 { | 380 { |
| 382 if (!mediaElement().togglePlayStateWillPlay()) { | 381 if (!mediaElement().paused()) { |
| 383 m_isPausedForScrubbing = true; | 382 m_isPausedForScrubbing = true; |
| 384 mediaElement().togglePlayState(); | 383 mediaElement().pause(); |
| 385 } | 384 } |
| 386 } | 385 } |
| 387 | 386 |
| 388 void MediaControls::endScrubbing() | 387 void MediaControls::endScrubbing() |
| 389 { | 388 { |
| 390 if (m_isPausedForScrubbing) { | 389 if (m_isPausedForScrubbing) { |
| 391 m_isPausedForScrubbing = false; | 390 m_isPausedForScrubbing = false; |
| 392 if (mediaElement().togglePlayStateWillPlay()) | 391 if (mediaElement().paused()) |
| 393 mediaElement().togglePlayState(); | 392 mediaElement().play(); |
| 394 } | 393 } |
| 395 } | 394 } |
| 396 | 395 |
| 397 void MediaControls::updateCurrentTimeDisplay() | 396 void MediaControls::updateCurrentTimeDisplay() |
| 398 { | 397 { |
| 399 double now = mediaElement().currentTime(); | 398 double now = mediaElement().currentTime(); |
| 400 double duration = mediaElement().duration(); | 399 double duration = mediaElement().duration(); |
| 401 | 400 |
| 402 // After seek, hide duration display and show current time. | 401 // After seek, hide duration display and show current time. |
| 403 if (!RuntimeEnabledFeatures::newMediaPlaybackUiEnabled() && now > 0) { | 402 if (!RuntimeEnabledFeatures::newMediaPlaybackUiEnabled() && now > 0) { |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 540 // to allow the hide-timer to do the right thing when it fires. | 539 // to allow the hide-timer to do the right thing when it fires. |
| 541 // FIXME: Preferably we would only do this when we're actually handling the
event | 540 // FIXME: Preferably we would only do this when we're actually handling the
event |
| 542 // here ourselves. | 541 // here ourselves. |
| 543 bool wasLastEventTouch = event->isTouchEvent() || event->isGestureEvent() | 542 bool wasLastEventTouch = event->isTouchEvent() || event->isGestureEvent() |
| 544 || (event->isMouseEvent() && toMouseEvent(event)->fromTouch()); | 543 || (event->isMouseEvent() && toMouseEvent(event)->fromTouch()); |
| 545 m_hideTimerBehaviorFlags |= wasLastEventTouch ? IgnoreControlsHover : Ignore
None; | 544 m_hideTimerBehaviorFlags |= wasLastEventTouch ? IgnoreControlsHover : Ignore
None; |
| 546 | 545 |
| 547 if (event->type() == EventTypeNames::mouseover) { | 546 if (event->type() == EventTypeNames::mouseover) { |
| 548 if (!containsRelatedTarget(event)) { | 547 if (!containsRelatedTarget(event)) { |
| 549 m_isMouseOverControls = true; | 548 m_isMouseOverControls = true; |
| 550 if (!mediaElement().togglePlayStateWillPlay()) { | 549 if (!mediaElement().paused()) { |
| 551 makeOpaque(); | 550 makeOpaque(); |
| 552 if (shouldHideMediaControls()) | 551 if (shouldHideMediaControls()) |
| 553 startHideMediaControlsTimer(); | 552 startHideMediaControlsTimer(); |
| 554 } | 553 } |
| 555 } | 554 } |
| 556 return; | 555 return; |
| 557 } | 556 } |
| 558 | 557 |
| 559 if (event->type() == EventTypeNames::mouseout) { | 558 if (event->type() == EventTypeNames::mouseout) { |
| 560 if (!containsRelatedTarget(event)) { | 559 if (!containsRelatedTarget(event)) { |
| (...skipping 12 matching lines...) Expand all Loading... |
| 573 startHideMediaControlsTimer(); | 572 startHideMediaControlsTimer(); |
| 574 return; | 573 return; |
| 575 } | 574 } |
| 576 } | 575 } |
| 577 | 576 |
| 578 void MediaControls::hideMediaControlsTimerFired(Timer<MediaControls>*) | 577 void MediaControls::hideMediaControlsTimerFired(Timer<MediaControls>*) |
| 579 { | 578 { |
| 580 unsigned behaviorFlags = m_hideTimerBehaviorFlags | IgnoreFocus | IgnoreVide
oHover; | 579 unsigned behaviorFlags = m_hideTimerBehaviorFlags | IgnoreFocus | IgnoreVide
oHover; |
| 581 m_hideTimerBehaviorFlags = IgnoreNone; | 580 m_hideTimerBehaviorFlags = IgnoreNone; |
| 582 | 581 |
| 583 if (mediaElement().togglePlayStateWillPlay()) | 582 if (mediaElement().paused()) |
| 584 return; | 583 return; |
| 585 | 584 |
| 586 if (!shouldHideMediaControls(behaviorFlags)) | 585 if (!shouldHideMediaControls(behaviorFlags)) |
| 587 return; | 586 return; |
| 588 | 587 |
| 589 makeTransparent(); | 588 makeTransparent(); |
| 590 m_overlayCastButton->setIsWanted(false); | 589 m_overlayCastButton->setIsWanted(false); |
| 591 } | 590 } |
| 592 | 591 |
| 593 void MediaControls::startHideMediaControlsTimer() | 592 void MediaControls::startHideMediaControlsTimer() |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 723 visitor->trace(m_toggleClosedCaptionsButton); | 722 visitor->trace(m_toggleClosedCaptionsButton); |
| 724 visitor->trace(m_fullScreenButton); | 723 visitor->trace(m_fullScreenButton); |
| 725 visitor->trace(m_durationDisplay); | 724 visitor->trace(m_durationDisplay); |
| 726 visitor->trace(m_enclosure); | 725 visitor->trace(m_enclosure); |
| 727 visitor->trace(m_castButton); | 726 visitor->trace(m_castButton); |
| 728 visitor->trace(m_overlayCastButton); | 727 visitor->trace(m_overlayCastButton); |
| 729 HTMLDivElement::trace(visitor); | 728 HTMLDivElement::trace(visitor); |
| 730 } | 729 } |
| 731 | 730 |
| 732 } | 731 } |
| OLD | NEW |