| 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 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 557 // to allow the hide-timer to do the right thing when it fires. | 556 // to allow the hide-timer to do the right thing when it fires. |
| 558 // FIXME: Preferably we would only do this when we're actually handling the
event | 557 // FIXME: Preferably we would only do this when we're actually handling the
event |
| 559 // here ourselves. | 558 // here ourselves. |
| 560 bool wasLastEventTouch = event->isTouchEvent() || event->isGestureEvent() | 559 bool wasLastEventTouch = event->isTouchEvent() || event->isGestureEvent() |
| 561 || (event->isMouseEvent() && toMouseEvent(event)->fromTouch()); | 560 || (event->isMouseEvent() && toMouseEvent(event)->fromTouch()); |
| 562 m_hideTimerBehaviorFlags |= wasLastEventTouch ? IgnoreControlsHover : Ignore
None; | 561 m_hideTimerBehaviorFlags |= wasLastEventTouch ? IgnoreControlsHover : Ignore
None; |
| 563 | 562 |
| 564 if (event->type() == EventTypeNames::mouseover) { | 563 if (event->type() == EventTypeNames::mouseover) { |
| 565 if (!containsRelatedTarget(event)) { | 564 if (!containsRelatedTarget(event)) { |
| 566 m_isMouseOverControls = true; | 565 m_isMouseOverControls = true; |
| 567 if (!mediaElement().togglePlayStateWillPlay()) { | 566 if (!mediaElement().paused()) { |
| 568 makeOpaque(); | 567 makeOpaque(); |
| 569 if (shouldHideMediaControls()) | 568 if (shouldHideMediaControls()) |
| 570 startHideMediaControlsTimer(); | 569 startHideMediaControlsTimer(); |
| 571 } | 570 } |
| 572 } | 571 } |
| 573 return; | 572 return; |
| 574 } | 573 } |
| 575 | 574 |
| 576 if (event->type() == EventTypeNames::mouseout) { | 575 if (event->type() == EventTypeNames::mouseout) { |
| 577 if (!containsRelatedTarget(event)) { | 576 if (!containsRelatedTarget(event)) { |
| (...skipping 12 matching lines...) Expand all Loading... |
| 590 startHideMediaControlsTimer(); | 589 startHideMediaControlsTimer(); |
| 591 return; | 590 return; |
| 592 } | 591 } |
| 593 } | 592 } |
| 594 | 593 |
| 595 void MediaControls::hideMediaControlsTimerFired(Timer<MediaControls>*) | 594 void MediaControls::hideMediaControlsTimerFired(Timer<MediaControls>*) |
| 596 { | 595 { |
| 597 unsigned behaviorFlags = m_hideTimerBehaviorFlags | IgnoreFocus | IgnoreVide
oHover; | 596 unsigned behaviorFlags = m_hideTimerBehaviorFlags | IgnoreFocus | IgnoreVide
oHover; |
| 598 m_hideTimerBehaviorFlags = IgnoreNone; | 597 m_hideTimerBehaviorFlags = IgnoreNone; |
| 599 | 598 |
| 600 if (mediaElement().togglePlayStateWillPlay()) | 599 if (mediaElement().paused()) |
| 601 return; | 600 return; |
| 602 | 601 |
| 603 if (!shouldHideMediaControls(behaviorFlags)) | 602 if (!shouldHideMediaControls(behaviorFlags)) |
| 604 return; | 603 return; |
| 605 | 604 |
| 606 makeTransparent(); | 605 makeTransparent(); |
| 607 m_overlayCastButton->setIsWanted(false); | 606 m_overlayCastButton->setIsWanted(false); |
| 608 } | 607 } |
| 609 | 608 |
| 610 void MediaControls::startHideMediaControlsTimer() | 609 void MediaControls::startHideMediaControlsTimer() |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 736 visitor->trace(m_toggleClosedCaptionsButton); | 735 visitor->trace(m_toggleClosedCaptionsButton); |
| 737 visitor->trace(m_fullScreenButton); | 736 visitor->trace(m_fullScreenButton); |
| 738 visitor->trace(m_durationDisplay); | 737 visitor->trace(m_durationDisplay); |
| 739 visitor->trace(m_enclosure); | 738 visitor->trace(m_enclosure); |
| 740 visitor->trace(m_castButton); | 739 visitor->trace(m_castButton); |
| 741 visitor->trace(m_overlayCastButton); | 740 visitor->trace(m_overlayCastButton); |
| 742 HTMLDivElement::trace(visitor); | 741 HTMLDivElement::trace(visitor); |
| 743 } | 742 } |
| 744 | 743 |
| 745 } | 744 } |
| OLD | NEW |