SVGFontFaceSrcElement.cpp [plain text]
#include "config.h"
#if ENABLE(SVG_FONTS)
#include "SVGFontFaceSrcElement.h"
#include "CSSFontFaceSrcValue.h"
#include "CSSValueList.h"
#include "ElementIterator.h"
#include "SVGFontFaceElement.h"
#include "SVGFontFaceNameElement.h"
#include "SVGFontFaceUriElement.h"
#include "SVGNames.h"
namespace WebCore {
using namespace SVGNames;
inline SVGFontFaceSrcElement::SVGFontFaceSrcElement(const QualifiedName& tagName, Document& document)
: SVGElement(tagName, document)
{
ASSERT(hasTagName(font_face_srcTag));
}
PassRefPtr<SVGFontFaceSrcElement> SVGFontFaceSrcElement::create(const QualifiedName& tagName, Document& document)
{
return adoptRef(new SVGFontFaceSrcElement(tagName, document));
}
PassRefPtr<CSSValueList> SVGFontFaceSrcElement::srcValue() const
{
RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
for (auto& child : childrenOfType<SVGElement>(*this)) {
RefPtr<CSSFontFaceSrcValue> srcValue;
if (isSVGFontFaceUriElement(child))
srcValue = toSVGFontFaceUriElement(child).srcValue();
else if (isSVGFontFaceNameElement(child))
srcValue = toSVGFontFaceNameElement(child).srcValue();
if (srcValue && srcValue->resource().length())
list->append(srcValue.release());
}
return list;
}
void SVGFontFaceSrcElement::childrenChanged(const ChildChange& change)
{
SVGElement::childrenChanged(change);
if (parentNode() && isSVGFontFaceElement(parentNode()))
toSVGFontFaceElement(parentNode())->rebuildFontFace();
}
}
#endif // ENABLE(SVG_FONTS)