SVGEllipseElement.cpp [plain text]
#include "config.h"
#if SVG_SUPPORT
#include "Attr.h"
#include "SVGNames.h"
#include "SVGHelper.h"
#include "SVGEllipseElement.h"
#include "SVGAnimatedLength.h"
#include <kcanvas/KCanvasCreator.h>
namespace WebCore {
SVGEllipseElement::SVGEllipseElement(const QualifiedName& tagName, Document *doc)
: SVGStyledTransformableElement(tagName, doc), SVGTests(), SVGLangSpace(), SVGExternalResourcesRequired()
{
}
SVGEllipseElement::~SVGEllipseElement()
{
}
SVGAnimatedLength *SVGEllipseElement::cx() const
{
return lazy_create<SVGAnimatedLength>(m_cx, this, LM_WIDTH, viewportElement());
}
SVGAnimatedLength *SVGEllipseElement::cy() const
{
return lazy_create<SVGAnimatedLength>(m_cy, this, LM_HEIGHT, viewportElement());
}
SVGAnimatedLength *SVGEllipseElement::rx() const
{
return lazy_create<SVGAnimatedLength>(m_rx, this, LM_WIDTH, viewportElement());
}
SVGAnimatedLength *SVGEllipseElement::ry() const
{
return lazy_create<SVGAnimatedLength>(m_ry, this, LM_HEIGHT, viewportElement());
}
void SVGEllipseElement::parseMappedAttribute(MappedAttribute *attr)
{
const AtomicString& value = attr->value();
if (attr->name() == SVGNames::cxAttr)
cx()->baseVal()->setValueAsString(value.impl());
if (attr->name() == SVGNames::cyAttr)
cy()->baseVal()->setValueAsString(value.impl());
if (attr->name() == SVGNames::rxAttr)
rx()->baseVal()->setValueAsString(value.impl());
if (attr->name() == SVGNames::ryAttr)
ry()->baseVal()->setValueAsString(value.impl());
else
{
if(SVGTests::parseMappedAttribute(attr)) return;
if(SVGLangSpace::parseMappedAttribute(attr)) return;
if(SVGExternalResourcesRequired::parseMappedAttribute(attr)) return;
SVGStyledTransformableElement::parseMappedAttribute(attr);
}
}
KCanvasPath* SVGEllipseElement::toPathData() const
{
float _cx = cx()->baseVal()->value(), _cy = cy()->baseVal()->value();
float _rx = rx()->baseVal()->value(), _ry = ry()->baseVal()->value();
return KCanvasCreator::self()->createEllipse(_cx, _cy, _rx, _ry);
}
const SVGStyledElement *SVGEllipseElement::pushAttributeContext(const SVGStyledElement *context)
{
const SVGStyledElement *restore = cx()->baseVal()->context();
cx()->baseVal()->setContext(context);
cy()->baseVal()->setContext(context);
rx()->baseVal()->setContext(context);
ry()->baseVal()->setContext(context);
SVGStyledElement::pushAttributeContext(context);
return restore;
}
}
#endif // SVG_SUPPORT