Update To 11.40.268.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 blink {
34
35 class Event;
36
37 class MediaControls final : public HTMLDivElement {
38 public:
39     static PassRefPtrWillBeRawPtr<MediaControls> create(HTMLMediaElement&);
40
41     HTMLMediaElement& mediaElement() const { return *m_mediaElement; }
42
43     void reset();
44
45     void show();
46     void hide();
47
48     void playbackStarted();
49     void playbackProgressed();
50     void playbackStopped();
51
52     void beginScrubbing();
53     void endScrubbing();
54
55     void updateCurrentTimeDisplay();
56
57     void updateVolume();
58
59     void changedClosedCaptionsVisibility();
60     void refreshClosedCaptionsButtonVisibility();
61     void textTracksChanged();
62
63     void enteredFullscreen();
64     void exitedFullscreen();
65
66     void startedCasting();
67     void stoppedCasting();
68     void refreshCastButtonVisibility();
69     void showOverlayCastButton();
70
71     void updateTextTrackDisplay();
72
73     void mediaElementFocused();
74
75     virtual void trace(Visitor*) override;
76
77 private:
78     explicit MediaControls(HTMLMediaElement&);
79
80     bool initializeControls();
81
82     void makeOpaque();
83     void makeTransparent();
84
85     void updatePlayState();
86
87     enum HideBehaviorFlags {
88         IgnoreVideoHover = 1 << 0,
89         IgnoreFocus = 1 << 1,
90         IgnoreControlsHover = 1 << 2
91     };
92
93     bool shouldHideMediaControls(unsigned behaviorFlags = 0) const;
94     void hideMediaControlsTimerFired(Timer<MediaControls>*);
95     void startHideMediaControlsTimer();
96     void stopHideMediaControlsTimer();
97     void resetHideMediaControlsTimer();
98
99     void createTextTrackDisplay();
100     void showTextTrackDisplay();
101     void hideTextTrackDisplay();
102
103     // Node
104     virtual bool isMediaControls() const override { return true; }
105     virtual bool willRespondToMouseMoveEvents() override { return true; }
106     virtual void defaultEventHandler(Event*) override;
107     bool containsRelatedTarget(Event*);
108
109     // Element
110     virtual const AtomicString& shadowPseudoId() const override;
111
112     RawPtrWillBeMember<HTMLMediaElement> m_mediaElement;
113
114     // Container for the media control elements.
115     RawPtrWillBeMember<MediaControlPanelElement> m_panel;
116
117     // Container for the text track cues.
118     RawPtrWillBeMember<MediaControlTextTrackContainerElement> m_textDisplayContainer;
119
120     // Media control elements.
121     RawPtrWillBeMember<MediaControlOverlayPlayButtonElement> m_overlayPlayButton;
122     RawPtrWillBeMember<MediaControlOverlayEnclosureElement> m_overlayEnclosure;
123     RawPtrWillBeMember<MediaControlPlayButtonElement> m_playButton;
124     RawPtrWillBeMember<MediaControlCurrentTimeDisplayElement> m_currentTimeDisplay;
125     RawPtrWillBeMember<MediaControlTimelineElement> m_timeline;
126     RawPtrWillBeMember<MediaControlMuteButtonElement> m_muteButton;
127     RawPtrWillBeMember<MediaControlVolumeSliderElement> m_volumeSlider;
128     RawPtrWillBeMember<MediaControlToggleClosedCaptionsButtonElement> m_toggleClosedCaptionsButton;
129     RawPtrWillBeMember<MediaControlFullscreenButtonElement> m_fullScreenButton;
130     RawPtrWillBeMember<MediaControlCastButtonElement> m_castButton;
131     RawPtrWillBeMember<MediaControlCastButtonElement> m_overlayCastButton;
132     RawPtrWillBeMember<MediaControlTimeRemainingDisplayElement> m_durationDisplay;
133     RawPtrWillBeMember<MediaControlPanelEnclosureElement> m_enclosure;
134
135     Timer<MediaControls> m_hideMediaControlsTimer;
136     bool m_isMouseOverControls : 1;
137     bool m_isPausedForScrubbing : 1;
138     bool m_wasLastEventTouch : 1;
139 };
140
141 DEFINE_ELEMENT_TYPE_CASTS(MediaControls, isMediaControls());
142
143 }
144
145 #endif