Title: [118577] trunk
Revision
118577
Author
[email protected]
Date
2012-05-25 15:30:56 -0700 (Fri, 25 May 2012)

Log Message

[chromium] Default media controls should render only the currentTime-containing buffered range
https://bugs.webkit.org/show_bug.cgi?id=85925

Reviewed by Eric Carlson.

Test: http/tests/media/video-buffered-range-contains-currentTime.html

* rendering/RenderMediaControlsChromium.cpp:
(WebCore::paintMediaSlider):

Modified Paths

Added Paths

Diff

Added: trunk/LayoutTests/http/tests/media/video-buffered-range-contains-currentTime-expected.txt (0 => 118577)


--- trunk/LayoutTests/http/tests/media/video-buffered-range-contains-currentTime-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/http/tests/media/video-buffered-range-contains-currentTime-expected.txt	2012-05-25 22:30:56 UTC (rev 118577)
@@ -0,0 +1,7 @@
+Test that the painted buffered range contains currentTime.
+
+EVENT(loadedmetadata)
+EVENT(seeked)
+EVENT(ended)
+END OF TEST
+
Property changes on: trunk/LayoutTests/http/tests/media/video-buffered-range-contains-currentTime-expected.txt
___________________________________________________________________

Added: svn:eol-style

Added: trunk/LayoutTests/http/tests/media/video-buffered-range-contains-currentTime.html (0 => 118577)


--- trunk/LayoutTests/http/tests/media/video-buffered-range-contains-currentTime.html	                        (rev 0)
+++ trunk/LayoutTests/http/tests/media/video-buffered-range-contains-currentTime.html	2012-05-25 22:30:56 UTC (rev 118577)
@@ -0,0 +1,31 @@
+<html>
+  <head>
+      <script src=""
+      <script src=""
+      <script>
+          if (window.layoutTestController)
+              layoutTestController.dumpAsText(true); // To get pixels.
+
+          function start() {
+              findMediaElement();
+  
+              waitForEventAndEnd('ended');
+              waitForEvent('seeked', function() {
+                  video.play();
+              });
+              waitForEvent('loadedmetadata', function() {
+                  video.currentTime = video.duration - 0.5;
+              } );
+
+              var mediaFile = findMediaFile("audio", "../../../media/content/test");
+              var type = mimeTypeForExtension(mediaFile.split('.').pop());
+              video.src = "" + mediaFile + "&throttle=50&nph=1&type=" + type;
+              video.load();
+          }
+      </script>
+    </head>
+    <body _onload_="start()">
+      <video controls></video>
+      <p>Test that the painted buffered range contains currentTime.</p>
+    </body>
+</html>
Property changes on: trunk/LayoutTests/http/tests/media/video-buffered-range-contains-currentTime.html
___________________________________________________________________

Added: svn:eol-style

Added: trunk/LayoutTests/platform/chromium-linux/http/tests/media/video-buffered-range-contains-currentTime-expected.png


(Binary files differ)
Property changes on: trunk/LayoutTests/platform/chromium-linux/http/tests/media/video-buffered-range-contains-currentTime-expected.png ___________________________________________________________________

Added: svn:mime-type

Modified: trunk/Source/WebCore/ChangeLog (118576 => 118577)


--- trunk/Source/WebCore/ChangeLog	2012-05-25 22:24:41 UTC (rev 118576)
+++ trunk/Source/WebCore/ChangeLog	2012-05-25 22:30:56 UTC (rev 118577)
@@ -1,3 +1,15 @@
+2012-05-25  Ami Fischman  <[email protected]>
+
+        [chromium] Default media controls should render only the currentTime-containing buffered range
+        https://bugs.webkit.org/show_bug.cgi?id=85925
+
+        Reviewed by Eric Carlson.
+
+        Test: http/tests/media/video-buffered-range-contains-currentTime.html
+
+        * rendering/RenderMediaControlsChromium.cpp:
+        (WebCore::paintMediaSlider):
+
 2012-05-25  Simon Fraser  <[email protected]>
 
         Build fix: add TransformationMatrix ctor from an AffineTransform.

