Example #1
0
void SVGRenderSupport::applyStrokeStyleToContext(GraphicsContext* context, const RenderStyle* style, const RenderObject* object)
{
    ASSERT(context);
    ASSERT(style);
    ASSERT(object);
    ASSERT(object->node());
    ASSERT(object->node()->isSVGElement());

    const SVGRenderStyle& svgStyle = style->svgStyle();

    SVGLengthContext lengthContext(toSVGElement(object->node()));
    context->setStrokeThickness(svgStyle.strokeWidth()->value(lengthContext));
    context->setLineCap(svgStyle.capStyle());
    context->setLineJoin(svgStyle.joinStyle());
    context->setMiterLimit(svgStyle.strokeMiterLimit());

    RefPtrWillBeRawPtr<SVGLengthList> dashes = svgStyle.strokeDashArray();
    if (dashes->isEmpty())
        return;

    DashArray dashArray;
    SVGLengthList::ConstIterator it = dashes->begin();
    SVGLengthList::ConstIterator itEnd = dashes->end();
    for (; it != itEnd; ++it)
        dashArray.append(it->value(lengthContext));

    context->setLineDash(dashArray, svgStyle.strokeDashOffset()->value(lengthContext));
}
Example #2
0
static void updatePathFromPolylineElement(SVGElement* element, Path& path)
{
    RefPtrWillBeRawPtr<SVGPointList> points = toSVGPolyElement(element)->points()->currentValue();
    if (points->isEmpty())
        return;

    SVGPointList::ConstIterator it = points->begin();
    SVGPointList::ConstIterator itEnd = points->end();
    ASSERT(it != itEnd);
    path.moveTo(it->value());
    ++it;

    for (; it != itEnd; ++it)
        path.addLineTo(it->value());
}