Changeset 87661 in webkit


Ignore:
Timestamp:
May 29, 2011 8:37:14 PM (13 years ago)
Author:
jer.noble@apple.com
Message:

2011-05-29 Brian Weinstein <bweinstein@apple.com>

Reviewed by Darin Adler.

Controls never hide in full screen after user stops moving mouse
https://bugs.webkit.org/show_bug.cgi?id=61715
<rdar://problem/9522182>

When we get a mouse move event in HTMLMediaElement::defaultEventHandler, and we are in full screen,
show the media controls, and then start a timer.

The timer fires 3 seconds after the user's last mouse movement (timer is restarted on every mouse
move), and hides the controls.

  • html/HTMLMediaElement.cpp: (WebCore::HTMLMediaElement::HTMLMediaElement): Initialize our new timer. (WebCore::HTMLMediaElement::play): If we are in full screen mode, start our timer to hide the full screen

controls. We don't want the user to have to move the mouse to hide them when they use the spacebar
to play.

(WebCore::HTMLMediaElement::startHideFullscreenControlsTimer): Starts a oneshot timer 3 seconds in the future

if we are in full screen.

(WebCore::HTMLMediaElement::hideFullscreenControlsTimerFired): Make sure that we are currently playing, and

we are in full screen, and hide the controls. We don't want to hide the controls if we are paused.

(WebCore::HTMLMediaElement::stopHideFullscreenControlsTimer): Stops the timer.
(WebCore::HTMLMediaElement::defaultEventHandler): If we get a mouse move event and are in full screen, show the

controls and start a timer to hide them.

(WebCore::HTMLMediaElement::enterFullscreen): Start a timer to hide the full screen controls. The user shouldn't

have the move the mouse once they enter full screen to hide the controls.

(WebCore::HTMLMediaElement::exitFullscreen): Stop the timer to hide the full screen controls.

  • html/HTMLMediaElement.h:
  • html/shadow/MediaControls.h: Added pure virtual shouldHideControls() method.
  • html/shadow/MediaControlRootElement.cpp: (WebCore::MediaControlRootElement::playbackStopped): Stop the timer to hide the full screen controls. (WebCore::MediaControlRootElement::shouldHideControls): Added, only report that

the caller should hide the controls if the panel is not hovered.

  • html/shadow/MediaControlRootElement.h:
