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 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 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 | #pragma once |
28 | |
29 | #if ENABLE(VIDEO) |
30 | |
31 | #include "Chrome.h" |
32 | #include "HTMLDivElement.h" |
33 | #include "MediaControlElements.h" |
34 | #include <wtf/RefPtr.h> |
35 | |
36 | #if ENABLE(VIDEO_TRACK) |
37 | #include "TextTrackCue.h" |
38 | #endif |
39 | |
40 | namespace WebCore { |
41 | |
42 | class Document; |
43 | class Event; |
44 | class MediaPlayer; |
45 | |
46 | class RenderBox; |
47 | class RenderMedia; |
48 | |
49 | // An abstract class with the media control elements that all ports support. |
50 | class MediaControls : public HTMLDivElement { |
51 | WTF_MAKE_ISO_ALLOCATED(MediaControls); |
52 | public: |
53 | virtual ~MediaControls() = default; |
54 | |
55 | // This function is to be implemented in your port-specific media |
56 | // controls implementation since it will return a child instance. |
57 | static RefPtr<MediaControls> tryCreate(Document&); |
58 | |
59 | virtual void setMediaController(MediaControllerInterface*); |
60 | |
61 | virtual void reset(); |
62 | virtual void reportedError(); |
63 | virtual void loadedMetadata(); |
64 | |
65 | virtual void show(); |
66 | virtual void hide(); |
67 | virtual void makeOpaque(); |
68 | virtual void makeTransparent(); |
69 | virtual bool shouldHideControls(); |
70 | |
71 | virtual void bufferingProgressed(); |
72 | virtual void playbackStarted(); |
73 | virtual void playbackProgressed(); |
74 | virtual void playbackStopped(); |
75 | |
76 | virtual void updateStatusDisplay() { }; |
77 | virtual void updateCurrentTimeDisplay(); |
78 | virtual void showVolumeSlider(); |
79 | |
80 | virtual void changedMute(); |
81 | virtual void changedVolume(); |
82 | |
83 | virtual void changedClosedCaptionsVisibility(); |
84 | virtual void refreshClosedCaptionsButtonVisibility(); |
85 | virtual void toggleClosedCaptionTrackList() { } |
86 | virtual void closedCaptionTracksChanged(); |
87 | |
88 | virtual void enteredFullscreen(); |
89 | virtual void exitedFullscreen(); |
90 | |
91 | #if !PLATFORM(IOS_FAMILY) |
92 | bool willRespondToMouseMoveEvents() override { return true; } |
93 | #endif |
94 | |
95 | virtual void hideFullscreenControlsTimerFired(); |
96 | virtual void startHideFullscreenControlsTimer(); |
97 | virtual void stopHideFullscreenControlsTimer(); |
98 | |
99 | #if ENABLE(VIDEO_TRACK) |
100 | virtual void createTextTrackDisplay(); |
101 | virtual void showTextTrackDisplay(); |
102 | virtual void hideTextTrackDisplay(); |
103 | virtual void updateTextTrackDisplay(); |
104 | virtual void textTrackPreferencesChanged(); |
105 | virtual void clearTextDisplayContainer(); |
106 | #endif |
107 | |
108 | protected: |
109 | explicit MediaControls(Document&); |
110 | |
111 | void defaultEventHandler(Event&) override; |
112 | |
113 | virtual bool containsRelatedTarget(Event&); |
114 | |
115 | void setSliderVolume(); |
116 | |
117 | MediaControllerInterface* m_mediaController; |
118 | |
119 | // Container for the media control elements. |
120 | MediaControlPanelElement* m_panel; |
121 | |
122 | // Container for the text track cues. |
123 | #if ENABLE(VIDEO_TRACK) |
124 | MediaControlTextTrackContainerElement* m_textDisplayContainer; |
125 | #endif |
126 | |
127 | // Media control elements. |
128 | MediaControlPlayButtonElement* m_playButton; |
129 | MediaControlCurrentTimeDisplayElement* m_currentTimeDisplay; |
130 | MediaControlTimelineElement* m_timeline; |
131 | MediaControlPanelMuteButtonElement* m_panelMuteButton; |
132 | MediaControlPanelVolumeSliderElement* m_volumeSlider; |
133 | MediaControlToggleClosedCaptionsButtonElement* m_toggleClosedCaptionsButton; |
134 | MediaControlFullscreenButtonElement* m_fullScreenButton; |
135 | |
136 | Timer m_hideFullscreenControlsTimer; |
137 | bool m_isFullscreen; |
138 | bool m_isMouseOverControls; |
139 | |
140 | private: |
141 | bool isMediaControls() const final { return true; } |
142 | }; |
143 | |
144 | inline MediaControls* toMediaControls(Node* node) |
145 | { |
146 | ASSERT_WITH_SECURITY_IMPLICATION(!node || node->isMediaControls()); |
147 | return static_cast<MediaControls*>(node); |
148 | } |
149 | |
150 | // This will catch anyone doing an unneccessary cast. |
151 | void toMediaControls(const MediaControls*); |
152 | |
153 | } // namespace WebCore |
154 | |
155 | #endif // ENABLE(VIDEO) |
156 | |