bool RenderThemeQt::paintMediaSliderTrack(RenderObject* o, const PaintInfo& paintInfo, const IntRect& r)
{
    HTMLMediaElement* mediaElement = toParentMediaElement(o);
    if (!mediaElement)
        return false;

    StylePainter p(this, paintInfo);
    if (!p.isValid())
        return true;

    p.painter->setRenderHint(QPainter::Antialiasing, true);

    paintMediaBackground(p.painter, r);

    if (MediaPlayer* player = mediaElement->player()) {
        // Get the buffered parts of the media
        PassRefPtr<TimeRanges> buffered = player->buffered();
        if (buffered->length() > 0 && player->duration() < std::numeric_limits<float>::infinity()) {
            // Set the transform and brush
            WorldMatrixTransformer transformer(p.painter, o, r);
            p.painter->setBrush(getMediaControlForegroundColor());

            // Paint each buffered section
            ExceptionCode ex;
            for (int i = 0; i < buffered->length(); i++) {
                float startX = (buffered->start(i, ex) / player->duration()) * 100;
                float width = ((buffered->end(i, ex) / player->duration()) * 100) - startX;
                p.painter->drawRect(startX, 37, width, 26);
            }
        }
    }

    return false;
}
Example #2
0
void ScriptBreakpoint::sourceBreakpointsFromInspectorObject(PassRefPtr<InspectorObject> breakpoints, SourceBreakpoints* sourceBreakpoints)
{
    for (InspectorObject::iterator it = breakpoints->begin(); it != breakpoints->end(); ++it) {
        bool ok;
        int lineNumber = it->first.toInt(&ok);
        if (!ok)
            continue;
        RefPtr<InspectorObject> breakpoint = it->second->asObject();
        if (!breakpoint)
            continue;
        bool enabled;
        RefPtr<InspectorValue> enabledValue = breakpoint->get("enabled");
        if (!enabledValue || !enabledValue->asBoolean(&enabled))
            continue;
        String condition;
        RefPtr<InspectorValue> conditionValue = breakpoint->get("condition");
        if (!conditionValue || !conditionValue->asString(&condition))
            continue;
        sourceBreakpoints->set(lineNumber, ScriptBreakpoint(enabled, condition));
    }
}