| 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 401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 412 return false; | 412 return false; |
| 413 } | 413 } |
| 414 | 414 |
| 415 // Don't hide the media controls when a panel is showing. | 415 // Don't hide the media controls when a panel is showing. |
| 416 if (m_textTrackList->isWanted() || m_overflowList->isWanted()) | 416 if (m_textTrackList->isWanted() || m_overflowList->isWanted()) |
| 417 return false; | 417 return false; |
| 418 | 418 |
| 419 return true; | 419 return true; |
| 420 } | 420 } |
| 421 | 421 |
| 422 void MediaControls::playbackStarted() { | |
| 423 BatchedControlUpdate batch(this); | |
| 424 updatePlayState(); | |
| 425 m_timeline->setPosition(mediaElement().currentTime()); | |
| 426 updateCurrentTimeDisplay(); | |
| 427 | |
| 428 startHideMediaControlsTimer(); | |
| 429 } | |
| 430 | |
| 431 void MediaControls::playbackProgressed() { | |
| 432 m_timeline->setPosition(mediaElement().currentTime()); | |
| 433 updateCurrentTimeDisplay(); | |
| 434 | |
| 435 if (isVisible() && shouldHideMediaControls()) | |
| 436 makeTransparent(); | |
| 437 } | |
| 438 | |
| 439 void MediaControls::playbackStopped() { | |
| 440 updatePlayState(); | |
| 441 m_timeline->setPosition(mediaElement().currentTime()); | |
| 442 updateCurrentTimeDisplay(); | |
| 443 makeOpaque(); | |
| 444 | |
| 445 stopHideMediaControlsTimer(); | |
| 446 } | |
| 447 | |
| 448 void MediaControls::updatePlayState() { | 422 void MediaControls::updatePlayState() { |
| 449 if (m_isPausedForScrubbing) | 423 if (m_isPausedForScrubbing) |
| 450 return; | 424 return; |
| 451 | 425 |
| 452 if (m_overlayPlayButton) | 426 if (m_overlayPlayButton) |
| 453 m_overlayPlayButton->updateDisplayType(); | 427 m_overlayPlayButton->updateDisplayType(); |
| 454 m_playButton->updateDisplayType(); | 428 m_playButton->updateDisplayType(); |
| 455 } | 429 } |
| 456 | 430 |
| 457 void MediaControls::beginScrubbing() { | 431 void MediaControls::beginScrubbing() { |
| (...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 711 } | 685 } |
| 712 | 686 |
| 713 void MediaControls::onFocusIn() { | 687 void MediaControls::onFocusIn() { |
| 714 if (!mediaElement().shouldShowControls()) | 688 if (!mediaElement().shouldShowControls()) |
| 715 return; | 689 return; |
| 716 | 690 |
| 717 show(); | 691 show(); |
| 718 resetHideMediaControlsTimer(); | 692 resetHideMediaControlsTimer(); |
| 719 } | 693 } |
| 720 | 694 |
| 695 void MediaControls::onTimeUpdate() { |
| 696 m_timeline->setPosition(mediaElement().currentTime()); |
| 697 updateCurrentTimeDisplay(); |
| 698 |
| 699 // 'timeupdate' might be called in a paused state. The controls should not |
| 700 // become transparent in that case. |
| 701 if (mediaElement().paused()) { |
| 702 makeOpaque(); |
| 703 return; |
| 704 } |
| 705 |
| 706 if (isVisible() && shouldHideMediaControls()) |
| 707 makeTransparent(); |
| 708 } |
| 709 |
| 710 void MediaControls::onPlay() { |
| 711 updatePlayState(); |
| 712 m_timeline->setPosition(mediaElement().currentTime()); |
| 713 updateCurrentTimeDisplay(); |
| 714 |
| 715 startHideMediaControlsTimer(); |
| 716 } |
| 717 |
| 718 void MediaControls::onPause() { |
| 719 updatePlayState(); |
| 720 m_timeline->setPosition(mediaElement().currentTime()); |
| 721 updateCurrentTimeDisplay(); |
| 722 makeOpaque(); |
| 723 |
| 724 stopHideMediaControlsTimer(); |
| 725 } |
| 726 |
| 721 void MediaControls::notifyPanelWidthChanged(const LayoutUnit& newWidth) { | 727 void MediaControls::notifyPanelWidthChanged(const LayoutUnit& newWidth) { |
| 722 // Don't bother to do any work if this matches the most recent panel | 728 // Don't bother to do any work if this matches the most recent panel |
| 723 // width, since we're called after layout. | 729 // width, since we're called after layout. |
| 724 // Note that this code permits a bad frame on resize, since it is | 730 // Note that this code permits a bad frame on resize, since it is |
| 725 // run after the relayout / paint happens. It would be great to improve | 731 // run after the relayout / paint happens. It would be great to improve |
| 726 // this, but it would be even greater to move this code entirely to | 732 // this, but it would be even greater to move this code entirely to |
| 727 // JS and fix it there. | 733 // JS and fix it there. |
| 728 m_panelWidth = newWidth.toInt(); | 734 m_panelWidth = newWidth.toInt(); |
| 729 | 735 |
| 730 // Adjust for effective zoom. | 736 // Adjust for effective zoom. |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 908 visitor->trace(m_overflowMenu); | 914 visitor->trace(m_overflowMenu); |
| 909 visitor->trace(m_overflowList); | 915 visitor->trace(m_overflowList); |
| 910 visitor->trace(m_castButton); | 916 visitor->trace(m_castButton); |
| 911 visitor->trace(m_overlayCastButton); | 917 visitor->trace(m_overlayCastButton); |
| 912 visitor->trace(m_mediaEventListener); | 918 visitor->trace(m_mediaEventListener); |
| 913 visitor->trace(m_windowEventListener); | 919 visitor->trace(m_windowEventListener); |
| 914 HTMLDivElement::trace(visitor); | 920 HTMLDivElement::trace(visitor); |
| 915 } | 921 } |
| 916 | 922 |
| 917 } // namespace blink | 923 } // namespace blink |
| OLD | NEW |