static bool paintMediaSlider(RenderObject* object, const PaintInfo& paintInfo, const IntRect& rect) { HTMLMediaElement* mediaElement = toParentMediaElement(object); if (!mediaElement) return false; RenderStyle* style = object->style(); GraphicsContext* context = paintInfo.context; // Draw the border of the time bar. // FIXME: this should be a rounded rect but need to fix GraphicsContextSkia first. // https://bugs.webkit.org/show_bug.cgi?id=30143 context->save(); context->setShouldAntialias(true); context->setStrokeStyle(SolidStroke); context->setStrokeColor(style->visitedDependentColor(CSSPropertyBorderLeftColor), ColorSpaceDeviceRGB); context->setStrokeThickness(style->borderLeftWidth()); context->setFillColor(style->visitedDependentColor(CSSPropertyBackgroundColor), ColorSpaceDeviceRGB); context->drawRect(rect); context->restore(); // Draw the buffered ranges. // FIXME: Draw multiple ranges if there are multiple buffered ranges. IntRect bufferedRect = rect; bufferedRect.inflate(-style->borderLeftWidth()); double bufferedWidth = 0.0; if (mediaElement->percentLoaded() > 0.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; bufferedWidth = rectWidth * mediaElement->percentLoaded() + thumbWidth; } bufferedRect.setWidth(bufferedWidth); // Don't bother drawing an empty area. if (!bufferedRect.isEmpty()) { IntPoint sliderTopLeft = bufferedRect.location(); IntPoint sliderTopRight = sliderTopLeft; sliderTopRight.move(0, bufferedRect.height()); RefPtr<Gradient> gradient = Gradient::create(sliderTopLeft, sliderTopRight); 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())); context->save(); context->setStrokeStyle(NoStroke); context->setFillGradient(gradient); context->fillRect(bufferedRect); context->restore(); } return true; }
static bool paintMediaSliderThumb(RenderObject* object, const PaintInfo& paintInfo, const IntRect& rect) { ASSERT(object->node()); HTMLMediaElement* mediaElement = toParentMediaElement(object->node()->shadowHost()); if (!mediaElement) return false; if (!hasSource(mediaElement)) return true; Image* mediaSliderThumb = getMediaSliderThumb(); return paintMediaButton(paintInfo.context, rect, mediaSliderThumb); }
bool MediaControlsPainter::paintMediaSliderThumb(const LayoutObject& object, const PaintInfo& paintInfo, const IntRect& rect) { if (!object.node()) return false; const HTMLMediaElement* mediaElement = toParentMediaElement(object.node()->shadowHost()); if (!mediaElement) return false; if (!hasSource(mediaElement)) return true; Image* mediaSliderThumb = getMediaSliderThumb(); IntRect paintRect; const ComputedStyle& style = object.styleRef(); adjustMediaSliderThumbPaintSize(rect, style, paintRect); return paintMediaButton(paintInfo.context, paintRect, mediaSliderThumb); }