SVGAltGlyphElement.cpp [plain text]
#include "config.h"
#include "SVGAltGlyphElement.h"
#if ENABLE(SVG_FONTS)
#include "RenderInline.h"
#include "RenderSVGTSpan.h"
#include "SVGAltGlyphDefElement.h"
#include "SVGGlyphElement.h"
#include "SVGNames.h"
#include "XLinkNames.h"
namespace WebCore {
DEFINE_ANIMATED_STRING(SVGAltGlyphElement, XLinkNames::hrefAttr, Href, href)
BEGIN_REGISTER_ANIMATED_PROPERTIES(SVGAltGlyphElement)
REGISTER_LOCAL_ANIMATED_PROPERTY(href)
REGISTER_PARENT_ANIMATED_PROPERTIES(SVGTextPositioningElement)
END_REGISTER_ANIMATED_PROPERTIES
inline SVGAltGlyphElement::SVGAltGlyphElement(const QualifiedName& tagName, Document& document)
: SVGTextPositioningElement(tagName, document)
{
ASSERT(hasTagName(SVGNames::altGlyphTag));
registerAnimatedPropertiesForSVGAltGlyphElement();
}
Ref<SVGAltGlyphElement> SVGAltGlyphElement::create(const QualifiedName& tagName, Document& document)
{
return adoptRef(*new SVGAltGlyphElement(tagName, document));
}
ExceptionOr<void> SVGAltGlyphElement::setGlyphRef(const AtomicString&)
{
return Exception { NoModificationAllowedError };
}
const AtomicString& SVGAltGlyphElement::glyphRef() const
{
return attributeWithoutSynchronization(SVGNames::glyphRefAttr);
}
ExceptionOr<void> SVGAltGlyphElement::setFormat(const AtomicString&)
{
return Exception { NoModificationAllowedError };
}
const AtomicString& SVGAltGlyphElement::format() const
{
return attributeWithoutSynchronization(SVGNames::formatAttr);
}
bool SVGAltGlyphElement::childShouldCreateRenderer(const Node& child) const
{
return child.isTextNode();
}
RenderPtr<RenderElement> SVGAltGlyphElement::createElementRenderer(RenderStyle&& style, const RenderTreePosition&)
{
return createRenderer<RenderSVGTSpan>(*this, WTFMove(style));
}
bool SVGAltGlyphElement::hasValidGlyphElements(Vector<String>& glyphNames) const
{
String target;
auto element = makeRefPtr(targetElementFromIRIString(getAttribute(XLinkNames::hrefAttr), document(), &target));
if (is<SVGGlyphElement>(element)) {
glyphNames.append(target);
return true;
}
if (is<SVGAltGlyphDefElement>(element) && downcast<SVGAltGlyphDefElement>(*element).hasValidGlyphElements(glyphNames))
return true;
return false;
}
}
#endif