Title: [120478] trunk/Source/WebCore
Revision
120478
Author
commit-qu...@webkit.org
Date
2012-06-15 10:59:50 -0700 (Fri, 15 Jun 2012)

Log Message

Remove volume thumb for videos without audio track.
https://bugs.webkit.org/show_bug.cgi?id=89093

Patch by Silvia Pfeiffer <silvi...@chromium.org> on 2012-06-15
Reviewed by Eric Carlson.

No new tests, since this was already tested in media/video-no-audio.html.

* rendering/RenderMediaControlsChromium.cpp:
(WebCore::paintMediaMuteButton):
Change mute button when there is no audio or no source file.
(WebCore::paintMediaVolumeSlider):
Set volume slider to 0 when there is no audio or no source file.
(WebCore::paintMediaVolumeSliderThumb):
Don't paint the volume slider thumb when there is no audio or no source file.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (120477 => 120478)


--- trunk/Source/WebCore/ChangeLog	2012-06-15 17:57:57 UTC (rev 120477)
+++ trunk/Source/WebCore/ChangeLog	2012-06-15 17:59:50 UTC (rev 120478)
@@ -1,3 +1,20 @@
+2012-06-15  Silvia Pfeiffer  <silvi...@chromium.org>
+
+        Remove volume thumb for videos without audio track.
+        https://bugs.webkit.org/show_bug.cgi?id=89093
+
+        Reviewed by Eric Carlson.
+
+        No new tests, since this was already tested in media/video-no-audio.html.
+
+        * rendering/RenderMediaControlsChromium.cpp:
+        (WebCore::paintMediaMuteButton):
+        Change mute button when there is no audio or no source file.
+        (WebCore::paintMediaVolumeSlider):
+        Set volume slider to 0 when there is no audio or no source file.
+        (WebCore::paintMediaVolumeSliderThumb):
+        Don't paint the volume slider thumb when there is no audio or no source file.
+
 2012-06-15  Abhishek Arya  <infe...@chromium.org>
 
         Cleanup empty anonymous block continuation.

Modified: trunk/Source/WebCore/rendering/RenderMediaControlsChromium.cpp (120477 => 120478)


--- trunk/Source/WebCore/rendering/RenderMediaControlsChromium.cpp	2012-06-15 17:57:57 UTC (rev 120477)
+++ trunk/Source/WebCore/rendering/RenderMediaControlsChromium.cpp	2012-06-15 17:59:50 UTC (rev 120478)
@@ -77,11 +77,15 @@
     static Image* soundLevel3 = platformResource("mediaplayerSoundLevel3");
     static Image* soundLevel2 = platformResource("mediaplayerSoundLevel2");
     static Image* soundLevel1 = platformResource("mediaplayerSoundLevel1");
+    static Image* soundLevel0 = platformResource("mediaplayerSoundLevel0");
     static Image* soundDisabled = platformResource("mediaplayerSoundDisabled");
 
-    if (!hasSource(mediaElement) || !mediaElement->hasAudio() || mediaElement->muted() || mediaElement->volume() <= 0)
+    if (!hasSource(mediaElement) || !mediaElement->hasAudio())
         return paintMediaButton(paintInfo.context, rect, soundDisabled);
 
+    if (mediaElement->muted() || mediaElement->volume() <= 0)
+        return paintMediaButton(paintInfo.context, rect, soundLevel0);
+
     if (mediaElement->volume() <= 0.33)
         return paintMediaButton(paintInfo.context, rect, soundLevel1);
 
@@ -248,14 +252,17 @@
         return true;
     if (volume > 1)
         volume = 1;
-    if (mediaElement->muted())
+    if (!hasSource(mediaElement) || !mediaElement->hasAudio() || mediaElement->muted())
         volume = 0;
 
     // Calculate the position relative to the center of the thumb.
-    float thumbCenter = mediaVolumeSliderThumbWidth / 2;
-    float zoomLevel = style->effectiveZoom();
-    float positionWidth = volume * (rect.width() - (zoomLevel * thumbCenter));
-    float fillWidth = positionWidth + (zoomLevel * thumbCenter / 2);
+    float fillWidth = 0;
+    if (volume > 0) {
+        float thumbCenter = mediaVolumeSliderThumbWidth / 2;
+        float zoomLevel = style->effectiveZoom();
+        float positionWidth = volume * (rect.width() - (zoomLevel * thumbCenter));
+        fillWidth = positionWidth + (zoomLevel * thumbCenter / 2);
+    }
 
     paintSliderRangeHighlight(rect, style, context, 0.0, fillWidth / rect.width());
 
@@ -264,6 +271,16 @@
 
 static bool paintMediaVolumeSliderThumb(RenderObject* object, const PaintInfo& paintInfo, const IntRect& rect)
 {
+    ASSERT(object->node());
+    Node* hostNode = object->node()->shadowAncestorNode();
+    ASSERT(hostNode);
+    HTMLMediaElement* mediaElement = toParentMediaElement(hostNode);
+    if (!mediaElement)
+        return false;
+
+    if (!hasSource(mediaElement) || !mediaElement->hasAudio())
+        return true;
+
     static Image* mediaVolumeSliderThumb = platformResource("mediaplayerVolumeSliderThumb");
     return paintMediaButton(paintInfo.context, rect, mediaVolumeSliderThumb);
 }
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to