Title: [120322] trunk/Source/WebCore
Revision
120322
Author
[email protected]
Date
2012-06-14 07:01:36 -0700 (Thu, 14 Jun 2012)

Log Message

Update the time display of the new Chromium media controls.
https://bugs.webkit.org/show_bug.cgi?id=88724

Patch by Silvia Pfeiffer <[email protected]> on 2012-06-14
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 changes
the format of the time digits that are displayed. They are different for media
files of different duration. For non-autoplaying videos, the duration is shown
before playback is started.

* css/mediaControlsChromium.css:
(audio::-webkit-media-controls-time-remaining-display, video::-webkit-media-controls-time-remaining-display):
Format the new duration display the same as the current time display.
* html/shadow/MediaControlRootElementChromium.cpp:
(WebCore::MediaControlRootElementChromium::MediaControlRootElementChromium):
Add a member field for the duration display.
(WebCore::MediaControlRootElementChromium::create):
Add an element for the duration display and initially hide the current time display.
(WebCore::MediaControlRootElementChromium::setMediaController):
Add the duration display to the controller.
(WebCore::MediaControlRootElementChromium::reset):
Add reset functionality for the duration display.
(WebCore::MediaControlRootElementChromium::playbackStarted):
Show the current time display and hide the duration display upon playback start.
(WebCore::MediaControlRootElementChromium::updateTimeDisplay):
Show the current time display and hide the duration display when current time is non-zero.
* html/shadow/MediaControlRootElementChromium.h:
(WebCore):
Add the MediaControlTimeRemainingDisplayElement which provides use with the duration display.
(MediaControlRootElementChromium):
Add a duration member field, reusing the existing MediaControlTimeRemainingDisplayElement.
* rendering/RenderMediaControlsChromium.cpp:
(WebCore::formatChromiumMediaControlsTime):
Formats a given time under the condition of a given duration.
(WebCore::RenderMediaControlsChromium::formatMediaControlsTime):
When formatting a single time, assume it to also provide the duration conditions.
(WebCore::RenderMediaControlsChromium::formatMediaControlsCurrentTime):
Format the current time given the duration.
(WebCore::RenderMediaControlsChromium::formatMediaControlsRemainingTime):
Format the remaining time from the current time given the duration.
* rendering/RenderMediaControlsChromium.h:
(RenderMediaControlsChromium):
Declare the time formatting member functions.
* rendering/RenderThemeChromiumMac.h:
(RenderThemeChromiumMac):
Declare the time formatting member functions for Chromium on the Mac.
* rendering/RenderThemeChromiumMac.mm:
(WebCore::RenderThemeChromiumMac::formatMediaControlsTime):
(WebCore::RenderThemeChromiumMac::formatMediaControlsCurrentTime):
(WebCore::RenderThemeChromiumMac::formatMediaControlsRemainingTime):
Call the time formatting member functions of RenderMediaControlsChromium on the Mac.
* rendering/RenderThemeChromiumSkia.cpp:
(WebCore::formatMediaControlsTime):
(WebCore::formatMediaControlsCurrentTime):
(WebCore::formatMediaControlsRemainingTime):
Call the time formatting member functions of RenderMediaControlsChromium on Skia.
* rendering/RenderThemeChromiumSkia.h:
(RenderThemeChromiumSkia):
Declare the time formatting member functions for Chromium Skia.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (120321 => 120322)


