コード例 #1
0
static void updatePathFromCircleElement(SVGElement* element, Path& path)
{
    ASSERT(isSVGCircleElement(element));
    SVGCircleElement* circle = toSVGCircleElement(element);

    SVGLengthContext lengthContext(element);
    float r = circle->r().value(lengthContext);
    if (r > 0)
        path.addEllipse(FloatRect(circle->cx().value(lengthContext) - r, circle->cy().value(lengthContext) - r, r * 2, r * 2));
}
コード例 #2
0
ファイル: SVGPathData.cpp プロジェクト: 3163504123/phantomjs
static void updatePathFromCircleElement(SVGElement* element, Path& path)
{
    ASSERT(element->hasTagName(SVGNames::circleTag));
    SVGCircleElement* circle = static_cast<SVGCircleElement*>(element);

    SVGLengthContext lengthContext(element);
    float r = circle->r().value(lengthContext);
    if (r > 0)
        path.addEllipse(FloatRect(circle->cx().value(lengthContext) - r, circle->cy().value(lengthContext) - r, r * 2, r * 2));
}
コード例 #3
0
static TextStream& operator<<(TextStream& ts, const RenderSVGShape& shape)
{
    writePositionAndStyle(ts, shape);

    ASSERT(shape.node()->isSVGElement());
    SVGElement* svgElement = toSVGElement(shape.node());
    SVGLengthContext lengthContext(svgElement);

    if (svgElement->hasTagName(SVGNames::rectTag)) {
        SVGRectElement* element = static_cast<SVGRectElement*>(svgElement);
        writeNameValuePair(ts, "x", element->x().value(lengthContext));
        writeNameValuePair(ts, "y", element->y().value(lengthContext));
        writeNameValuePair(ts, "width", element->width().value(lengthContext));
        writeNameValuePair(ts, "height", element->height().value(lengthContext));
    } else if (svgElement->hasTagName(SVGNames::lineTag)) {
        SVGLineElement* element = static_cast<SVGLineElement*>(svgElement);
        writeNameValuePair(ts, "x1", element->x1().value(lengthContext));
        writeNameValuePair(ts, "y1", element->y1().value(lengthContext));
        writeNameValuePair(ts, "x2", element->x2().value(lengthContext));
        writeNameValuePair(ts, "y2", element->y2().value(lengthContext));
    } else if (svgElement->hasTagName(SVGNames::ellipseTag)) {
        SVGEllipseElement* element = static_cast<SVGEllipseElement*>(svgElement);
        writeNameValuePair(ts, "cx", element->cx().value(lengthContext));
        writeNameValuePair(ts, "cy", element->cy().value(lengthContext));
        writeNameValuePair(ts, "rx", element->rx().value(lengthContext));
        writeNameValuePair(ts, "ry", element->ry().value(lengthContext));
    } else if (svgElement->hasTagName(SVGNames::circleTag)) {
        SVGCircleElement* element = static_cast<SVGCircleElement*>(svgElement);
        writeNameValuePair(ts, "cx", element->cx().value(lengthContext));
        writeNameValuePair(ts, "cy", element->cy().value(lengthContext));
        writeNameValuePair(ts, "r", element->r().value(lengthContext));
    } else if (svgElement->hasTagName(SVGNames::polygonTag) || svgElement->hasTagName(SVGNames::polylineTag)) {
        SVGPolyElement* element = static_cast<SVGPolyElement*>(svgElement);
        writeNameAndQuotedValue(ts, "points", element->pointList().valueAsString());
    } else if (svgElement->hasTagName(SVGNames::pathTag)) {
        SVGPathElement* element = toSVGPathElement(svgElement);
        String pathString;
        // FIXME: We should switch to UnalteredParsing here - this will affect the path dumping output of dozens of tests.
        buildStringFromByteStream(element->pathByteStream(), pathString, NormalizedParsing);
        writeNameAndQuotedValue(ts, "data", pathString);
    } else
        ASSERT_NOT_REACHED();
    return ts;
}
コード例 #4
0
void RenderSVGEllipse::calculateRadiiAndCenter()
{
    ASSERT(element());
    if (element()->hasTagName(SVGNames::circleTag)) {
        SVGCircleElement* circle = toSVGCircleElement(element());

        SVGLengthContext lengthContext(circle);
        float radius = circle->r()->currentValue()->value(lengthContext);
        m_radii = FloatSize(radius, radius);
        m_center = FloatPoint(circle->cx()->currentValue()->value(lengthContext), circle->cy()->currentValue()->value(lengthContext));
        return;
    }

    SVGEllipseElement* ellipse = toSVGEllipseElement(element());

    SVGLengthContext lengthContext(ellipse);
    m_radii = FloatSize(ellipse->rx()->currentValue()->value(lengthContext), ellipse->ry()->currentValue()->value(lengthContext));
    m_center = FloatPoint(ellipse->cx()->currentValue()->value(lengthContext), ellipse->cy()->currentValue()->value(lengthContext));
}
コード例 #5
0
void RenderSVGEllipse::calculateRadiiAndCenter()
{
    ASSERT(element());
    if (isSVGCircleElement(element())) {

        SVGCircleElement* circle = toSVGCircleElement(element());

        SVGLengthContext lengthContext(circle);
        float radius = circle->r().value(lengthContext);
        m_radii = FloatSize(radius, radius);
        m_center = FloatPoint(circle->cx().value(lengthContext), circle->cy().value(lengthContext));
        return;
    }

    ASSERT(isSVGEllipseElement(element()));
    SVGEllipseElement* ellipse = toSVGEllipseElement(element());

    SVGLengthContext lengthContext(ellipse);
    m_radii = FloatSize(ellipse->rx().value(lengthContext), ellipse->ry().value(lengthContext));
    m_center = FloatPoint(ellipse->cx().value(lengthContext), ellipse->cy().value(lengthContext));
}