bool RenderThemeChromiumWin::paintProgressBar(RenderObject* o, const PaintInfo& i, const IntRect& r) { if (!o->isProgress()) return true; RenderProgress* renderProgress = toRenderProgress(o); // For indeterminate bar, valueRect is ignored and it is computed by the theme engine // because the animation is a platform detail and WebKit doesn't need to know how. IntRect valueRect = renderProgress->isDeterminate() ? determinateProgressValueRectFor(renderProgress, r) : IntRect(0, 0, 0, 0); double animatedSeconds = renderProgress->animationStartTime() ? WTF::currentTime() - renderProgress->animationStartTime() : 0; ThemePainter painter(i.context, r); ChromiumBridge::paintProgressBar(painter.context(), r, valueRect, renderProgress->isDeterminate(), animatedSeconds); return false; }
IntRect RenderThemeGtk::calculateProgressRect(RenderObject* renderObject, const IntRect& fullBarRect) { IntRect progressRect(fullBarRect); RenderProgress* renderProgress = toRenderProgress(renderObject); if (renderProgress->isDeterminate()) { int progressWidth = progressRect.width() * renderProgress->position(); if (renderObject->style()->direction() == RTL) progressRect.setX(progressRect.x() + progressRect.width() - progressWidth); progressRect.setWidth(progressWidth); return progressRect; } double animationProgress = renderProgress->animationProgress(); // Never let the progress rect shrink smaller than 2 pixels. int newWidth = max(2, progressRect.width() / progressActivityBlocks); int movableWidth = progressRect.width() - newWidth; progressRect.setWidth(newWidth); // We want the first 0.5 units of the animation progress to represent the // forward motion and the second 0.5 units to represent the backward motion, // thus we multiply by two here to get the full sweep of the progress bar with // each direction. if (animationProgress < 0.5) progressRect.setX(progressRect.x() + (animationProgress * 2 * movableWidth)); else progressRect.setX(progressRect.x() + ((1.0 - animationProgress) * 2 * movableWidth)); return progressRect; }
void HTMLProgressElement::didElementStateChange() { m_value->setWidthPercentage(position() * 100); if (renderer() && renderer()->isProgress()) { RenderProgress* render = toRenderProgress(renderer()); bool wasDeterminate = render->isDeterminate(); renderer()->updateFromElement(); if (wasDeterminate != isDeterminate()) setNeedsStyleRecalc(); } }
bool RenderThemeNix::paintProgressBar(RenderObject* o, const PaintInfo& i, const IntRect& rect) { RenderProgress* renderProgress = toRenderProgress(o); WebKit::WebThemeEngine::ProgressBarExtraParams extraParams; extraParams.isDeterminate = renderProgress->isDeterminate(); extraParams.position = renderProgress->position(); extraParams.animationProgress = renderProgress->animationProgress(); extraParams.animationStartTime = renderProgress->animationStartTime(); themeEngine()->paintProgressBar(webCanvas(i), getWebThemeState(this, o), WebKit::WebRect(rect), extraParams); return false; }
bool RenderThemeChromiumWin::paintProgressBar(RenderObject* o, const PaintInfo& i, const IntRect& r) { if (!o->isProgress()) return true; RenderProgress* renderProgress = toRenderProgress(o); // For indeterminate bar, valueRect is ignored and it is computed by the theme engine // because the animation is a platform detail and WebKit doesn't need to know how. IntRect valueRect = renderProgress->isDeterminate() ? determinateProgressValueRectFor(renderProgress, r) : IntRect(0, 0, 0, 0); double animatedSeconds = renderProgress->animationStartTime() ? WTF::currentTime() - renderProgress->animationStartTime() : 0; ThemePainter painter(i.context, r); DirectionFlippingScope scope(o, i, r); WebKit::WebCanvas* canvas = painter.context()->platformContext()->canvas(); WebKit::Platform::current()->themeEngine()->paintProgressBar(canvas, WebKit::WebRect(r), WebKit::WebRect(valueRect), renderProgress->isDeterminate(), animatedSeconds); return false; }
bool RenderThemeChromiumLinux::paintProgressBar(RenderObject* o, const PaintInfo& i, const IntRect& rect) { if (!o->isProgress()) return true; RenderProgress* renderProgress = toRenderProgress(o); IntRect valueRect = progressValueRectFor(renderProgress, rect); PlatformSupport::ThemePaintExtraParams extraParams; extraParams.progressBar.determinate = renderProgress->isDeterminate(); extraParams.progressBar.valueRectX = valueRect.x(); extraParams.progressBar.valueRectY = valueRect.y(); extraParams.progressBar.valueRectWidth = valueRect.width(); extraParams.progressBar.valueRectHeight = valueRect.height(); PlatformSupport::paintThemePart(i.context, PlatformSupport::PartProgressBar, getWebThemeState(this, o), rect, &extraParams); return false; }
bool RenderThemeQtMobile::paintProgressBar(RenderObject* o, const PaintInfo& pi, const IntRect& r) { if (!o->isProgress()) return true; StylePainterMobile p(this, pi); if (!p.isValid()) return true; RenderProgress* renderProgress = toRenderProgress(o); const bool isRTL = (renderProgress->style()->direction() == RTL); if (renderProgress->isDeterminate()) p.drawProgress(r, renderProgress->position(), !isRTL); else p.drawProgress(r, renderProgress->animationProgress(), !isRTL, true); return false; }
bool RenderThemeChromiumDefault::paintProgressBar(RenderObject* o, const PaintInfo& i, const IntRect& rect) { if (!o->isProgress()) return true; RenderProgress* renderProgress = toRenderProgress(o); IntRect valueRect = progressValueRectFor(renderProgress, rect); WebKit::WebThemeEngine::ExtraParams extraParams; extraParams.progressBar.determinate = renderProgress->isDeterminate(); extraParams.progressBar.valueRectX = valueRect.x(); extraParams.progressBar.valueRectY = valueRect.y(); extraParams.progressBar.valueRectWidth = valueRect.width(); extraParams.progressBar.valueRectHeight = valueRect.height(); DirectionFlippingScope scope(o, i, rect); WebKit::WebCanvas* canvas = i.context->canvas(); WebKit::Platform::current()->themeEngine()->paint(canvas, WebKit::WebThemeEngine::PartProgressBar, getWebThemeState(this, o), WebKit::WebRect(rect), &extraParams); return false; }