Upstream version 5.34.104.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / Source / core / html / shadow / MediaControls.h
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 COMPUTER, 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 COMPUTER, 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 #ifndef MediaControls_h
28 #define MediaControls_h
29
30 #include "core/events/MouseEvent.h"
31 #include "core/html/HTMLDivElement.h"
32 #include "core/html/shadow/MediaControlElements.h"
33 #include "core/rendering/RenderTheme.h"
34
35 namespace WebCore {
36
37 class Document;
38 class Event;
39 class MediaPlayer;
40
41 class RenderBox;
42 class RenderMedia;
43
44 class MediaControls : public HTMLDivElement {
45 public:
46     virtual ~MediaControls() {}
47
48     static PassRefPtr<MediaControls> create(Document&);
49
50     virtual void setMediaController(MediaControllerInterface*);
51
52     void reset();
53
54     void show();
55     void hide();
56
57     void bufferingProgressed();
58     virtual void playbackStarted();
59     void playbackProgressed();
60     virtual void playbackStopped();
61
62     void updateCurrentTimeDisplay();
63     void showVolumeSlider();
64
65     void changedMute();
66     void changedVolume();
67
68     void changedClosedCaptionsVisibility();
69     void refreshClosedCaptionsButtonVisibility();
70     void closedCaptionTracksChanged();
71
72     void enteredFullscreen();
73     void exitedFullscreen();
74
75     void updateTextTrackDisplay();
76
77 protected:
78     explicit MediaControls(Document&);
79
80     virtual bool initializeControls(Document&);
81
82     virtual bool shouldHideControls();
83
84     virtual void insertTextTrackContainer(PassRefPtr<MediaControlTextTrackContainerElement>);
85
86 private:
87     void makeOpaque();
88     void makeTransparent();
89
90     void hideFullscreenControlsTimerFired(Timer<MediaControls>*);
91     void startHideFullscreenControlsTimer();
92     void stopHideFullscreenControlsTimer();
93
94     void createTextTrackDisplay();
95     void showTextTrackDisplay();
96     void hideTextTrackDisplay();
97
98     // Node
99     virtual bool isMediaControls() const OVERRIDE FINAL { return true; }
100     virtual bool willRespondToMouseMoveEvents() OVERRIDE { return true; }
101     virtual void defaultEventHandler(Event*) OVERRIDE;
102     bool containsRelatedTarget(Event*);
103
104     // Element
105     virtual const AtomicString& shadowPseudoId() const OVERRIDE;
106
107     MediaControllerInterface* m_mediaController;
108
109     // Container for the media control elements.
110     MediaControlPanelElement* m_panel;
111
112     // Container for the text track cues.
113     MediaControlTextTrackContainerElement* m_textDisplayContainer;
114
115     // Media control elements.
116     MediaControlPlayButtonElement* m_playButton;
117     MediaControlCurrentTimeDisplayElement* m_currentTimeDisplay;
118     MediaControlTimelineElement* m_timeline;
119     MediaControlPanelMuteButtonElement* m_panelMuteButton;
120     MediaControlPanelVolumeSliderElement* m_volumeSlider;
121     MediaControlToggleClosedCaptionsButtonElement* m_toggleClosedCaptionsButton;
122     MediaControlFullscreenButtonElement* m_fullScreenButton;
123     MediaControlTimeRemainingDisplayElement* m_durationDisplay;
124     MediaControlPanelEnclosureElement* m_enclosure;
125
126     Timer<MediaControls> m_hideFullscreenControlsTimer;
127     bool m_isFullscreen;
128     bool m_isMouseOverControls;
129 };
130
131 DEFINE_NODE_TYPE_CASTS(MediaControls, isMediaControls());
132
133 }
134
135 #endif