2 * Copyright (C) 2008, 2009, 2010, 2011 Apple Inc. All rights reserved.
3 * Copyright (C) 2012 Google Inc. All rights reserved.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
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.
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.
30 #ifndef MediaControlElementTypes_h
31 #define MediaControlElementTypes_h
33 #include "core/CoreExport.h"
34 #include "core/html/HTMLDivElement.h"
35 #include "core/html/HTMLInputElement.h"
36 #include "public/platform/WebLocalizedString.h"
40 class HTMLMediaElement;
43 enum MediaControlElementType {
44 MediaEnterFullscreenButton = 0,
49 MediaSeekForwardButton,
53 MediaShowClosedCaptionsButton,
54 MediaHideClosedCaptionsButton,
58 MediaTimelineContainer,
59 MediaCurrentTimeDisplay,
60 MediaTimeRemainingDisplay,
61 MediaTrackSelectionCheckmark,
63 MediaVolumeSliderContainer,
65 MediaVolumeSliderThumb,
66 MediaFullscreenVolumeSlider,
67 MediaFullscreenVolumeSliderThumb,
68 MediaExitFullscreenButton,
69 MediaOverlayPlayButton,
70 #if defined(TIZEN_VIDEO_MANUAL_ROTATION_SUPPORT)
75 MediaOverlayCastOffButton,
76 MediaOverlayCastOnButton,
80 #if defined(TIZEN_MULTIMEDIA_SUPPORT)
85 CORE_EXPORT const HTMLMediaElement* toParentMediaElement(const Node*);
86 CORE_EXPORT const HTMLMediaElement* toParentMediaElement(const LayoutObject&);
88 CORE_EXPORT MediaControlElementType mediaControlElementType(const Node*);
90 // ----------------------------
92 class MediaControlElement : public GarbageCollectedMixin {
94 // These hold the state about whether this control should be shown if
95 // space permits. These will also show / hide as needed.
96 void setIsWanted(bool);
99 // Tell us whether we fit or not. This will hide / show the control as
101 void setDoesFit(bool);
103 MediaControlElementType displayType() const { return m_displayType; }
105 // By default, media controls elements are not added to the overflow menu.
106 // Controls that can be added to the overflow menu should override this
107 // function and return true.
108 virtual bool hasOverflowButton() { return false; }
110 // If true, shows the overflow menu item if it exists. Hides it if false.
111 void shouldShowButtonInOverflowMenu(bool);
113 // Returns a string representation of the media control element. Used for
114 // the overflow menu.
115 String getOverflowMenuString();
117 // Updates the value of the Text string shown in the overflow menu.
118 void updateOverflowString();
120 DECLARE_VIRTUAL_TRACE();
123 MediaControlElement(MediaControls&, MediaControlElementType, HTMLElement*);
125 MediaControls& mediaControls() const {
126 DCHECK(m_mediaControls);
127 return *m_mediaControls;
129 HTMLMediaElement& mediaElement() const;
131 void setDisplayType(MediaControlElementType);
133 // Represents the overflow menu element for this media control.
134 // The Element contains the button that the user can click on, but having
135 // the button within an Element enables us to style the overflow menu.
136 // Setting this pointer is optional so it may be null.
137 Member<Element> m_overflowMenuElement;
139 // The text representation of the button within the overflow menu.
140 Member<Text> m_overflowMenuText;
143 // Hide or show based on our fits / wanted state. We want to show
144 // if and only if we're wanted and we fit.
145 void updateShownState();
147 // Returns a string representation of the media control element.
148 // Subclasses should override this method to return the string representation
149 // of the overflow button.
150 virtual WebLocalizedString::Name getOverflowStringName() {
152 return WebLocalizedString::AXAMPMFieldText;
155 Member<MediaControls> m_mediaControls;
156 MediaControlElementType m_displayType;
157 Member<HTMLElement> m_element;
162 // ----------------------------
164 class MediaControlDivElement : public HTMLDivElement,
165 public MediaControlElement {
166 USING_GARBAGE_COLLECTED_MIXIN(MediaControlDivElement);
169 DECLARE_VIRTUAL_TRACE();
172 MediaControlDivElement(MediaControls&, MediaControlElementType);
175 bool isMediaControlElement() const final { return true; }
178 // ----------------------------
180 class MediaControlInputElement : public HTMLInputElement,
181 public MediaControlElement {
182 USING_GARBAGE_COLLECTED_MIXIN(MediaControlInputElement);
185 DECLARE_VIRTUAL_TRACE();
187 // Creates an overflow menu element with the given button as a child.
188 HTMLElement* createOverflowElement(MediaControls&, MediaControlInputElement*);
191 MediaControlInputElement(MediaControls&, MediaControlElementType);
194 virtual void updateDisplayType() {}
195 bool isMediaControlElement() const final { return true; }
196 bool isMouseFocusable() const override;
198 // Creates an overflow menu HTML element.
199 virtual MediaControlInputElement* createOverflowButton(MediaControls&) {
204 // ----------------------------
206 class MediaControlTimeDisplayElement : public MediaControlDivElement {
208 void setCurrentValue(double);
209 double currentValue() const { return m_currentValue; }
212 MediaControlTimeDisplayElement(MediaControls&, MediaControlElementType);
215 double m_currentValue;
220 #endif // MediaControlElementTypes_h