示例#1
0
KCanvasMarker *SVGMarkerElement::canvasResource()
{
    if(!m_marker)
        m_marker = static_cast<KCanvasMarker *>(renderingDevice()->createResource(RS_MARKER));
    
    m_marker->setMarker(renderer());

    // Spec: If the attribute is not specified, the effect is as if a
    // value of "0" were specified.
    if(!m_orientType)
    {
        SVGAngle *angle = SVGSVGElement::createSVGAngle();
        angle->setValueAsString(String("0").impl());
        setOrientToAngle(angle);
    }
    
    if(orientType()->baseVal() == SVG_MARKER_ORIENT_ANGLE)
        m_marker->setAngle(orientAngle()->baseVal()->value());
    else
        m_marker->setAutoAngle();

    m_marker->setRef(refX()->baseVal()->value(), refY()->baseVal()->value());
    
    m_marker->setUseStrokeWidth(markerUnits()->baseVal() == SVG_MARKERUNITS_STROKEWIDTH);
    double w = markerWidth()->baseVal()->value();
    double h = markerHeight()->baseVal()->value();
    RefPtr<SVGMatrix> viewBox = viewBoxToViewTransform(w, h);
    m_marker->setScale(viewBox->matrix().m11(), viewBox->matrix().m22());
    
    return m_marker;
}
示例#2
0
void SVGMarkerElement::parseMappedAttribute(MappedAttribute *attr)
{
    const AtomicString& value = attr->value();
    if (attr->name() == SVGNames::markerUnitsAttr) {
        if (value == "userSpaceOnUse")
            markerUnits()->setBaseVal(SVG_MARKERUNITS_USERSPACEONUSE);
    }
    else if (attr->name() == SVGNames::refXAttr)
        refX()->baseVal()->setValueAsString(value.impl());
    else if (attr->name() == SVGNames::refYAttr)
        refY()->baseVal()->setValueAsString(value.impl());
    else if (attr->name() == SVGNames::markerWidthAttr)
        markerWidth()->baseVal()->setValueAsString(value.impl());
    else if (attr->name() == SVGNames::markerHeightAttr)
        markerHeight()->baseVal()->setValueAsString(value.impl());
    else if (attr->name() == SVGNames::orientAttr)
    {
        if (value == "auto")
            setOrientToAuto();
        else {
            SVGAngle *angle = SVGSVGElement::createSVGAngle();
            angle->setValueAsString(value.impl());
            setOrientToAngle(angle);
        }
    }
    else
    {
        if(SVGLangSpace::parseMappedAttribute(attr)) return;
        if(SVGExternalResourcesRequired::parseMappedAttribute(attr)) return;
        if(SVGFitToViewBox::parseMappedAttribute(attr)) return;

        SVGStyledElement::parseMappedAttribute(attr);
    }
}
示例#3
0
bool SVGMarkerElement::selfHasRelativeLengths() const
{
    return refX().isRelative()
           || refY().isRelative()
           || markerWidth().isRelative()
           || markerHeight().isRelative();
}