Location:
trunk/Source/WebCore
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r87660 r87661  
     12011-05-29  Brian Weinstein  <bweinstein@apple.com>
     2
     3        Reviewed by Darin Adler.
     4
     5        Controls never hide in full screen after user stops moving mouse
     6        https://bugs.webkit.org/show_bug.cgi?id=61715
     7        <rdar://problem/9522182>
     8       
     9        When we get a mouse move event in HTMLMediaElement::defaultEventHandler, and we are in full screen,
     10        show the media controls, and then start a timer.
     11       
     12        The timer fires 3 seconds after the user's last mouse movement (timer is restarted on every mouse
     13        move), and hides the controls.
     14
     15        * html/HTMLMediaElement.cpp:
     16        (WebCore::HTMLMediaElement::HTMLMediaElement): Initialize our new timer.
     17        (WebCore::HTMLMediaElement::play): If we are in full screen mode, start our timer to hide the full screen
     18            controls. We don't want the user to have to move the mouse to hide them when they use the spacebar
     19            to play.
     20        (WebCore::HTMLMediaElement::startHideFullscreenControlsTimer): Starts a oneshot timer 3 seconds in the future
     21            if we are in full screen.
     22        (WebCore::HTMLMediaElement::hideFullscreenControlsTimerFired): Make sure that we are currently playing, and
     23            we are in full screen, and hide the controls. We don't want to hide the controls if we are paused.
     24        (WebCore::HTMLMediaElement::stopHideFullscreenControlsTimer): Stops the timer.
     25        (WebCore::HTMLMediaElement::defaultEventHandler): If we get a mouse move event and are in full screen, show the
     26            controls and start a timer to hide them.
     27        (WebCore::HTMLMediaElement::enterFullscreen): Start a timer to hide the full screen controls. The user shouldn't
     28            have the move the mouse once they enter full screen to hide the controls.
     29        (WebCore::HTMLMediaElement::exitFullscreen): Stop the timer to hide the full screen controls.
     30        * html/HTMLMediaElement.h:
     31        * html/shadow/MediaControls.h: Added pure virtual shouldHideControls() method.
     32        * html/shadow/MediaControlRootElement.cpp:
     33        (WebCore::MediaControlRootElement::playbackStopped): Stop the timer to hide the full screen controls.
     34        (WebCore::MediaControlRootElement::shouldHideControls): Added, only report that
     35            the caller should hide the controls if the panel is not hovered.
     36        * html/shadow/MediaControlRootElement.h:
     37
    1382011-05-29  Jer Noble  <jer.noble@apple.com>
    239
  • trunk/Source/WebCore/html/HTMLMediaElement.cpp

    r87657 r87661  
    124124    , m_progressEventTimer(this, &HTMLMediaElement::progressEventTimerFired)
    125125    , m_playbackProgressTimer(this, &HTMLMediaElement::playbackProgressTimerFired)
     126    , m_hideFullscreenControlsTimer(this, &HTMLMediaElement::hideFullscreenControlsTimerFired)
    126127    , m_playedTimeRanges()
    127128    , m_playbackRate(1.0f)
     
    14261427    }
    14271428   
     1429    if (isFullscreen())
     1430        startHideFullscreenControlsTimer();
     1431   
    14281432    playInternal();
    14291433}
     
    16111615static const double maxTimeupdateEventFrequency = 0.25;
    16121616
     1617static const double timeWithoutMouseMovementBeforeHidingControls = 3;
     1618
    16131619void HTMLMediaElement::startPlaybackProgressTimer()
    16141620{
     
    16341640    }
    16351641    // FIXME: deal with cue ranges here
     1642}
     1643
     1644void HTMLMediaElement::startHideFullscreenControlsTimer()
     1645{
     1646    if (!isFullscreen())
     1647        return;
     1648   
     1649    m_hideFullscreenControlsTimer.startOneShot(timeWithoutMouseMovementBeforeHidingControls);
     1650}
     1651
     1652void HTMLMediaElement::hideFullscreenControlsTimerFired(Timer<HTMLMediaElement>*)
     1653{
     1654    if (!m_playing)
     1655        return;
     1656   
     1657    if (!isFullscreen())
     1658        return;
     1659   
     1660    if (!controls() || !hasMediaControls())
     1661        return;
     1662   
     1663    if (!mediaControls()->shouldHideControls())
     1664        return;
     1665       
     1666    mediaControls()->makeTransparent();
     1667}
     1668
     1669void HTMLMediaElement::stopHideFullscreenControlsTimer()
     1670{
     1671    m_hideFullscreenControlsTimer.stop();
    16361672}
    16371673
     
    23792415            if (event->type() == eventNames().mouseoverEvent) {
    23802416                m_mouseOver = true;
    2381                 if (hasMediaControls() && controls() && !canPlay())
     2417                if (hasMediaControls() && controls() && !canPlay()) {
    23822418                    mediaControls()->makeOpaque();
    2383             } else if (event->type() == eventNames().mouseoutEvent)
     2419                    if (mediaControls()->shouldHideControls())
     2420                        startHideFullscreenControlsTimer();
     2421                }
     2422            } else if (event->type() == eventNames().mouseoutEvent) {
    23842423                m_mouseOver = false;
     2424                stopHideFullscreenControlsTimer();
     2425            } else if (event->type() == eventNames().mousemoveEvent) {
     2426                if (isFullscreen() && hasMediaControls() && controls()) {
     2427                    // When we get a mouse move in fullscreen mode, show the media controls, and start a timer
     2428                    // that will hide the media controls after a 3 seconds without a mouse move.
     2429                    mediaControls()->makeOpaque();
     2430                    if (mediaControls()->shouldHideControls())
     2431                        startHideFullscreenControlsTimer();
     2432                }
     2433            }
     2434   
    23852435        }
    23862436    }
     
    25192569{
    25202570    LOG(Media, "HTMLMediaElement::enterFullscreen");
     2571   
     2572    startHideFullscreenControlsTimer();
     2573   
    25212574#if ENABLE(FULLSCREEN_API)
    25222575    if (document() && document()->settings() && document()->settings()->fullScreenEnabled()) {
     
    25382591{
    25392592    LOG(Media, "HTMLMediaElement::exitFullscreen");
     2593   
     2594    stopHideFullscreenControlsTimer();
     2595   
    25402596#if ENABLE(FULLSCREEN_API)
    25412597    if (document() && document()->settings() && document()->settings()->fullScreenEnabled()) {
  • trunk/Source/WebCore/html/HTMLMediaElement.h

    r87657 r87661  
    147147    void beginScrubbing();
    148148    void endScrubbing();
     149   
     150    void stopHideFullscreenControlsTimer();
    149151
    150152    bool canPlay() const;
     
    271273    void progressEventTimerFired(Timer<HTMLMediaElement>*);
    272274    void playbackProgressTimerFired(Timer<HTMLMediaElement>*);
     275    void hideFullscreenControlsTimerFired(Timer<HTMLMediaElement>*);
    273276    void startPlaybackProgressTimer();
    274277    void startProgressEventTimer();
     278    void startHideFullscreenControlsTimer();
    275279    void stopPeriodicTimers();
    276280
     
    342346    Timer<HTMLMediaElement> m_progressEventTimer;
    343347    Timer<HTMLMediaElement> m_playbackProgressTimer;
     348    Timer<HTMLMediaElement> m_hideFullscreenControlsTimer;
    344349    Vector<RefPtr<Event> > m_pendingEvents;
    345350    RefPtr<TimeRanges> m_playedTimeRanges;
  • trunk/Source/WebCore/html/shadow/MediaControlRootElement.cpp

    r87557 r87661  
    351351    updateTimeDisplay();
    352352    makeOpaque();
     353   
     354    m_mediaElement->stopHideFullscreenControlsTimer();
    353355}
    354356
     
    458460}
    459461
     462bool MediaControlRootElement::shouldHideControls()
     463{
     464    return !m_panel->hovered();
     465}
     466
    460467const AtomicString& MediaControlRootElement::shadowPseudoId() const
    461468{
  • trunk/Source/WebCore/html/shadow/MediaControlRootElement.h

    r85949 r87661  
    9797    void updateStatusDisplay();
    9898
     99    virtual bool shouldHideControls();
    99100private:
    100101    MediaControlRootElement(HTMLMediaElement*);
  • trunk/Source/WebCore/html/shadow/MediaControls.h

    r85949 r87661  
    6969    virtual void updateStatusDisplay() = 0;
    7070
     71    virtual bool shouldHideControls() = 0;
     72
    7173protected:
    7274    MediaControls(HTMLMediaElement*);
Note: See TracChangeset for help on using the changeset viewer.