--- trunk/Source/WebCore/ChangeLog	2012-06-14 13:58:01 UTC (rev 120321)
+++ trunk/Source/WebCore/ChangeLog	2012-06-14 14:01:36 UTC (rev 120322)
@@ -1,3 +1,67 @@
+2012-06-14  Silvia Pfeiffer  <[email protected]>
+
+        Update the time display of the new Chromium media controls.
+        https://bugs.webkit.org/show_bug.cgi?id=88724
+
+        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 changes
+        the format of the time digits that are displayed. They are different for media
+        files of different duration. For non-autoplaying videos, the duration is shown
+        before playback is started.
+
+        * css/mediaControlsChromium.css:
+        (audio::-webkit-media-controls-time-remaining-display, video::-webkit-media-controls-time-remaining-display):
+        Format the new duration display the same as the current time display.
+        * html/shadow/MediaControlRootElementChromium.cpp:
+        (WebCore::MediaControlRootElementChromium::MediaControlRootElementChromium):
+        Add a member field for the duration display.
+        (WebCore::MediaControlRootElementChromium::create):
+        Add an element for the duration display and initially hide the current time display.
+        (WebCore::MediaControlRootElementChromium::setMediaController):
+        Add the duration display to the controller.
+        (WebCore::MediaControlRootElementChromium::reset):
+        Add reset functionality for the duration display.
+        (WebCore::MediaControlRootElementChromium::playbackStarted):
+        Show the current time display and hide the duration display upon playback start.
+        (WebCore::MediaControlRootElementChromium::updateTimeDisplay):
+        Show the current time display and hide the duration display when current time is non-zero.
+        * html/shadow/MediaControlRootElementChromium.h:
+        (WebCore):
+        Add the MediaControlTimeRemainingDisplayElement which provides use with the duration display.
+        (MediaControlRootElementChromium):
+        Add a duration member field, reusing the existing MediaControlTimeRemainingDisplayElement.
+        * rendering/RenderMediaControlsChromium.cpp:
+        (WebCore::formatChromiumMediaControlsTime):
+        Formats a given time under the condition of a given duration.
+        (WebCore::RenderMediaControlsChromium::formatMediaControlsTime):
+        When formatting a single time, assume it to also provide the duration conditions.
+        (WebCore::RenderMediaControlsChromium::formatMediaControlsCurrentTime):
+        Format the current time given the duration.
+        (WebCore::RenderMediaControlsChromium::formatMediaControlsRemainingTime):
+        Format the remaining time from the current time given the duration.
+        * rendering/RenderMediaControlsChromium.h:
+        (RenderMediaControlsChromium):
+        Declare the time formatting member functions.
+        * rendering/RenderThemeChromiumMac.h:
+        (RenderThemeChromiumMac):
+        Declare the time formatting member functions for Chromium on the Mac.
+        * rendering/RenderThemeChromiumMac.mm:
+        (WebCore::RenderThemeChromiumMac::formatMediaControlsTime):
+        (WebCore::RenderThemeChromiumMac::formatMediaControlsCurrentTime):
+        (WebCore::RenderThemeChromiumMac::formatMediaControlsRemainingTime):
+        Call the time formatting member functions of RenderMediaControlsChromium on the Mac.
+        * rendering/RenderThemeChromiumSkia.cpp:
+        (WebCore::formatMediaControlsTime):
+        (WebCore::formatMediaControlsCurrentTime):
+        (WebCore::formatMediaControlsRemainingTime):
+        Call the time formatting member functions of RenderMediaControlsChromium on Skia.
+        * rendering/RenderThemeChromiumSkia.h:
+        (RenderThemeChromiumSkia):
+        Declare the time formatting member functions for Chromium Skia.
+
 2012-06-14  Eugene Klyuchnikov  <[email protected]>
 
         Web Inspector: Refactor message loop instrumentation.

Modified: trunk/Source/WebCore/css/mediaControlsChromium.css (120321 => 120322)


--- trunk/Source/WebCore/css/mediaControlsChromium.css	2012-06-14 13:58:01 UTC (rev 120321)
+++ trunk/Source/WebCore/css/mediaControlsChromium.css	2012-06-14 14:01:36 UTC (rev 120322)
@@ -97,7 +97,8 @@
     padding: 0;
 }
 
