1/* 2 * Copyright (C) 2007 Eric Seidel <eric@webkit.org> 3 * 4 * This library is free software; you can redistribute it and/or 5 * modify it under the terms of the GNU Library General Public 6 * License as published by the Free Software Foundation; either 7 * version 2 of the License, or (at your option) any later version. 8 * 9 * This library is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 * Library General Public License for more details. 13 * 14 * You should have received a copy of the GNU Library General Public License 15 * along with this library; see the file COPYING.LIB. If not, write to 16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 * Boston, MA 02110-1301, USA. 18 */ 19 20#include "config.h" 21 22#if ENABLE(SVG_FONTS) 23#include "SVGFontFaceSrcElement.h" 24 25#include "CSSFontFaceSrcValue.h" 26#include "CSSValueList.h" 27#include "ElementIterator.h" 28#include "SVGFontFaceElement.h" 29#include "SVGFontFaceNameElement.h" 30#include "SVGFontFaceUriElement.h" 31#include "SVGNames.h" 32 33namespace WebCore { 34 35using namespace SVGNames; 36 37inline SVGFontFaceSrcElement::SVGFontFaceSrcElement(const QualifiedName& tagName, Document& document) 38 : SVGElement(tagName, document) 39{ 40 ASSERT(hasTagName(font_face_srcTag)); 41} 42 43PassRefPtr<SVGFontFaceSrcElement> SVGFontFaceSrcElement::create(const QualifiedName& tagName, Document& document) 44{ 45 return adoptRef(new SVGFontFaceSrcElement(tagName, document)); 46} 47 48PassRefPtr<CSSValueList> SVGFontFaceSrcElement::srcValue() const 49{ 50 RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated(); 51 for (auto& child : childrenOfType<SVGElement>(*this)) { 52 RefPtr<CSSFontFaceSrcValue> srcValue; 53 if (isSVGFontFaceUriElement(child)) 54 srcValue = toSVGFontFaceUriElement(child).srcValue(); 55 else if (isSVGFontFaceNameElement(child)) 56 srcValue = toSVGFontFaceNameElement(child).srcValue(); 57 if (srcValue && srcValue->resource().length()) 58 list->append(srcValue.release()); 59 } 60 return list; 61} 62 63void SVGFontFaceSrcElement::childrenChanged(const ChildChange& change) 64{ 65 SVGElement::childrenChanged(change); 66 if (parentNode() && isSVGFontFaceElement(parentNode())) 67 toSVGFontFaceElement(parentNode())->rebuildFontFace(); 68} 69 70} 71 72#endif // ENABLE(SVG_FONTS) 73