diff options
author | Simon Hausmann <simon.hausmann@nokia.com> | 2012-05-27 21:51:42 +0200 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@nokia.com> | 2012-05-27 21:51:42 +0200 |
commit | be01689f43cf6882cf670d33df49ead1f570c53a (patch) | |
tree | 4bb2161d8983b38e3e7ed37b4a50303bfd5e2e85 /Source/WebCore/rendering/RenderMediaControlsChromium.cpp | |
parent | a89b2ebb8e192c5e8cea21079bda2ee2c0c7dddd (diff) | |
download | qtwebkit-be01689f43cf6882cf670d33df49ead1f570c53a.tar.gz |
Imported WebKit commit 8d6c5efc74f0222dfc7bcce8d845d4a2707ed9e6 (http://svn.webkit.org/repository/webkit/trunk@118629)
Diffstat (limited to 'Source/WebCore/rendering/RenderMediaControlsChromium.cpp')
-rw-r--r-- | Source/WebCore/rendering/RenderMediaControlsChromium.cpp | 49 |
1 files changed, 25 insertions, 24 deletions
diff --git a/Source/WebCore/rendering/RenderMediaControlsChromium.cpp b/Source/WebCore/rendering/RenderMediaControlsChromium.cpp index c28049c2b..72e12c881 100644 --- a/Source/WebCore/rendering/RenderMediaControlsChromium.cpp +++ b/Source/WebCore/rendering/RenderMediaControlsChromium.cpp @@ -127,37 +127,37 @@ static bool paintMediaSlider(RenderObject* object, const PaintInfo& paintInfo, c 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; + + 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; - // Don't bother drawing an empty area. - if (!bufferedRect.isEmpty()) { 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 @@ static bool paintMediaSlider(RenderObject* object, const PaintInfo& paintInfo, c context->setFillGradient(gradient); context->fillRect(bufferedRect); context->restore(); + return true; } return true; |