SVGGlyphRefElement.cpp [plain text]
#include "config.h"
#if ENABLE(SVG_FONTS)
#include "SVGGlyphRefElement.h"
#include "SVGGlyphElement.h"
#include "SVGNames.h"
#include "SVGParserUtilities.h"
#include "XLinkNames.h"
#include <wtf/text/AtomicString.h>
namespace WebCore {
DEFINE_ANIMATED_STRING(SVGGlyphRefElement, XLinkNames::hrefAttr, Href, href)
BEGIN_REGISTER_ANIMATED_PROPERTIES(SVGGlyphRefElement)
REGISTER_LOCAL_ANIMATED_PROPERTY(href)
REGISTER_PARENT_ANIMATED_PROPERTIES(SVGElement)
END_REGISTER_ANIMATED_PROPERTIES
inline SVGGlyphRefElement::SVGGlyphRefElement(const QualifiedName& tagName, Document& document)
: SVGElement(tagName, document)
{
ASSERT(hasTagName(SVGNames::glyphRefTag));
registerAnimatedPropertiesForSVGGlyphRefElement();
}
Ref<SVGGlyphRefElement> SVGGlyphRefElement::create(const QualifiedName& tagName, Document& document)
{
return adoptRef(*new SVGGlyphRefElement(tagName, document));
}
bool SVGGlyphRefElement::hasValidGlyphElement(String& glyphName) const
{
return is<SVGGlyphElement>(targetElementFromIRIString(getAttribute(XLinkNames::hrefAttr), document(), &glyphName));
}
static float parseFloat(const AtomicString& value)
{
float result;
if (!parseNumberFromString(value, result))
return 0;
return result;
}
void SVGGlyphRefElement::parseAttribute(const QualifiedName& name, const AtomicString& value)
{
if (name == SVGNames::xAttr)
m_x = parseFloat(value);
else if (name == SVGNames::yAttr)
m_y = parseFloat(value);
else if (name == SVGNames::dxAttr)
m_dx = parseFloat(value);
else if (name == SVGNames::dyAttr)
m_dy = parseFloat(value);
else {
SVGURIReference::parseAttribute(name, value);
SVGElement::parseAttribute(name, value);
}
}
void SVGGlyphRefElement::setX(float x)
{
setAttribute(SVGNames::xAttr, AtomicString::number(x));
}
void SVGGlyphRefElement::setY(float y)
{
setAttribute(SVGNames::yAttr, AtomicString::number(y));
}
void SVGGlyphRefElement::setDx(float dx)
{
setAttribute(SVGNames::dxAttr, AtomicString::number(dx));
}
void SVGGlyphRefElement::setDy(float dy)
{
setAttribute(SVGNames::dyAttr, AtomicString::number(dy));
}
}
#endif