コード例 #1
0
bool RenderThemeGtk::paintProgressBar(RenderObject* renderObject, const PaintInfo& paintInfo, const IntRect& rect)
{
    if (!renderObject->isProgress())
        return true;

    GtkWidget* progressBarWidget = moz_gtk_get_progress_widget();
    if (!progressBarWidget)
        return true;

    if (paintRenderObject(MOZ_GTK_PROGRESSBAR, renderObject, paintInfo.context, rect))
        return true;

    IntRect chunkRect(rect);
    RenderProgress* renderProgress = toRenderProgress(renderObject);

    GtkStyle* style = gtk_widget_get_style(progressBarWidget);
    chunkRect.setHeight(chunkRect.height() - (2 * style->ythickness));
    chunkRect.setY(chunkRect.y() + style->ythickness);
    chunkRect.setWidth((chunkRect.width() - (2 * style->xthickness)) * renderProgress->position());
    if (renderObject->style()->direction() == RTL)
        chunkRect.setX(rect.x() + rect.width() - chunkRect.width() - style->xthickness);
    else
        chunkRect.setX(chunkRect.x() + style->xthickness);

    return paintRenderObject(MOZ_GTK_PROGRESS_CHUNK, renderObject, paintInfo.context, chunkRect);
}
コード例 #2
0
ファイル: RenderThemeGtk.cpp プロジェクト: Wrichik1999/webkit
IntRect RenderThemeGtk::calculateProgressRect(const RenderObject& renderObject, const IntRect& fullBarRect)
{
    IntRect progressRect(fullBarRect);
    const 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 = std::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;
}
コード例 #3
0
bool RenderThemeChromiumSkia::paintProgressBar(RenderObject* renderObject, const RenderObject::PaintInfo& paintInfo, const IntRect& rect)
{
    static Image* barImage = Image::loadPlatformResource("linuxProgressBar").releaseRef();
    static Image* valueImage = Image::loadPlatformResource("linuxProgressValue").releaseRef();
    static Image* leftBorderImage = Image::loadPlatformResource("linuxProgressBorderLeft").releaseRef();
    static Image* rightBorderImage = Image::loadPlatformResource("linuxProgressBorderRight").releaseRef();
    ASSERT(barImage->height() == valueImage->height());

    if (!renderObject->isProgress())
        return true;

    paintInfo.context->platformContext()->setImageResamplingHint(barImage->size(), rect.size());

    RenderProgress* renderProgress = toRenderProgress(renderObject);
    double tileScale = static_cast<double>(rect.height()) / barImage->height();
    IntSize barTileSize(static_cast<int>(barImage->width() * tileScale), rect.height());
    ColorSpace colorSpace = renderObject->style()->colorSpace();

    paintInfo.context->drawTiledImage(barImage, colorSpace, rect, IntPoint(0, 0), barTileSize);

    IntRect valueRect = progressValueRectFor(renderProgress, rect);
    if (valueRect.width()) {

        IntSize valueTileSize(static_cast<int>(valueImage->width() * tileScale), valueRect.height());
        int leftOffset = valueRect.x() - rect.x();
        int roundedLeftOffset= (leftOffset / valueTileSize.width()) * valueTileSize.width();
        int dstLeftValueWidth = roundedLeftOffset - leftOffset + (leftOffset % valueImage->width()) ? valueTileSize.width() : 0;

        IntRect dstLeftValueRect(valueRect.x(), valueRect.y(), dstLeftValueWidth, valueRect.height());
        int srcLeftValueWidth = dstLeftValueWidth / tileScale;
        IntRect srcLeftValueRect(valueImage->width() - srcLeftValueWidth, 0, srcLeftValueWidth, valueImage->height());
        paintInfo.context->drawImage(valueImage, colorSpace, dstLeftValueRect, srcLeftValueRect);

        int rightOffset = valueRect.right() - rect.x();
        int roundedRightOffset = (rightOffset / valueTileSize.width()) * valueTileSize.width();
        int dstRightValueWidth = rightOffset - roundedRightOffset;
        IntRect dstRightValueRect(rect.x() + roundedRightOffset, valueRect.y(), dstRightValueWidth, valueTileSize.height());
        int srcRightValueWidth = dstRightValueWidth / tileScale;
        IntRect srcRightValueRect(0, 0, srcRightValueWidth, valueImage->height());
        paintInfo.context->drawImage(valueImage, colorSpace, dstRightValueRect, srcRightValueRect);
        
        IntRect alignedValueRect(dstLeftValueRect.right(), dstLeftValueRect.y(), 
                                 dstRightValueRect.x() - dstLeftValueRect.right(), dstLeftValueRect.height());
        paintInfo.context->drawTiledImage(valueImage, colorSpace, alignedValueRect, IntPoint(0, 0), valueTileSize);
    }

    int dstLeftBorderWidth = leftBorderImage->width() * tileScale;
    IntRect dstLeftBorderRect(rect.x(), rect.y(), dstLeftBorderWidth, rect.height());
    paintInfo.context->drawImage(leftBorderImage, colorSpace, dstLeftBorderRect, leftBorderImage->rect());

    int dstRightBorderWidth = rightBorderImage->width() * tileScale;
    IntRect dstRightBorderRect(rect.right() - dstRightBorderWidth, rect.y(), dstRightBorderWidth, rect.height());
    paintInfo.context->drawImage(rightBorderImage, colorSpace, dstRightBorderRect, rightBorderImage->rect());

    paintInfo.context->platformContext()->clearImageResamplingHint();

    return false;
}
コード例 #4
0
void HTMLProgressElement::didElementStateChange()
{
    m_value->setWidthPercentage(position() * 100);
    if (renderer()) {
        RenderProgress* render = toRenderProgress(renderer());
        bool wasDeterminate = render->isDeterminate();
        renderer()->updateFromElement();
        if (wasDeterminate != isDeterminate())
            setNeedsStyleRecalc();
    }
}
コード例 #5
0
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;
}
コード例 #6
0
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;
}
コード例 #7
0
bool RenderThemeAndroid::paintProgressBar(RenderObject* o, const PaintInfo& i, const IntRect& rect)
{
    if (!o->isProgress())
        return true;

    RenderProgress* renderProgress = toRenderProgress(o);
    IntRect valueRect = progressValueRectFor(renderProgress, rect);//progressRect;

    SkPaint paint;
    SkRect  dstRect;
    SkShader* m_shader = NULL;
    SkPoint pts[2];
    SkColor colors[3];
    SkScalar pos[] = { 0.0f, 0.5f, 1.0f};
    SkCanvas* const canvas = i.context->platformContext()->getCanvas();

    pts[0].fX = valueRect.x();
    pts[0].fY = valueRect.y();
    pts[1].fX = valueRect.x();
    pts[1].fY = valueRect.y() + valueRect.height();

    colors[0] = 0xFFC4EEA4;
    colors[1] = 0xFF3DC032;
    colors[2] = 0xFFC4EEA4;

    m_shader = SkGradientShader::CreateLinear(pts, colors, pos, 3, SkShader::kClamp_TileMode);

    // Paint the bar, the bar is valueRect
    dstRect.set(valueRect.x(), valueRect.y(), (valueRect.x() + valueRect.width()), (valueRect.y() + valueRect.height()));

    paint.setAntiAlias(true);
    paint.setFilterBitmap(true);
    paint.setShader(m_shader);
    canvas->drawRect(dstRect, paint);

    // Paint the border for progress bar, set the rect to complete progress bar rect
    dstRect.set(rect.x(), rect.y(), (rect.x() + rect.width()), (rect.y() + rect.height()));
    paint.setShader(NULL);
    paint.setColor(0x80000000);
    paint.setStyle(SkPaint::kStroke_Style);
    canvas->drawRect(dstRect, paint);

    if (m_shader)
    {
        m_shader->unref();
    }

    return false;
}
コード例 #8
0
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;
}
コード例 #9
0
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;
}
コード例 #10
0
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;
}
コード例 #11
0
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;
}