-audio::-webkit-media-controls-current-time-display, video::-webkit-media-controls-current-time-display {
+audio::-webkit-media-controls-current-time-display, video::-webkit-media-controls-current-time-display,
+audio::-webkit-media-controls-time-remaining-display, video::-webkit-media-controls-time-remaining-display {
     -webkit-appearance: media-current-time-display;
     -webkit-user-select: none;
     display: block;
@@ -111,6 +112,7 @@
     line-height: 30px;
     font-family: Arial, Helvetica, sans-serif;
     font-size: 13px;
+    font-weight: bold;
     color: white;
 
     letter-spacing: normal;

Modified: trunk/Source/WebCore/html/shadow/MediaControlRootElementChromium.cpp (120321 => 120322)


--- trunk/Source/WebCore/html/shadow/MediaControlRootElementChromium.cpp	2012-06-14 13:58:01 UTC (rev 120321)
+++ trunk/Source/WebCore/html/shadow/MediaControlRootElementChromium.cpp	2012-06-14 14:01:36 UTC (rev 120322)
@@ -68,6 +68,7 @@
     , m_mediaController(0)
     , m_playButton(0)
     , m_currentTimeDisplay(0)
+    , m_durationDisplay(0)
     , m_timeline(0)
     , m_panelMuteButton(0)
     , m_volumeSlider(0)
@@ -117,10 +118,17 @@
 
     RefPtr<MediaControlCurrentTimeDisplayElement> currentTimeDisplay = MediaControlCurrentTimeDisplayElement::create(document);
     controls->m_currentTimeDisplay = currentTimeDisplay.get();
+    controls->m_currentTimeDisplay->hide();
     panel->appendChild(currentTimeDisplay.release(), ec, true);
     if (ec)
         return 0;
 
+    RefPtr<MediaControlTimeRemainingDisplayElement> durationDisplay = MediaControlTimeRemainingDisplayElement::create(document);
+    controls->m_durationDisplay = durationDisplay.get();
+    panel->appendChild(durationDisplay.release(), ec, true);
+    if (ec)
+        return 0;
+
     RefPtr<MediaControlPanelMuteButtonElement> panelMuteButton = MediaControlPanelMuteButtonElement::create(document, controls.get());
     controls->m_panelMuteButton = panelMuteButton.get();
     panel->appendChild(panelMuteButton.release(), ec, true);
@@ -164,6 +172,8 @@
         m_playButton->setMediaController(controller);
     if (m_currentTimeDisplay)
         m_currentTimeDisplay->setMediaController(controller);
+    if (m_durationDisplay)
+        m_durationDisplay->setMediaController(controller);
     if (m_timeline)
         m_timeline->setMediaController(controller);
     if (m_panelMuteButton)
@@ -218,6 +228,10 @@
     float duration = m_mediaController->duration();
     m_timeline->setDuration(duration);
     m_timeline->show();
+
+    m_durationDisplay->setInnerText(page->theme()->formatMediaControlsTime(duration), ASSERT_NO_EXCEPTION);
+    m_durationDisplay->setCurrentValue(duration);
+
     m_timeline->setPosition(m_mediaController->currentTime());
     updateTimeDisplay();
 
@@ -236,6 +250,8 @@
 {
     m_playButton->updateDisplayType();
     m_timeline->setPosition(m_mediaController->currentTime());
+    m_currentTimeDisplay->show();
+    m_durationDisplay->hide();
     updateTimeDisplay();
 }
 
@@ -265,6 +281,12 @@
     if (!page)
         return;
 
+    // After seek, hide duration display and show current time.
+    if (now > 0) {
+        m_currentTimeDisplay->show();
+        m_durationDisplay->hide();
+    }
+
     // Allow the theme to format the time.
     ExceptionCode ec;
     m_currentTimeDisplay->setInnerText(page->theme()->formatMediaControlsCurrentTime(now, duration), ec);

Modified: trunk/Source/WebCore/html/shadow/MediaControlRootElementChromium.h (120321 => 120322)


--- trunk/Source/WebCore/html/shadow/MediaControlRootElementChromium.h	2012-06-14 13:58:01 UTC (rev 120321)
+++ trunk/Source/WebCore/html/shadow/MediaControlRootElementChromium.h	2012-06-14 14:01:36 UTC (rev 120322)
@@ -40,6 +40,7 @@
 class MediaControlPanelMuteButtonElement;
 class MediaControlPlayButtonElement;
 class MediaControlCurrentTimeDisplayElement;
+class MediaControlTimeRemainingDisplayElement;
 class MediaControlTimelineElement;
 class MediaControlVolumeSliderElement;
 class MediaControlFullscreenButtonElement;
@@ -134,6 +135,7 @@
 
     MediaControlPlayButtonElement* m_playButton;
     MediaControlCurrentTimeDisplayElement* m_currentTimeDisplay;
+    MediaControlTimeRemainingDisplayElement* m_durationDisplay;
     MediaControlTimelineElement* m_timeline;
     MediaControlTimelineContainerElement* m_timelineContainer;
     MediaControlPanelMuteButtonElement* m_panelMuteButton;

Modified: trunk/Source/WebCore/rendering/RenderMediaControlsChromium.cpp (120321 => 120322)


--- trunk/Source/WebCore/rendering/RenderMediaControlsChromium.cpp	2012-06-14 13:58:01 UTC (rev 120321)
+++ trunk/Source/WebCore/rendering/RenderMediaControlsChromium.cpp	2012-06-14 14:01:36 UTC (rev 120322)
@@ -348,6 +348,45 @@
     }
 }
 
