Title: [120414] trunk/Source
Revision
120414
Author
[email protected]
Date
2012-06-15 00:19:53 -0700 (Fri, 15 Jun 2012)

Log Message

Add fullscreen button to Chrome video controls for video.
https://bugs.webkit.org/show_bug.cgi?id=88818

Patch by Silvia Pfeiffer <[email protected]> on 2012-06-15
Reviewed by Eric Carlson.

No new tests, final patch will contain the rebaselined tests.

The Chrome video controls are receiving a visual update.
This patch includes a fullscreen button for video elements and the rendering of the controls
in fullscreen including hiding them after 2 seconds when the mouse is out of the controls
and not moved.

* css/fullscreen.css:
(video:-webkit-full-screen, audio:-webkit-full-screen):
Add audio to the default fullscreen styling rules.
* css/mediaControlsChromium.css:
(video:-webkit-full-page-media::-webkit-media-controls-panel):
Align controls to the bottom of the fullscreen page.
(audio::-webkit-media-controls-fullscreen-button, video::-webkit-media-controls-fullscreen-button):
Include styling for the fullscreen button.
* html/shadow/MediaControlRootElementChromium.cpp:
(WebCore):
Add a constant for when to hide the controls in fullscreen.
(WebCore::MediaControlRootElementChromium::MediaControlRootElementChromium):
Add member fields for fullscreen button, hiding timer and tracking of whether we are in fullscreen.
(WebCore::MediaControlRootElementChromium::create):
Add fullscreen button element to the visual layout.
(WebCore::MediaControlRootElementChromium::setMediaController):
Add fullscreen button element to the media controller.
(WebCore::MediaControlRootElementChromium::reset):
Show the fullscreen button if the controller supports fullscreen.
(WebCore::MediaControlRootElementChromium::playbackStarted):
Start the timer to hide the controls in fullscreen.
(WebCore::MediaControlRootElementChromium::playbackStopped):
Don't hide the controls when the video is paused in fullscreen.
(WebCore::MediaControlRootElementChromium::reportedError):
Hide the fullscreen button when we hit an error.
(WebCore::MediaControlRootElementChromium::defaultEventHandler):
Add logic for mouse events in fullscreen to start/stop the hiding timer.
(WebCore::MediaControlRootElementChromium::startHideFullscreenControlsTimer):
Start the fullscreen hiding timer.
(WebCore::MediaControlRootElementChromium::hideFullscreenControlsTimerFired):
Timer fired: hide the video controls in fullscreen.
(WebCore::MediaControlRootElementChromium::stopHideFullscreenControlsTimer):
Reset the fullscreen hiding timer.
(WebCore::MediaControlRootElementChromium::enteredFullscreen):
Add logic to enter fullscreen.
(WebCore::MediaControlRootElementChromium::exitedFullscreen):
Add logic to exit fullscreen.
* html/shadow/MediaControlRootElementChromium.h:
(MediaControlRootElementChromium):
Add declaration of member functions and fields for fullscreen.
* rendering/RenderMediaControlsChromium.cpp:
(WebCore::paintMediaFullscreenButton):
Use the new image for the fullscreen button.
* rendering/RenderThemeChromiumMac.h:
(RenderThemeChromiumMac):
Declare the fullscreen painting function for Chrome Mac.
* rendering/RenderThemeChromiumMac.mm:
(WebCore::RenderThemeChromiumMac::paintMediaFullscreenButton):
Hook up the fullscreen paining function for Chrome Mac.
* rendering/RenderThemeChromiumSkia.cpp:
(WebCore::RenderThemeChromiumSkia::paintMediaFullscreenButton):
Hook up the fullscreen paining function for Chrome Skia.
* rendering/RenderThemeChromiumSkia.h:
(RenderThemeChromiumSkia):
Declare the fullscreen painting function for Chrome Skia.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (120413 => 120414)


