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>
#include <wtf/text/StringView.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)
, m_x(0)
, m_y(0)
, m_dx(0)
, m_dy(0)
{
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));
}
void SVGGlyphRefElement::parseAttribute(const QualifiedName& name, const AtomicString& value)
{
auto upconvertedCharacters = StringView(value.string()).upconvertedCharacters();
const UChar* startPtr = upconvertedCharacters;
const UChar* endPtr = startPtr + value.length();
if (name == SVGNames::xAttr)
parseNumber(startPtr, endPtr, m_x);
else if (name == SVGNames::yAttr)
parseNumber(startPtr, endPtr, m_y);
else if (name == SVGNames::dxAttr)
parseNumber(startPtr, endPtr, m_dx);
else if (name == SVGNames::dyAttr)
parseNumber(startPtr, endPtr, m_dy);
else {
SVGURIReference::parseAttribute(name, value);
SVGElement::parseAttribute(name, value);
}
}
const AtomicString& SVGGlyphRefElement::glyphRef() const
{
return attributeWithoutSynchronization(SVGNames::glyphRefAttr);
}
void SVGGlyphRefElement::setGlyphRef(const AtomicString&, ExceptionCode&)
{
}
void SVGGlyphRefElement::setX(float x, ExceptionCode&)
{
m_x = x;
}
void SVGGlyphRefElement::setY(float y , ExceptionCode&)
{
m_y = y;
}
void SVGGlyphRefElement::setDx(float dx, ExceptionCode&)
{
m_dx = dx;
}
void SVGGlyphRefElement::setDy(float dy, ExceptionCode&)
{
m_dy = dy;
}
}
#endif