2 * Copyright (C) 2007, 2008, 2009, 2010 Apple Inc. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 #include "RenderImage.h"
36 class HTMLInputElement;
37 class HTMLMediaElement;
38 class MediaControlMuteButtonElement;
39 class MediaControlPlayButtonElement;
40 class MediaControlSeekButtonElement;
41 class MediaControlRewindButtonElement;
42 class MediaControlReturnToRealtimeButtonElement;
43 class MediaControlToggleClosedCaptionsButtonElement;
44 class MediaControlTimelineElement;
45 class MediaControlVolumeSliderElement;
46 class MediaControlFullscreenButtonElement;
47 class MediaControlTimeDisplayElement;
48 class MediaControlStatusDisplayElement;
49 class MediaControlTimelineContainerElement;
50 class MediaControlVolumeSliderContainerElement;
51 class MediaControlElement;
54 class RenderMedia : public RenderImage {
56 RenderMedia(HTMLMediaElement*);
57 RenderMedia(HTMLMediaElement*, const IntSize& intrinsicSize);
58 virtual ~RenderMedia();
60 const RenderObjectChildList* children() const { return &m_children; }
61 RenderObjectChildList* children() { return &m_children; }
63 HTMLMediaElement* mediaElement() const;
64 MediaPlayer* player() const;
66 bool shouldShowTimeDisplayControls() const;
68 void updateFromElement();
70 void updateControls();
71 void updateTimeDisplay();
73 void forwardEvent(Event*);
76 virtual void layout();
79 virtual RenderObjectChildList* virtualChildren() { return children(); }
80 virtual const RenderObjectChildList* virtualChildren() const { return children(); }
82 virtual void destroy();
84 virtual const char* renderName() const { return "RenderMedia"; }
85 virtual bool isMedia() const { return true; }
86 virtual bool isImage() const { return false; }
88 virtual int topmostPosition(bool includeOverflowInterior = true, bool includeSelf = true, ApplyTransform = IncludeTransform) const;
89 virtual int lowestPosition(bool includeOverflowInterior = true, bool includeSelf = true, ApplyTransform = IncludeTransform) const;
90 virtual int rightmostPosition(bool includeOverflowInterior = true, bool includeSelf = true, ApplyTransform = IncludeTransform) const;
91 virtual int leftmostPosition(bool includeOverflowInterior = true, bool includeSelf = true, ApplyTransform = IncludeTransform) const;
93 void createControlsShadowRoot();
94 void destroyControlsShadowRoot();
96 void createMuteButton();
97 void createPlayButton();
98 void createSeekBackButton();
99 void createSeekForwardButton();
100 void createRewindButton();
101 void createReturnToRealtimeButton();
102 void createToggleClosedCaptionsButton();
103 void createStatusDisplay();
104 void createTimelineContainer();
105 void createTimeline();
106 void createVolumeSliderContainer();
107 void createVolumeSlider();
108 void createVolumeSliderMuteButton();
109 void createCurrentTimeDisplay();
110 void createTimeRemainingDisplay();
111 void createFullscreenButton();
113 void timeUpdateTimerFired(Timer<RenderMedia>*);
115 void updateControlVisibility();
116 void changeOpacity(HTMLElement*, float opacity);
117 void opacityAnimationTimerFired(Timer<RenderMedia>*);
119 void updateVolumeSliderContainer(bool visible);
121 virtual void styleDidChange(StyleDifference, const RenderStyle* oldStyle);
123 virtual bool requiresForcedStyleRecalcPropagation() const { return true; }
125 RefPtr<HTMLElement> m_controlsShadowRoot;
126 RefPtr<MediaControlElement> m_panel;
127 RefPtr<MediaControlMuteButtonElement> m_muteButton;
128 RefPtr<MediaControlPlayButtonElement> m_playButton;
129 RefPtr<MediaControlSeekButtonElement> m_seekBackButton;
130 RefPtr<MediaControlSeekButtonElement> m_seekForwardButton;
131 RefPtr<MediaControlRewindButtonElement> m_rewindButton;
132 RefPtr<MediaControlReturnToRealtimeButtonElement> m_returnToRealtimeButton;
133 RefPtr<MediaControlToggleClosedCaptionsButtonElement> m_toggleClosedCaptionsButton;
134 RefPtr<MediaControlTimelineElement> m_timeline;
135 RefPtr<MediaControlVolumeSliderElement> m_volumeSlider;
136 RefPtr<MediaControlMuteButtonElement> m_volumeSliderMuteButton;
137 RefPtr<MediaControlFullscreenButtonElement> m_fullscreenButton;
138 RefPtr<MediaControlTimelineContainerElement> m_timelineContainer;
139 RefPtr<MediaControlVolumeSliderContainerElement> m_volumeSliderContainer;
140 RefPtr<MediaControlTimeDisplayElement> m_currentTimeDisplay;
141 RefPtr<MediaControlTimeDisplayElement> m_timeRemainingDisplay;
142 RefPtr<MediaControlStatusDisplayElement> m_statusDisplay;
143 RenderObjectChildList m_children;
144 Node* m_lastUnderNode;
145 Node* m_nodeUnderMouse;
147 Timer<RenderMedia> m_timeUpdateTimer;
148 Timer<RenderMedia> m_opacityAnimationTimer;
150 double m_opacityAnimationStartTime;
151 double m_opacityAnimationDuration;
152 float m_opacityAnimationFrom;
153 float m_opacityAnimationTo;
156 inline RenderMedia* toRenderMedia(RenderObject* object)
158 ASSERT(!object || object->isMedia());
159 return static_cast<RenderMedia*>(object);
162 // This will catch anyone doing an unnecessary cast.
163 void toRenderMedia(const RenderMedia*);
165 } // namespace WebCore
168 #endif // RenderMedia_h