--- trunk/Source/WebCore/ChangeLog	2012-06-15 07:13:35 UTC (rev 120413)
+++ trunk/Source/WebCore/ChangeLog	2012-06-15 07:19:53 UTC (rev 120414)
@@ -1,3 +1,73 @@
+2012-06-15  Silvia Pfeiffer  <[email protected]>
+
+        Add fullscreen button to Chrome video controls for video.
+        https://bugs.webkit.org/show_bug.cgi?id=88818
+
+        Reviewed by Eric Carlson.
+
+        No new tests, final patch will contain the rebaselined tests.
+
+        The Chrome video controls are receiving a visual update.
+        This patch includes a fullscreen button for video elements and the rendering of the controls
+        in fullscreen including hiding them after 2 seconds when the mouse is out of the controls
+        and not moved.
+
+        * css/fullscreen.css:
+        (video:-webkit-full-screen, audio:-webkit-full-screen):
+        Add audio to the default fullscreen styling rules.
+        * css/mediaControlsChromium.css:
+        (video:-webkit-full-page-media::-webkit-media-controls-panel):
+        Align controls to the bottom of the fullscreen page.
+        (audio::-webkit-media-controls-fullscreen-button, video::-webkit-media-controls-fullscreen-button):
+        Include styling for the fullscreen button.
+        * html/shadow/MediaControlRootElementChromium.cpp:
+        (WebCore):
+        Add a constant for when to hide the controls in fullscreen.
+        (WebCore::MediaControlRootElementChromium::MediaControlRootElementChromium):
+        Add member fields for fullscreen button, hiding timer and tracking of whether we are in fullscreen.
+        (WebCore::MediaControlRootElementChromium::create):
+        Add fullscreen button element to the visual layout.
+        (WebCore::MediaControlRootElementChromium::setMediaController):
+        Add fullscreen button element to the media controller.
+        (WebCore::MediaControlRootElementChromium::reset):
+        Show the fullscreen button if the controller supports fullscreen.
+        (WebCore::MediaControlRootElementChromium::playbackStarted):
+        Start the timer to hide the controls in fullscreen.
+        (WebCore::MediaControlRootElementChromium::playbackStopped):
+        Don't hide the controls when the video is paused in fullscreen.
+        (WebCore::MediaControlRootElementChromium::reportedError):
+        Hide the fullscreen button when we hit an error.
+        (WebCore::MediaControlRootElementChromium::defaultEventHandler):
+        Add logic for mouse events in fullscreen to start/stop the hiding timer.
+        (WebCore::MediaControlRootElementChromium::startHideFullscreenControlsTimer):
+        Start the fullscreen hiding timer.
+        (WebCore::MediaControlRootElementChromium::hideFullscreenControlsTimerFired):
+        Timer fired: hide the video controls in fullscreen.
+        (WebCore::MediaControlRootElementChromium::stopHideFullscreenControlsTimer):
+        Reset the fullscreen hiding timer.
+        (WebCore::MediaControlRootElementChromium::enteredFullscreen):
+        Add logic to enter fullscreen.
+        (WebCore::MediaControlRootElementChromium::exitedFullscreen):
+        Add logic to exit fullscreen.
+        * html/shadow/MediaControlRootElementChromium.h:
+        (MediaControlRootElementChromium):
+        Add declaration of member functions and fields for fullscreen.
+        * rendering/RenderMediaControlsChromium.cpp:
+        (WebCore::paintMediaFullscreenButton):
+        Use the new image for the fullscreen button.
+        * rendering/RenderThemeChromiumMac.h:
+        (RenderThemeChromiumMac):
+        Declare the fullscreen painting function for Chrome Mac.
+        * rendering/RenderThemeChromiumMac.mm:
+        (WebCore::RenderThemeChromiumMac::paintMediaFullscreenButton):
+        Hook up the fullscreen paining function for Chrome Mac.
+        * rendering/RenderThemeChromiumSkia.cpp:
+        (WebCore::RenderThemeChromiumSkia::paintMediaFullscreenButton):
+        Hook up the fullscreen paining function for Chrome Skia.
+        * rendering/RenderThemeChromiumSkia.h:
+        (RenderThemeChromiumSkia):
+        Declare the fullscreen painting function for Chrome Skia.
+
 2012-06-14  Kent Tamura  <[email protected]>
 
         Unreviewed, rolling out r110340.

Modified: trunk/Source/WebCore/css/fullscreen.css (120413 => 120414)