+static String formatChromiumMediaControlsTime(float time, float duration)
+{
+    if (!isfinite(time))
+        time = 0;
+    if (!isfinite(duration))
+        duration = 0;
+    int seconds = static_cast<int>(fabsf(time));
+    int hours = seconds / (60 * 60);
+    int minutes = (seconds / 60) % 60;
+    seconds %= 60;
+
+    // duration defines the format of how the time is rendered
+    int durationSecs = static_cast<int>(fabsf(duration));
+    int durationHours = durationSecs / (60 * 60);
+    int durationMins = (durationSecs / 60) % 60;
+
+    if (durationHours || hours)
+        return String::format("%s%01d:%02d:%02d", (time < 0 ? "-" : ""), hours, minutes, seconds);
+    if (durationMins > 9)
+        return String::format("%s%02d:%02d", (time < 0 ? "-" : ""), minutes, seconds);
+
+    return String::format("%s%01d:%02d", (time < 0 ? "-" : ""), minutes, seconds);
+}
+
+String RenderMediaControlsChromium::formatMediaControlsTime(float time)
+{
+    return formatChromiumMediaControlsTime(time, time);
+}
+
+String RenderMediaControlsChromium::formatMediaControlsCurrentTime(float currentTime, float duration)
+{
+    return formatChromiumMediaControlsTime(currentTime, duration);
+}
+
+String RenderMediaControlsChromium::formatMediaControlsRemainingTime(float currentTime, float duration)
+{
+    return formatChromiumMediaControlsTime(currentTime - duration, duration);
+}
+
 #endif  // #if ENABLE(VIDEO)
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/rendering/RenderMediaControlsChromium.h (120321 => 120322)


--- trunk/Source/WebCore/rendering/RenderMediaControlsChromium.h	2012-06-14 13:58:01 UTC (rev 120321)
+++ trunk/Source/WebCore/rendering/RenderMediaControlsChromium.h	2012-06-14 14:01:36 UTC (rev 120322)
@@ -38,6 +38,9 @@
 public:
     static bool paintMediaControlsPart(MediaControlElementType, RenderObject*, const PaintInfo&, const IntRect&);
     static void adjustMediaSliderThumbSize(RenderStyle*);
+    static String formatMediaControlsTime(float time);
+    static String formatMediaControlsCurrentTime(float currentTime, float duration);
+    static String formatMediaControlsRemainingTime(float currentTime, float duration);
 };
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/rendering/RenderThemeChromiumMac.h (120321 => 120322)


--- trunk/Source/WebCore/rendering/RenderThemeChromiumMac.h	2012-06-14 13:58:01 UTC (rev 120321)
+++ trunk/Source/WebCore/rendering/RenderThemeChromiumMac.h	2012-06-14 14:01:36 UTC (rev 120322)
@@ -55,6 +55,9 @@
     virtual bool usesMediaControlStatusDisplay() { return false; }
     virtual bool hasOwnDisabledStateHandlingFor(ControlPart) const { return true; }
     virtual bool usesVerticalVolumeSlider() const { return false; }
