SVGCursorElement.cpp [plain text]
#include "config.h"
#if SVG_SUPPORT
#include "SVGCursorElement.h"
#include "Attr.h"
#include "CachedImage.h"
#include "Document.h"
#include "DocLoader.h"
#include "SVGNames.h"
#include "SVGHelper.h"
#include "SVGAnimatedLength.h"
#include "SVGAnimatedString.h"
using namespace WebCore;
SVGCursorElement::SVGCursorElement(const QualifiedName& tagName, Document *doc)
: SVGElement(tagName, doc), SVGTests(), SVGExternalResourcesRequired(), SVGURIReference(), CachedResourceClient()
{
m_cachedImage = 0;
}
SVGCursorElement::~SVGCursorElement()
{
if (m_cachedImage)
m_cachedImage->deref(this);
}
SVGAnimatedLength *SVGCursorElement::x() const
{
return lazy_create<SVGAnimatedLength>(m_x, static_cast<const SVGStyledElement *>(0) , LM_WIDTH, viewportElement());
}
SVGAnimatedLength *SVGCursorElement::y() const
{
return lazy_create<SVGAnimatedLength>(m_y, static_cast<const SVGStyledElement *>(0) , LM_HEIGHT, viewportElement());
}
void SVGCursorElement::parseMappedAttribute(MappedAttribute *attr)
{
const AtomicString& value = attr->value();
if (attr->name() == SVGNames::xAttr)
x()->baseVal()->setValueAsString(value.impl());
else if (attr->name() == SVGNames::yAttr)
y()->baseVal()->setValueAsString(value.impl());
else
{
if(SVGTests::parseMappedAttribute(attr)) return;
if(SVGExternalResourcesRequired::parseMappedAttribute(attr)) return;
if (SVGURIReference::parseMappedAttribute(attr)) {
if (m_cachedImage)
m_cachedImage->deref(this);
m_cachedImage = ownerDocument()->docLoader()->requestImage(href()->baseVal());
if (m_cachedImage)
m_cachedImage->ref(this);
return;
}
SVGElement::parseMappedAttribute(attr);
}
}
#endif // SVG_SUPPORT