--- trunk/Source/WebCore/css/fullscreen.css	2012-06-15 07:13:35 UTC (rev 120413)
+++ trunk/Source/WebCore/css/fullscreen.css	2012-06-15 07:19:53 UTC (rev 120414)
@@ -20,7 +20,7 @@
     -webkit-transform-style: flat !important;
 }
 
-video:-webkit-full-screen {
+video:-webkit-full-screen, audio:-webkit-full-screen {
     background-color: transparent !important;
     position: static !important;
     margin: 0 !important;

Modified: trunk/Source/WebCore/css/mediaControlsChromium.css (120413 => 120414)


--- trunk/Source/WebCore/css/mediaControlsChromium.css	2012-06-15 07:13:35 UTC (rev 120413)
+++ trunk/Source/WebCore/css/mediaControlsChromium.css	2012-06-15 07:19:53 UTC (rev 120414)
@@ -39,6 +39,11 @@
     max-width: 100%;
 }
 
+audio:-webkit-full-page-media::-webkit-media-controls-panel,
+video:-webkit-full-page-media::-webkit-media-controls-panel {
+    bottom: 0px;
+}
+
 ::-webkit-media-controls {
     display: -webkit-box;
     -webkit-box-orient: vertical;
@@ -171,3 +176,16 @@
     margin-left: -7px;
     margin-right: -7px;
 }
+
+audio::-webkit-media-controls-fullscreen-button, video::-webkit-media-controls-fullscreen-button {
+    -webkit-appearance: media-enter-fullscreen-button;
+    display: inline;
+    border: none;
+    box-sizing: border-box;
+    width: 30px;
+    height: 30px;
+    line-height: 30px;
+    margin-left: -5px;
+    margin-right: 9px;
+    padding: 0;
+}

Modified: trunk/Source/WebCore/html/shadow/MediaControlRootElementChromium.cpp (120413 => 120414)


--- trunk/Source/WebCore/html/shadow/MediaControlRootElementChromium.cpp	2012-06-15 07:13:35 UTC (rev 120413)
+++ trunk/Source/WebCore/html/shadow/MediaControlRootElementChromium.cpp	2012-06-15 07:19:53 UTC (rev 120414)
@@ -46,6 +46,8 @@
 
 namespace WebCore {
 
+static const double timeWithoutMouseMovementBeforeHidingControls = 2;
+
 MediaControlChromiumEnclosureElement::MediaControlChromiumEnclosureElement(Document* document)
     : HTMLDivElement(HTMLNames::divTag, document->document())
     , m_mediaController(0)
@@ -81,7 +83,9 @@
     , m_textDisplayContainer(0)
 #endif
     , m_opaque(true)
+    , m_hideFullscreenControlsTimer(this, &MediaControlRootElementChromium::hideFullscreenControlsTimerFired)
     , m_isMouseOverControls(false)
+    , m_isFullscreen(false)
 {
 }
 
@@ -254,6 +258,9 @@
     m_currentTimeDisplay->show();
     m_durationDisplay->hide();
     updateTimeDisplay();
+
+    if (m_isFullscreen)
+        startHideFullscreenControlsTimer();
 }
 
 void MediaControlRootElementChromium::playbackProgressed()
@@ -271,6 +278,8 @@
     m_timeline->setPosition(m_mediaController->currentTime());
     updateTimeDisplay();
     makeOpaque();
+
+    stopHideFullscreenControlsTimer();
 }
 
 void MediaControlRootElementChromium::updateTimeDisplay()
@@ -339,15 +348,55 @@
     if (event->type() == eventNames().mouseoverEvent) {
         if (!containsRelatedTarget(event)) {
             m_isMouseOverControls = true;
-            if (!m_mediaController->canPlay())
+            if (!m_mediaController->canPlay()) {
                 makeOpaque();
+                if (shouldHideControls())
+                    startHideFullscreenControlsTimer();
+            }
         }
     } else if (event->type() == eventNames().mouseoutEvent) {
-        if (!containsRelatedTarget(event))
+        if (!containsRelatedTarget(event)) {
             m_isMouseOverControls = false;
+            stopHideFullscreenControlsTimer();
+        }
+    } else if (event->type() == eventNames().mousemoveEvent) {
+        if (m_isFullscreen) {
+            // When we get a mouse move in fullscreen mode, show the media controls, and start a timer
+            // that will hide the media controls after a 2 seconds without a mouse move.
+            makeOpaque();
+            if (shouldHideControls())
+                startHideFullscreenControlsTimer();
+        }
     }
 }
 
