• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
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 
39 namespace WebCore {
40 
41 // Must match WebKitSystemInterface.h
42 enum 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,
71 };
72 
73 HTMLMediaElement* toParentMediaElement(Node*);
toParentMediaElement(RenderObject * renderer)74 inline HTMLMediaElement* toParentMediaElement(RenderObject* renderer) { return toParentMediaElement(renderer->node()); }
75 
76 MediaControlElementType mediaControlElementType(Node*);
77 
78 // ----------------------------
79 
80 class MediaControlElement {
81 public:
82     virtual void hide();
83     virtual void show();
84     virtual bool isShowing() const;
85 
displayType()86     virtual MediaControlElementType displayType() { return m_displayType; }
87     virtual const AtomicString& pseudo() const = 0;
88 
setMediaController(MediaControllerInterface * controller)89     virtual void setMediaController(MediaControllerInterface* controller) { m_mediaController = controller; }
mediaController()90     virtual MediaControllerInterface* mediaController() const { return m_mediaController; }
91 
92 protected:
93     explicit MediaControlElement(MediaControlElementType, HTMLElement*);
~MediaControlElement()94     ~MediaControlElement() { }
95 
96     virtual void setDisplayType(MediaControlElementType);
isMediaControlElement()97     virtual bool isMediaControlElement() const { return true; }
98 
99 private:
100     MediaControllerInterface* m_mediaController;
101     MediaControlElementType m_displayType;
102     HTMLElement* m_element;
103 };
104 
105 // ----------------------------
106 
107 class MediaControlDivElement : public HTMLDivElement, public MediaControlElement {
108 protected:
isMediaControlElement()109     virtual bool isMediaControlElement() const OVERRIDE { return MediaControlElement::isMediaControlElement(); }
110     explicit MediaControlDivElement(Document&, MediaControlElementType);
111 };
112 
113 // ----------------------------
114 
115 class MediaControlInputElement : public HTMLInputElement, public MediaControlElement {
116 protected:
isMediaControlElement()117     virtual bool isMediaControlElement() const OVERRIDE { return MediaControlElement::isMediaControlElement(); }
118     explicit MediaControlInputElement(Document&, MediaControlElementType);
119 
120 private:
updateDisplayType()121     virtual void updateDisplayType() { }
122     virtual bool isMouseFocusable() const OVERRIDE;
123 };
124 
125 // ----------------------------
126 
127 class MediaControlTimeDisplayElement : public MediaControlDivElement {
128 public:
129     void setCurrentValue(double);
currentValue()130     double currentValue() const { return m_currentValue; }
131 
132 protected:
133     explicit MediaControlTimeDisplayElement(Document&, MediaControlElementType);
134 
135 private:
136     double m_currentValue;
137 };
138 
139 // ----------------------------
140 
141 class MediaControlMuteButtonElement : public MediaControlInputElement {
142 public:
143     void changedMute();
144 
willRespondToMouseClickEvents()145     virtual bool willRespondToMouseClickEvents() OVERRIDE { return true; }
146 
147 protected:
148     explicit MediaControlMuteButtonElement(Document&, MediaControlElementType);
149 
150     virtual void defaultEventHandler(Event*) OVERRIDE;
151 
152 private:
153     virtual void updateDisplayType() OVERRIDE;
154 };
155 
156 // ----------------------------
157 
158 class MediaControlVolumeSliderElement : public MediaControlInputElement {
159 public:
160     virtual bool willRespondToMouseMoveEvents() OVERRIDE;
161     virtual bool willRespondToMouseClickEvents() OVERRIDE;
162     void setVolume(double);
163     void setClearMutedOnUserInteraction(bool);
164 
165 protected:
166     explicit MediaControlVolumeSliderElement(Document&);
167 
168     virtual void defaultEventHandler(Event*) OVERRIDE;
169 
170 private:
171     bool m_clearMutedOnUserInteraction;
172 };
173 
174 } // namespace WebCore
175 
176 #endif // MediaControlElementTypes_h
177