Upstream version 6.35.121.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/html/HTMLDivElement.h"
31 #include "core/html/shadow/MediaControlElements.h"
32
33 namespace WebCore {
34
35 class Document;
36 class Event;
37
38 class MediaControls FINAL : public HTMLDivElement {
39 public:
40     static PassRefPtr<MediaControls> create(HTMLMediaElement&);
41
42     HTMLMediaElement& mediaElement() const { return m_mediaElement; }
43     MediaControllerInterface& mediaControllerInterface() const;
44
45     void reset();
46
47     void show();
48     void hide();
49
50     void playbackStarted();
51     void playbackProgressed();
52     void playbackStopped();
53
54     void beginScrubbing();
55     void endScrubbing();
56
57     void updateCurrentTimeDisplay();
58
59     void changedMute();
60     void changedVolume();
61
62     void changedClosedCaptionsVisibility();
63     void refreshClosedCaptionsButtonVisibility();
64     void closedCaptionTracksChanged();
65
66     void enteredFullscreen();
67     void exitedFullscreen();
68
69     void updateTextTrackDisplay();
70
71 private:
72     explicit MediaControls(HTMLMediaElement&);
73
74     bool initializeControls();
75
76     void makeOpaque();
77     void makeTransparent();
78
79     void updatePlayState();
80
81     bool shouldHideFullscreenControls();
82     void hideFullscreenControlsTimerFired(Timer<MediaControls>*);
83     void startHideFullscreenControlsTimer();
84     void stopHideFullscreenControlsTimer();
85
86     void createTextTrackDisplay();
87     void showTextTrackDisplay();
88     void hideTextTrackDisplay();
89
90     // Node
91     virtual bool isMediaControls() const OVERRIDE { return true; }
92     virtual bool willRespondToMouseMoveEvents() OVERRIDE { return true; }
93     virtual void defaultEventHandler(Event*) OVERRIDE;
94     bool containsRelatedTarget(Event*);
95
96     // Element
97     virtual const AtomicString& shadowPseudoId() const OVERRIDE;
98
99     HTMLMediaElement& m_mediaElement;
100
101     // Container for the media control elements.
102     MediaControlPanelElement* m_panel;
103
104     // Container for the text track cues.
105     MediaControlTextTrackContainerElement* m_textDisplayContainer;
106
107     // Media control elements.
108     MediaControlOverlayPlayButtonElement* m_overlayPlayButton;
109     MediaControlOverlayEnclosureElement* m_overlayEnclosure;
110     MediaControlPlayButtonElement* m_playButton;
111     MediaControlCurrentTimeDisplayElement* m_currentTimeDisplay;
112     MediaControlTimelineElement* m_timeline;
113     MediaControlMuteButtonElement* m_muteButton;
114     MediaControlVolumeSliderElement* m_volumeSlider;
115     MediaControlToggleClosedCaptionsButtonElement* m_toggleClosedCaptionsButton;
116     MediaControlFullscreenButtonElement* m_fullScreenButton;
117     MediaControlTimeRemainingDisplayElement* m_durationDisplay;
118     MediaControlPanelEnclosureElement* m_enclosure;
119
120     Timer<MediaControls> m_hideFullscreenControlsTimer;
121     bool m_isFullscreen : 1;
122     bool m_isMouseOverControls : 1;
123     bool m_isPausedForScrubbing : 1;
124 };
125
126 DEFINE_ELEMENT_TYPE_CASTS(MediaControls, isMediaControls());
127
128 }
129
130 #endif