summaryrefslogtreecommitdiff
path: root/Source/WebCore/svg/SVGGlyphRefElement.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Source/WebCore/svg/SVGGlyphRefElement.cpp')
-rw-r--r--Source/WebCore/svg/SVGGlyphRefElement.cpp74
1 files changed, 26 insertions, 48 deletions
diff --git a/Source/WebCore/svg/SVGGlyphRefElement.cpp b/Source/WebCore/svg/SVGGlyphRefElement.cpp
index 9b27eaef4..c3ffaa565 100644
--- a/Source/WebCore/svg/SVGGlyphRefElement.cpp
+++ b/Source/WebCore/svg/SVGGlyphRefElement.cpp
@@ -19,7 +19,7 @@
#include "config.h"
-#if ENABLE(SVG) && ENABLE(SVG_FONTS)
+#if ENABLE(SVG_FONTS)
#include "SVGGlyphRefElement.h"
#include "SVGGlyphElement.h"
@@ -40,88 +40,66 @@ 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();
}
-PassRefPtr<SVGGlyphRefElement> SVGGlyphRefElement::create(const QualifiedName& tagName, Document& document)
+Ref<SVGGlyphRefElement> SVGGlyphRefElement::create(const QualifiedName& tagName, Document& document)
{
- return adoptRef(new SVGGlyphRefElement(tagName, document));
+ return adoptRef(*new SVGGlyphRefElement(tagName, document));
}
bool SVGGlyphRefElement::hasValidGlyphElement(String& glyphName) const
{
// FIXME: We only support xlink:href so far.
// https://bugs.webkit.org/show_bug.cgi?id=64787
- Element* element = targetElementFromIRIString(getAttribute(XLinkNames::hrefAttr), document(), &glyphName);
- if (!element || !element->hasTagName(SVGNames::glyphTag))
- return false;
- return true;
+ return is<SVGGlyphElement>(targetElementFromIRIString(getAttribute(XLinkNames::hrefAttr), document(), &glyphName));
}
-void SVGGlyphRefElement::parseAttribute(const QualifiedName& name, const AtomicString& value)
+static float parseFloat(const AtomicString& value)
{
- const UChar* startPtr = value.string().deprecatedCharacters();
- const UChar* endPtr = startPtr + value.length();
+ float result;
+ if (!parseNumberFromString(value, result))
+ return 0;
+ return result;
+}
- // FIXME: We need some error handling here.
+void SVGGlyphRefElement::parseAttribute(const QualifiedName& name, const AtomicString& value)
+{
+ // FIXME: Is the error handling in parseFloat correct for these attributes?
if (name == SVGNames::xAttr)
- parseNumber(startPtr, endPtr, m_x);
+ m_x = parseFloat(value);
else if (name == SVGNames::yAttr)
- parseNumber(startPtr, endPtr, m_y);
+ m_y = parseFloat(value);
else if (name == SVGNames::dxAttr)
- parseNumber(startPtr, endPtr, m_dx);
+ m_dx = parseFloat(value);
else if (name == SVGNames::dyAttr)
- parseNumber(startPtr, endPtr, m_dy);
+ m_dy = parseFloat(value);
else {
- if (SVGURIReference::parseAttribute(name, value))
- return;
+ SVGURIReference::parseAttribute(name, value);
SVGElement::parseAttribute(name, value);
}
}
-const AtomicString& SVGGlyphRefElement::glyphRef() const
+void SVGGlyphRefElement::setX(float x)
{
- return fastGetAttribute(SVGNames::glyphRefAttr);
+ setAttribute(SVGNames::xAttr, AtomicString::number(x));
}
-void SVGGlyphRefElement::setGlyphRef(const AtomicString&, ExceptionCode&)
+void SVGGlyphRefElement::setY(float y)
{
- // FIXME: Set and honor attribute change.
- // https://bugs.webkit.org/show_bug.cgi?id=64787
+ setAttribute(SVGNames::yAttr, AtomicString::number(y));
}
-void SVGGlyphRefElement::setX(float x, ExceptionCode&)
+void SVGGlyphRefElement::setDx(float dx)
{
- // FIXME: Honor attribute change.
- // https://bugs.webkit.org/show_bug.cgi?id=64787
- m_x = x;
+ setAttribute(SVGNames::dxAttr, AtomicString::number(dx));
}
-void SVGGlyphRefElement::setY(float y , ExceptionCode&)
+void SVGGlyphRefElement::setDy(float dy)
{
- // FIXME: Honor attribute change.
- // https://bugs.webkit.org/show_bug.cgi?id=64787
- m_y = y;
-}
-
-void SVGGlyphRefElement::setDx(float dx, ExceptionCode&)
-{
- // FIXME: Honor attribute change.
- // https://bugs.webkit.org/show_bug.cgi?id=64787
- m_dx = dx;
-}
-
-void SVGGlyphRefElement::setDy(float dy, ExceptionCode&)
-{
- // FIXME: Honor attribute change.
- // https://bugs.webkit.org/show_bug.cgi?id=64787
- m_dy = dy;
+ setAttribute(SVGNames::dyAttr, AtomicString::number(dy));
}
}