⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 118577 in webkit


Ignore:
Timestamp:
May 25, 2012, 3:30:56 PM (14 years ago)
Author:
fischman@chromium.org
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):

Location:
trunk
Files:
3 added
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r118572 r118577  
     12012-05-25  Ami Fischman  <fischman@chromium.org>
     2
     3        [chromium] Default media controls should render only the currentTime-containing buffered range
     4        https://bugs.webkit.org/show_bug.cgi?id=85925
     5
     6        Reviewed by Eric Carlson.
     7
     8        Test: http/tests/media/video-buffered-range-contains-currentTime.html
     9
     10        * rendering/RenderMediaControlsChromium.cpp:
     11        (WebCore::paintMediaSlider):
     12
    1132012-05-25  Simon Fraser  <simon.fraser@apple.com>
    214
  • trunk/Source/WebCore/rendering/RenderMediaControlsChromium.cpp

    r116539 r118577  
    128128    context->restore();
    129129
    130     // Draw the buffered ranges.
    131     // FIXME: Draw multiple ranges if there are multiple buffered ranges. http://webkit.org/b/85925
     130    // Draw the buffered range. Since the element may have multiple buffered ranges and it'd be
     131    // distracting/'busy' to show all of them, show only the buffered range containing the current play head.
    132132    IntRect bufferedRect = rect;
    133133    bufferedRect.inflate(-style->borderLeftWidth());
    134134
    135     double bufferedWidth = 0.0;
    136135    RefPtr<TimeRanges> bufferedTimeRanges = mediaElement->buffered();
    137     if (bufferedTimeRanges->length() > 0) {
    138         // Account for the width of the slider thumb.
    139         Image* mediaSliderThumb = getMediaSliderThumb();
    140         double thumbWidth = mediaSliderThumb->width() / 2.0 + 1.0;
    141         double rectWidth = bufferedRect.width() - thumbWidth;
    142         if (rectWidth < 0.0)
    143             rectWidth = 0.0;
    144         // Preserve old behavior pending resolution of UI design of multiple ranges (see FIXME above).
    145         // http://webkit.org/b/85926
    146         double fakePercentLoaded = 0;
    147         float duration = mediaElement->duration();
    148         if (duration && !isinf(duration))
    149             fakePercentLoaded = bufferedTimeRanges->end(bufferedTimeRanges->length() - 1, ASSERT_NO_EXCEPTION) / duration;
    150         bufferedWidth = rectWidth * fakePercentLoaded + thumbWidth;
    151     }
    152     bufferedRect.setWidth(bufferedWidth);
    153 
    154     // Don't bother drawing an empty area.
    155     if (!bufferedRect.isEmpty()) {
     136    float duration = mediaElement->duration();
     137    float currentTime = mediaElement->currentTime();
     138    if (isnan(duration) || isinf(duration) || !duration || isnan(currentTime))
     139        return true;
     140
     141    for (unsigned i = 0; i < bufferedTimeRanges->length(); ++i) {
     142        float start = bufferedTimeRanges->start(i, ASSERT_NO_EXCEPTION);
     143        float end = bufferedTimeRanges->end(i, ASSERT_NO_EXCEPTION);
     144        if (isnan(start) || isnan(end) || start > currentTime || end < currentTime)
     145            continue;
     146        float startFraction = start / duration;
     147        float endFraction = end / duration;
     148        float widthFraction = endFraction - startFraction;
     149        bufferedRect.move(startFraction * bufferedRect.width(), 0);
     150        bufferedRect.setWidth(widthFraction * bufferedRect.width());
     151
     152        // Don't bother drawing an empty area.
     153        if (bufferedRect.isEmpty())
     154            return true;
     155
    156156        IntPoint sliderTopLeft = bufferedRect.location();
    157         IntPoint sliderTopRight = sliderTopLeft;
    158         sliderTopRight.move(0, bufferedRect.height());
    159 
    160         RefPtr<Gradient> gradient = Gradient::create(sliderTopLeft, sliderTopRight);
     157        IntPoint sliderBottomLeft = sliderTopLeft;
     158        sliderBottomLeft.move(0, bufferedRect.height());
     159
     160        RefPtr<Gradient> gradient = Gradient::create(sliderTopLeft, sliderBottomLeft);
    161161        Color startColor = object->style()->visitedDependentColor(CSSPropertyColor);
    162162        gradient->addColorStop(0.0, startColor);
     
    168168        context->fillRect(bufferedRect);
    169169        context->restore();
     170        return true;
    170171    }
    171172
Note: See TracChangeset for help on using the changeset viewer.