1/* 2 * Copyright (C) 2011, 2012 Apple Inc. All rights reserved. 3 * Copyright (C) 2011, 2012 Google Inc. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * 2. Redistributions in binary form must reproduce the above copyright 11 * notice, this list of conditions and the following disclaimer in the 12 * documentation and/or other materials provided with the distribution. 13 * 14 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY 15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 17 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR 18 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 19 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 20 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 21 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 22 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 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. 25 */ 26 27#ifndef MediaControls_h 28#define MediaControls_h 29 30#if ENABLE(VIDEO) 31 32#include "Chrome.h" 33#include "HTMLDivElement.h" 34#include "HTMLMediaElement.h" 35#include "HTMLNames.h" 36#include "MediaControlElements.h" 37#include "MouseEvent.h" 38#include "Page.h" 39#include "RenderTheme.h" 40#include "Text.h" 41#include <wtf/RefPtr.h> 42 43#if ENABLE(VIDEO_TRACK) 44#include "TextTrackCue.h" 45#endif 46 47namespace WebCore { 48 49class Document; 50class Event; 51class Page; 52class MediaPlayer; 53 54class RenderBox; 55class RenderMedia; 56 57// An abstract class with the media control elements that all ports support. 58class MediaControls : public HTMLDivElement { 59 public: 60 virtual ~MediaControls() {} 61 62 // This function is to be implemented in your port-specific media 63 // controls implementation since it will return a child instance. 64 static PassRefPtr<MediaControls> create(Document*); 65 66 virtual void setMediaController(MediaControllerInterface*); 67 68 virtual void reset(); 69 virtual void reportedError(); 70 virtual void loadedMetadata(); 71 72 virtual void show(); 73 virtual void hide(); 74 virtual void makeOpaque(); 75 virtual void makeTransparent(); 76 virtual bool shouldHideControls(); 77 78 virtual void bufferingProgressed(); 79 virtual void playbackStarted(); 80 virtual void playbackProgressed(); 81 virtual void playbackStopped(); 82 83 virtual void updateStatusDisplay() { }; 84 virtual void updateCurrentTimeDisplay(); 85 virtual void showVolumeSlider(); 86 87 virtual void changedMute(); 88 virtual void changedVolume(); 89 90 virtual void changedClosedCaptionsVisibility(); 91 virtual void refreshClosedCaptionsButtonVisibility(); 92 virtual void toggleClosedCaptionTrackList() { } 93 virtual void closedCaptionTracksChanged(); 94 95 virtual void enteredFullscreen(); 96 virtual void exitedFullscreen(); 97 98 virtual bool willRespondToMouseMoveEvents() OVERRIDE { return true; } 99 100 virtual void hideFullscreenControlsTimerFired(Timer<MediaControls>*); 101 virtual void startHideFullscreenControlsTimer(); 102 virtual void stopHideFullscreenControlsTimer(); 103 104#if ENABLE(VIDEO_TRACK) 105 virtual void createTextTrackDisplay(); 106 virtual void showTextTrackDisplay(); 107 virtual void hideTextTrackDisplay(); 108 virtual void updateTextTrackDisplay(); 109 virtual void textTrackPreferencesChanged(); 110#endif 111 112protected: 113 explicit MediaControls(Document*); 114 115 virtual void defaultEventHandler(Event*); 116 117 virtual bool containsRelatedTarget(Event*); 118 119 MediaControllerInterface* m_mediaController; 120 121 // Container for the media control elements. 122 MediaControlPanelElement* m_panel; 123 124 // Container for the text track cues. 125#if ENABLE(VIDEO_TRACK) 126 MediaControlTextTrackContainerElement* m_textDisplayContainer; 127#endif 128 129 // Media control elements. 130 MediaControlPlayButtonElement* m_playButton; 131 MediaControlCurrentTimeDisplayElement* m_currentTimeDisplay; 132 MediaControlTimelineElement* m_timeline; 133 MediaControlPanelMuteButtonElement* m_panelMuteButton; 134 MediaControlPanelVolumeSliderElement* m_volumeSlider; 135 MediaControlToggleClosedCaptionsButtonElement* m_toggleClosedCaptionsButton; 136 MediaControlFullscreenButtonElement* m_fullScreenButton; 137 138 Timer<MediaControls> m_hideFullscreenControlsTimer; 139 bool m_isFullscreen; 140 bool m_isMouseOverControls; 141 142private: 143 virtual bool isMediaControls() const { return true; } 144 145 virtual const AtomicString& shadowPseudoId() const; 146}; 147 148inline MediaControls* toMediaControls(Node* node) 149{ 150 ASSERT_WITH_SECURITY_IMPLICATION(!node || node->isMediaControls()); 151 return static_cast<MediaControls*>(node); 152} 153 154// This will catch anyone doing an unneccessary cast. 155void toMediaControls(const MediaControls*); 156 157} 158 159#endif 160 161#endif 162