+    virtual String formatMediaControlsTime(float time) const;
+    virtual String formatMediaControlsCurrentTime(float currentTime, float duration) const;
+    virtual String formatMediaControlsRemainingTime(float currentTime, float duration) const;
 #endif
 
     virtual bool usesTestModeFocusRingColor() const;

Modified: trunk/Source/WebCore/rendering/RenderThemeChromiumMac.mm (120321 => 120322)


--- trunk/Source/WebCore/rendering/RenderThemeChromiumMac.mm	2012-06-14 13:58:01 UTC (rev 120321)
+++ trunk/Source/WebCore/rendering/RenderThemeChromiumMac.mm	2012-06-14 14:01:36 UTC (rev 120322)
@@ -223,6 +223,21 @@
 {
     return RenderTheme::volumeSliderOffsetFromMuteButton(muteButtonBox, size);
 }
+
+String RenderThemeChromiumMac::formatMediaControlsTime(float time) const
+{
+    return RenderMediaControlsChromium::formatMediaControlsTime(time);
+}
+
+String RenderThemeChromiumMac::formatMediaControlsCurrentTime(float currentTime, float duration) const
+{
+    return RenderMediaControlsChromium::formatMediaControlsCurrentTime(currentTime, duration);
+}
+
+String RenderThemeChromiumMac::formatMediaControlsRemainingTime(float currentTime, float duration) const
+{
+    return RenderThemeChromiumMac::formatMediaControlsRemainingTime(currentTime, duration);
+}
 #endif
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/rendering/RenderThemeChromiumSkia.cpp (120321 => 120322)


--- trunk/Source/WebCore/rendering/RenderThemeChromiumSkia.cpp	2012-06-14 13:58:01 UTC (rev 120321)
+++ trunk/Source/WebCore/rendering/RenderThemeChromiumSkia.cpp	2012-06-14 14:01:36 UTC (rev 120322)
@@ -459,6 +459,38 @@
 #endif
 }
 
+String RenderThemeChromiumSkia::formatMediaControlsTime(float time) const
+{
+#if ENABLE(VIDEO)
+    return RenderMediaControlsChromium::formatMediaControlsTime(time);
+#else
+    UNUSED_PARAM(time);
+    return 0;
+#endif
+}
+
+String RenderThemeChromiumSkia::formatMediaControlsCurrentTime(float currentTime, float duration) const
+{
+#if ENABLE(VIDEO)
+    return RenderMediaControlsChromium::formatMediaControlsCurrentTime(currentTime, duration);
+#else
+    UNUSED_PARAM(currentTime);
+    UNUSED_PARAM(duration);
+    return 0;
+#endif
+}
+
+String RenderThemeChromiumSkia::formatMediaControlsRemainingTime(float currentTime, float duration) const
+{
+#if ENABLE(VIDEO)
+    return RenderMediaControlsChromium::formatMediaControlsRemainingTime(currentTime, duration);
+#else
+    UNUSED_PARAM(currentTime);
+    UNUSED_PARAM(duration);
+    return 0;
+#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 (120321 => 120322)


--- trunk/Source/WebCore/rendering/RenderThemeChromiumSkia.h	2012-06-14 13:58:01 UTC (rev 120321)
+++ trunk/Source/WebCore/rendering/RenderThemeChromiumSkia.h	2012-06-14 14:01:36 UTC (rev 120322)
@@ -98,6 +98,9 @@
         virtual bool paintMediaVolumeSliderThumb(RenderObject*, const PaintInfo&, const IntRect&);
         virtual bool paintMediaPlayButton(RenderObject*, const PaintInfo&, const IntRect&);
         virtual bool paintMediaMuteButton(RenderObject*, const PaintInfo&, const IntRect&);
+        virtual String formatMediaControlsTime(float time) const;
+        virtual String formatMediaControlsCurrentTime(float currentTime, float duration) const;
+        virtual String formatMediaControlsRemainingTime(float currentTime, float duration) const;
 
         // MenuList refers to an unstyled menulist (meaning a menulist without
         // background-color or border set) and MenuListButton refers to a styled
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to