blob: fb534474035981ac0413c22a3ac647077eaaa348 [file] [log] [blame]
Torne (Richard Coles)53e740f2013-05-09 18:38:43 +01001/*
2 * Copyright (C) 2008, 2009, 2010, 2011 Apple Inc. All rights reserved.
3 * Copyright (C) 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 *
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
15 * its contributors may be used to endorse or promote products derived
16 * from this software without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
19 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
22 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
25 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 */
29
30#ifndef MediaControlElementTypes_h
31#define MediaControlElementTypes_h
32
33#include "core/html/HTMLDivElement.h"
34#include "core/html/HTMLInputElement.h"
35#include "core/html/HTMLMediaElement.h"
36#include "core/html/MediaControllerInterface.h"
37#include "core/rendering/RenderBlock.h"
38
39namespace WebCore {
40
41// Must match WebKitSystemInterface.h
42enum MediaControlElementType {
43 MediaEnterFullscreenButton = 0,
44 MediaMuteButton,
45 MediaPlayButton,
46 MediaSeekBackButton,
47 MediaSeekForwardButton,
48 MediaSlider,
49 MediaSliderThumb,
50 MediaRewindButton,
51 MediaReturnToRealtimeButton,
52 MediaShowClosedCaptionsButton,
53 MediaHideClosedCaptionsButton,
54 MediaUnMuteButton,
55 MediaPauseButton,
56 MediaTimelineContainer,
57 MediaCurrentTimeDisplay,
58 MediaTimeRemainingDisplay,
59 MediaStatusDisplay,
60 MediaControlsPanel,
61 MediaVolumeSliderContainer,
62 MediaVolumeSlider,
63 MediaVolumeSliderThumb,
64 MediaFullScreenVolumeSlider,
65 MediaFullScreenVolumeSliderThumb,
66 MediaVolumeSliderMuteButton,
67 MediaTextTrackDisplayContainer,
68 MediaTextTrackDisplay,
69 MediaExitFullscreenButton,
70 MediaOverlayPlayButton,
Torne (Richard Coles)53e740f2013-05-09 18:38:43 +010071};
72
73HTMLMediaElement* toParentMediaElement(Node*);
74inline HTMLMediaElement* toParentMediaElement(RenderObject* renderer) { return toParentMediaElement(renderer->node()); }
75
76MediaControlElementType mediaControlElementType(Node*);
77
Torne (Richard Coles)53e740f2013-05-09 18:38:43 +010078// ----------------------------
79
80class MediaControlElement {
81public:
82 virtual void hide();
83 virtual void show();
84 virtual bool isShowing() const;
85
86 virtual MediaControlElementType displayType() { return m_displayType; }
Ben Murdoch3c9e4ae2013-08-12 14:20:44 +010087 virtual const AtomicString& part() const = 0;
Torne (Richard Coles)53e740f2013-05-09 18:38:43 +010088
89 virtual void setMediaController(MediaControllerInterface* controller) { m_mediaController = controller; }
90 virtual MediaControllerInterface* mediaController() const { return m_mediaController; }
91
92protected:
93 explicit MediaControlElement(MediaControlElementType, HTMLElement*);
94 ~MediaControlElement() { }
95
96 virtual void setDisplayType(MediaControlElementType);
97 virtual bool isMediaControlElement() const { return true; }
98
99private:
100 MediaControllerInterface* m_mediaController;
101 MediaControlElementType m_displayType;
102 HTMLElement* m_element;
103};
104
105// ----------------------------
106
107class MediaControlDivElement : public HTMLDivElement, public MediaControlElement {
108protected:
109 virtual bool isMediaControlElement() const OVERRIDE { return MediaControlElement::isMediaControlElement(); }
110 explicit MediaControlDivElement(Document*, MediaControlElementType);
111};
112
113// ----------------------------
114
115class MediaControlInputElement : public HTMLInputElement, public MediaControlElement {
116protected:
117 virtual bool isMediaControlElement() const OVERRIDE { return MediaControlElement::isMediaControlElement(); }
118 explicit MediaControlInputElement(Document*, MediaControlElementType);
119
120private:
121 virtual void updateDisplayType() { }
Ben Murdoch83750172013-07-24 10:36:59 +0100122 virtual bool isMouseFocusable() const OVERRIDE;
Torne (Richard Coles)53e740f2013-05-09 18:38:43 +0100123};
124
125// ----------------------------
126
127class MediaControlTimeDisplayElement : public MediaControlDivElement {
128public:
129 void setCurrentValue(double);
130 double currentValue() const { return m_currentValue; }
131
132protected:
133 explicit MediaControlTimeDisplayElement(Document*, MediaControlElementType);
134
135private:
136 double m_currentValue;
137};
138
139// ----------------------------
140
141class MediaControlMuteButtonElement : public MediaControlInputElement {
142public:
143 void changedMute();
144
145 virtual bool willRespondToMouseClickEvents() OVERRIDE { return true; }
146
147protected:
148 explicit MediaControlMuteButtonElement(Document*, MediaControlElementType);
149
150 virtual void defaultEventHandler(Event*) OVERRIDE;
151
152private:
153 virtual void updateDisplayType() OVERRIDE;
154};
155
156// ----------------------------
157
Torne (Richard Coles)53e740f2013-05-09 18:38:43 +0100158class MediaControlVolumeSliderElement : public MediaControlInputElement {
159public:
160 virtual bool willRespondToMouseMoveEvents() OVERRIDE;
161 virtual bool willRespondToMouseClickEvents() OVERRIDE;
162 void setVolume(double);
163 void setClearMutedOnUserInteraction(bool);
164
165protected:
166 explicit MediaControlVolumeSliderElement(Document*);
167
168 virtual void defaultEventHandler(Event*) OVERRIDE;
169
170private:
171 bool m_clearMutedOnUserInteraction;
172};
173
174} // namespace WebCore
175
176#endif // MediaControlElementTypes_h