Home | History | Annotate | Download | only in shadow
      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 // An abstract class with the media control elements that all ports support.
     45 class MediaControls : public HTMLDivElement {
     46   public:
     47     virtual ~MediaControls() {}
     48 
     49     // This function is to be implemented in your port-specific media
     50     // controls implementation since it will return a child instance.
     51     static PassRefPtr<MediaControls> create(Document&);
     52 
     53     virtual void setMediaController(MediaControllerInterface*);
     54 
     55     virtual void reset();
     56     virtual void reportedError();
     57     virtual void loadedMetadata();
     58 
     59     virtual void show();
     60     virtual void hide();
     61     virtual void makeOpaque();
     62     virtual void makeTransparent();
     63     virtual bool shouldHideControls();
     64 
     65     virtual void bufferingProgressed();
     66     virtual void playbackStarted();
     67     virtual void playbackProgressed();
     68     virtual void playbackStopped();
     69 
     70     virtual void updateStatusDisplay() { };
     71     virtual void updateCurrentTimeDisplay() = 0;
     72     virtual void showVolumeSlider();
     73 
     74     virtual void changedMute();
     75     virtual void changedVolume();
     76 
     77     virtual void changedClosedCaptionsVisibility();
     78     virtual void refreshClosedCaptionsButtonVisibility();
     79     virtual void closedCaptionTracksChanged();
     80 
     81     virtual void enteredFullscreen();
     82     virtual void exitedFullscreen();
     83 
     84     virtual bool willRespondToMouseMoveEvents() OVERRIDE { return true; }
     85 
     86     virtual void hideFullscreenControlsTimerFired(Timer<MediaControls>*);
     87     virtual void startHideFullscreenControlsTimer();
     88     virtual void stopHideFullscreenControlsTimer();
     89 
     90     virtual void createTextTrackDisplay();
     91     virtual void showTextTrackDisplay();
     92     virtual void hideTextTrackDisplay();
     93     virtual void updateTextTrackDisplay();
     94 
     95 protected:
     96     explicit MediaControls(Document&);
     97 
     98     virtual void defaultEventHandler(Event*);
     99 
    100     virtual bool containsRelatedTarget(Event*);
    101 
    102     MediaControllerInterface* m_mediaController;
    103 
    104     // Container for the media control elements.
    105     MediaControlPanelElement* m_panel;
    106 
    107     // Container for the text track cues.
    108     MediaControlTextTrackContainerElement* m_textDisplayContainer;
    109 
    110     // Media control elements.
    111     MediaControlPlayButtonElement* m_playButton;
    112     MediaControlCurrentTimeDisplayElement* m_currentTimeDisplay;
    113     MediaControlTimelineElement* m_timeline;
    114     MediaControlPanelMuteButtonElement* m_panelMuteButton;
    115     MediaControlPanelVolumeSliderElement* m_volumeSlider;
    116     MediaControlToggleClosedCaptionsButtonElement* m_toggleClosedCaptionsButton;
    117     MediaControlFullscreenButtonElement* m_fullScreenButton;
    118 
    119     Timer<MediaControls> m_hideFullscreenControlsTimer;
    120     bool m_isFullscreen;
    121     bool m_isMouseOverControls;
    122 
    123 private:
    124     virtual bool isMediaControls() const { return true; }
    125 
    126     virtual const AtomicString& pseudo() const;
    127 };
    128 
    129 DEFINE_NODE_TYPE_CASTS(MediaControls, isMediaControls());
    130 
    131 }
    132 
    133 #endif
    134