+void MediaControlRootElementChromium::startHideFullscreenControlsTimer()
+{
+    if (!m_isFullscreen)
+        return;
+
+    m_hideFullscreenControlsTimer.startOneShot(timeWithoutMouseMovementBeforeHidingControls);
+}
+
+void MediaControlRootElementChromium::hideFullscreenControlsTimerFired(Timer<MediaControlRootElementChromium>*)
+{
+    if (m_mediaController->paused())
+        return;
+
+    if (!m_isFullscreen)
+        return;
+
+    if (!shouldHideControls())
+        return;
+
+    makeTransparent();
+}
+
+void MediaControlRootElementChromium::stopHideFullscreenControlsTimer()
+{
+    m_hideFullscreenControlsTimer.stop();
+}
+
 void MediaControlRootElementChromium::changedClosedCaptionsVisibility()
 {
 }
@@ -369,10 +418,16 @@
 
 void MediaControlRootElementChromium::enteredFullscreen()
 {
+    m_isFullscreen = true;
+    m_fullscreenButton->setIsFullscreen(true);
+    startHideFullscreenControlsTimer();
 }
 
 void MediaControlRootElementChromium::exitedFullscreen()
 {
+    m_isFullscreen = false;
+    m_fullscreenButton->setIsFullscreen(false);
+    stopHideFullscreenControlsTimer();
 }
 
 void MediaControlRootElementChromium::showVolumeSlider()

Modified: trunk/Source/WebCore/html/shadow/MediaControlRootElementChromium.h (120413 => 120414)


--- trunk/Source/WebCore/html/shadow/MediaControlRootElementChromium.h	2012-06-15 07:13:35 UTC (rev 120413)
+++ trunk/Source/WebCore/html/shadow/MediaControlRootElementChromium.h	2012-06-15 07:19:53 UTC (rev 120414)
@@ -126,6 +126,9 @@
     MediaControlRootElementChromium(Document*);
 
     virtual void defaultEventHandler(Event*);
+    void hideFullscreenControlsTimerFired(Timer<MediaControlRootElementChromium>*);
+    void startHideFullscreenControlsTimer();
+    void stopHideFullscreenControlsTimer();
 
     virtual const AtomicString& shadowPseudoId() const;
 
@@ -150,7 +153,9 @@
 #endif
 
     bool m_opaque;
+    Timer<MediaControlRootElementChromium> m_hideFullscreenControlsTimer;
     bool m_isMouseOverControls;
+    bool m_isFullscreen;
 };
 
 }

Modified: trunk/Source/WebCore/rendering/RenderMediaControlsChromium.cpp (120413 => 120414)


--- trunk/Source/WebCore/rendering/RenderMediaControlsChromium.cpp	2012-06-15 07:13:35 UTC (rev 120413)
+++ trunk/Source/WebCore/rendering/RenderMediaControlsChromium.cpp	2012-06-15 07:19:53 UTC (rev 120414)
@@ -274,8 +274,8 @@
     if (!mediaElement)
         return false;
 
-    DEFINE_STATIC_LOCAL(Image*, mediaFullscreen, (platformResource("mediaFullscreen")));
-    return paintMediaButton(paintInfo.context, rect, mediaFullscreen);
+    static Image* mediaFullscreenButton = platformResource("mediaplayerFullscreen");
+    return paintMediaButton(paintInfo.context, rect, mediaFullscreenButton);
 }
 
 bool RenderMediaControlsChromium::paintMediaControlsPart(MediaControlElementType part, RenderObject* object, const PaintInfo& paintInfo, const IntRect& rect)

Modified: trunk/Source/WebCore/rendering/RenderThemeChromiumMac.h (120413 => 120414)


--- trunk/Source/WebCore/rendering/RenderThemeChromiumMac.h	2012-06-15 07:13:35 UTC (rev 120413)
+++ trunk/Source/WebCore/rendering/RenderThemeChromiumMac.h	2012-06-15 07:19:53 UTC (rev 120414)
@@ -58,6 +58,7 @@
     virtual String formatMediaControlsTime(float time) const;
     virtual String formatMediaControlsCurrentTime(float currentTime, float duration) const;
     virtual String formatMediaControlsRemainingTime(float currentTime, float duration) const;
