File indexing completed on 2024-04-28 11:39:08
0001 /* 0002 Copyright (C) 2004, 2005, 2007 Nikolas Zimmermann <zimmermann@kde.org> 0003 2004, 2005, 2006 Rob Buis <buis@kde.org> 0004 Copyright (C) 2008 Apple Computer, Inc. 0005 0006 This library is free software; you can redistribute it and/or 0007 modify it under the terms of the GNU Library General Public 0008 License as published by the Free Software Foundation; either 0009 version 2 of the License, or (at your option) any later version. 0010 0011 This library is distributed in the hope that it will be useful, 0012 but WITHOUT ANY WARRANTY; without even the implied warranty of 0013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0014 Library General Public License for more details. 0015 0016 You should have received a copy of the GNU Library General Public License 0017 along with this library; see the file COPYING.LIB. If not, write to 0018 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 0019 Boston, MA 02110-1301, USA. 0020 */ 0021 0022 #include "wtf/Platform.h" 0023 0024 #if ENABLE(SVG_FONTS) 0025 #include "SVGAltGlyphElement.h" 0026 0027 #include "ExceptionCode.h" 0028 #include "RenderInline.h" 0029 #include "RenderSVGTSpan.h" 0030 #include "SVGGlyphElement.h" 0031 #include "SVGNames.h" 0032 #include "XLinkNames.h" 0033 0034 #include "dom/dom_exception.h" 0035 0036 namespace WebCore 0037 { 0038 0039 SVGAltGlyphElement::SVGAltGlyphElement(const QualifiedName &tagName, Document *doc) 0040 : SVGTextPositioningElement(tagName, doc) 0041 { 0042 } 0043 0044 SVGAltGlyphElement::~SVGAltGlyphElement() 0045 { 0046 } 0047 0048 void SVGAltGlyphElement::setGlyphRef(const DOMString &type, ExceptionCode &ec) 0049 { 0050 Q_UNUSED(type); 0051 ec = DOMException::NO_MODIFICATION_ALLOWED_ERR; 0052 } 0053 0054 DOMString SVGAltGlyphElement::glyphRef() const 0055 { 0056 return getAttribute(SVGNames::glyphRefAttr); 0057 } 0058 0059 void SVGAltGlyphElement::setFormat(const DOMString &type, ExceptionCode &ec) 0060 { 0061 Q_UNUSED(type); 0062 ec = DOMException::NO_MODIFICATION_ALLOWED_ERR; 0063 } 0064 0065 DOMString SVGAltGlyphElement::format() const 0066 { 0067 return getAttribute(SVGNames::formatAttr); 0068 } 0069 0070 bool SVGAltGlyphElement::childShouldCreateRenderer(Node *child) const 0071 { 0072 if (child->isTextNode()) { 0073 return true; 0074 } 0075 return false; 0076 } 0077 0078 RenderObject *SVGAltGlyphElement::createRenderer(RenderArena *arena, RenderStyle *) 0079 { 0080 return new(arena) RenderSVGTSpan(this); 0081 } 0082 0083 SVGGlyphElement *SVGAltGlyphElement::glyphElement() const 0084 { 0085 Element *elt = document()->getElementById(getTarget(getAttribute(XLinkNames::hrefAttr))); 0086 if (!elt || !elt->hasTagName(SVGNames::glyphTag)) { 0087 return nullptr; 0088 } 0089 return static_cast<SVGGlyphElement *>(elt); 0090 } 0091 0092 } 0093 0094 #endif // ENABLE(SVG) 0095