Modified: trunk/Source/WebCore/rendering/RenderMediaControlsChromium.cpp (118576 => 118577)


--- trunk/Source/WebCore/rendering/RenderMediaControlsChromium.cpp	2012-05-25 22:24:41 UTC (rev 118576)
+++ trunk/Source/WebCore/rendering/RenderMediaControlsChromium.cpp	2012-05-25 22:30:56 UTC (rev 118577)
@@ -127,37 +127,37 @@
     context->drawRect(rect);
     context->restore();
 
-    // Draw the buffered ranges.
-    // FIXME: Draw multiple ranges if there are multiple buffered ranges. http://webkit.org/b/85925
+    // Draw the buffered range. Since the element may have multiple buffered ranges and it'd be
+    // distracting/'busy' to show all of them, show only the buffered range containing the current play head.
     IntRect bufferedRect = rect;
     bufferedRect.inflate(-style->borderLeftWidth());
 
-    double bufferedWidth = 0.0;
     RefPtr<TimeRanges> bufferedTimeRanges = mediaElement->buffered();
-    if (bufferedTimeRanges->length() > 0) {
-        // Account for the width of the slider thumb.
-        Image* mediaSliderThumb = getMediaSliderThumb();
-        double thumbWidth = mediaSliderThumb->width() / 2.0 + 1.0;
-        double rectWidth = bufferedRect.width() - thumbWidth;
-        if (rectWidth < 0.0)
-            rectWidth = 0.0;
-        // Preserve old behavior pending resolution of UI design of multiple ranges (see FIXME above).
-        // http://webkit.org/b/85926
-        double fakePercentLoaded = 0;
-        float duration = mediaElement->duration();
-        if (duration && !isinf(duration))
-            fakePercentLoaded = bufferedTimeRanges->end(bufferedTimeRanges->length() - 1, ASSERT_NO_EXCEPTION) / duration;
-        bufferedWidth = rectWidth * fakePercentLoaded + thumbWidth;
-    }
-    bufferedRect.setWidth(bufferedWidth);
+    float duration = mediaElement->duration();
+    float currentTime = mediaElement->currentTime();
+    if (isnan(duration) || isinf(duration) || !duration || isnan(currentTime))
+        return true;
 
-    // Don't bother drawing an empty area.
-    if (!bufferedRect.isEmpty()) {
+    for (unsigned i = 0; i < bufferedTimeRanges->length(); ++i) {
+        float start = bufferedTimeRanges->start(i, ASSERT_NO_EXCEPTION);
+        float end = bufferedTimeRanges->end(i, ASSERT_NO_EXCEPTION);
+        if (isnan(start) || isnan(end) || start > currentTime || end < currentTime)
+            continue;
+        float startFraction = start / duration;
+        float endFraction = end / duration;
+        float widthFraction = endFraction - startFraction;
+        bufferedRect.move(startFraction * bufferedRect.width(), 0);
+        bufferedRect.setWidth(widthFraction * bufferedRect.width());
+
+        // Don't bother drawing an empty area.
+        if (bufferedRect.isEmpty())
+            return true;
+
         IntPoint sliderTopLeft = bufferedRect.location();
-        IntPoint sliderTopRight = sliderTopLeft;
-        sliderTopRight.move(0, bufferedRect.height());
+        IntPoint sliderBottomLeft = sliderTopLeft;
+        sliderBottomLeft.move(0, bufferedRect.height());
 
-        RefPtr<Gradient> gradient = Gradient::create(sliderTopLeft, sliderTopRight);
+        RefPtr<Gradient> gradient = Gradient::create(sliderTopLeft, sliderBottomLeft);
         Color startColor = object->style()->visitedDependentColor(CSSPropertyColor);
         gradient->addColorStop(0.0, startColor);
         gradient->addColorStop(1.0, Color(startColor.red() / 2, startColor.green() / 2, startColor.blue() / 2, startColor.alpha()));
@@ -167,6 +167,7 @@
         context->setFillGradient(gradient);
         context->fillRect(bufferedRect);
         context->restore();
+        return true;
     }
 
     return true;
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to