+    virtual bool paintMediaFullscreenButton(RenderObject*, const PaintInfo&, const IntRect&);
 #endif
 
     virtual bool usesTestModeFocusRingColor() const;

Modified: trunk/Source/WebCore/rendering/RenderThemeChromiumMac.mm (120413 => 120414)


--- trunk/Source/WebCore/rendering/RenderThemeChromiumMac.mm	2012-06-15 07:13:35 UTC (rev 120413)
+++ trunk/Source/WebCore/rendering/RenderThemeChromiumMac.mm	2012-06-15 07:19:53 UTC (rev 120414)
@@ -238,6 +238,11 @@
 {
     return RenderThemeChromiumMac::formatMediaControlsRemainingTime(currentTime, duration);
 }
+
+bool RenderThemeChromiumMac::paintMediaFullscreenButton(RenderObject* object, const PaintInfo& paintInfo, const IntRect& rect)
+{
+    return RenderMediaControlsChromium::paintMediaControlsPart(MediaEnterFullscreenButton, object, paintInfo, rect);
+}
 #endif
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/rendering/RenderThemeChromiumSkia.cpp (120413 => 120414)


--- trunk/Source/WebCore/rendering/RenderThemeChromiumSkia.cpp	2012-06-15 07:13:35 UTC (rev 120413)
+++ trunk/Source/WebCore/rendering/RenderThemeChromiumSkia.cpp	2012-06-15 07:19:53 UTC (rev 120414)
@@ -491,6 +491,18 @@
 #endif
 }
 
+bool RenderThemeChromiumSkia::paintMediaFullscreenButton(RenderObject* object, const PaintInfo& paintInfo, const IntRect& rect)
+{
+#if ENABLE(VIDEO)
+    return RenderMediaControlsChromium::paintMediaControlsPart(MediaEnterFullscreenButton, object, paintInfo, rect);
+#else
+    UNUSED_PARAM(object);
+    UNUSED_PARAM(paintInfo);
+    UNUSED_PARAM(rect);
+    return false;
+#endif
+}
+
 void RenderThemeChromiumSkia::adjustMenuListStyle(StyleResolver*, RenderStyle* style, WebCore::Element*) const
 {
     // Height is locked to auto on all browsers.

Modified: trunk/Source/WebCore/rendering/RenderThemeChromiumSkia.h (120413 => 120414)


--- trunk/Source/WebCore/rendering/RenderThemeChromiumSkia.h	2012-06-15 07:13:35 UTC (rev 120413)
+++ trunk/Source/WebCore/rendering/RenderThemeChromiumSkia.h	2012-06-15 07:19:53 UTC (rev 120414)
@@ -101,6 +101,7 @@
         virtual String formatMediaControlsTime(float time) const;
         virtual String formatMediaControlsCurrentTime(float currentTime, float duration) const;
         virtual String formatMediaControlsRemainingTime(float currentTime, float duration) const;
+        virtual bool paintMediaFullscreenButton(RenderObject*, const PaintInfo&, const IntRect&);
 
         // MenuList refers to an unstyled menulist (meaning a menulist without
         // background-color or border set) and MenuListButton refers to a styled

Modified: trunk/Source/WebKit/chromium/features.gypi (120413 => 120414)


--- trunk/Source/WebKit/chromium/features.gypi	2012-06-15 07:13:35 UTC (rev 120413)
+++ trunk/Source/WebKit/chromium/features.gypi	2012-06-15 07:19:53 UTC (rev 120414)
@@ -161,7 +161,7 @@
         'feature_defines': [
           'ENABLE_CALENDAR_PICKER=1',
           'ENABLE_FONT_BOOSTING=0',
-          'ENABLE_FULLSCREEN_MEDIA_CONTROLS=0',
+          'ENABLE_FULLSCREEN_MEDIA_CONTROLS=1',
           'ENABLE_INPUT_SPEECH=1',
           'ENABLE_JAVASCRIPT_I18N_API=1',
           'ENABLE_LEGACY_NOTIFICATIONS=1',
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to