KHTML
SVGTextPathElement.cpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include "config.h"
00023 #include "wtf/Platform.h"
00024
00025 #if ENABLE(SVG)
00026 #include "SVGTextPathElement.h"
00027
00028 #include "AffineTransform.h"
00029 #include "FloatRect.h"
00030 #include "RenderSVGTextPath.h"
00031 #include "SVGLengthList.h"
00032 #include "SVGPathElement.h"
00033 #include "SVGRenderStyle.h"
00034 #include "SVGTextPathElement.h"
00035 #include "SVGTransformList.h"
00036
00037 namespace WebCore {
00038
00039 SVGTextPathElement::SVGTextPathElement(const QualifiedName& tagName, Document* doc)
00040 : SVGTextContentElement(tagName, doc)
00041 , SVGURIReference()
00042 , m_startOffset(this, LengthModeOther)
00043 , m_method(SVG_TEXTPATH_METHODTYPE_ALIGN)
00044 , m_spacing(SVG_TEXTPATH_SPACINGTYPE_EXACT)
00045 {
00046 }
00047
00048 SVGTextPathElement::~SVGTextPathElement()
00049 {
00050 }
00051
00052 ANIMATED_PROPERTY_DEFINITIONS(SVGTextPathElement, SVGLength, Length, length, StartOffset, startOffset, SVGNames::startOffsetAttr, m_startOffset)
00053 ANIMATED_PROPERTY_DEFINITIONS(SVGTextPathElement, int, Enumeration, enumeration, Method, method, SVGNames::methodAttr, m_method)
00054 ANIMATED_PROPERTY_DEFINITIONS(SVGTextPathElement, int, Enumeration, enumeration, Spacing, spacing, SVGNames::spacingAttr, m_spacing)
00055
00056 void SVGTextPathElement::parseMappedAttribute(MappedAttribute* attr)
00057 {
00058 const String& value = attr->value();
00059
00060 if (attr->name() == SVGNames::startOffsetAttr)
00061 setStartOffsetBaseValue(SVGLength(this, LengthModeOther, value));
00062 else if (attr->name() == SVGNames::methodAttr) {
00063 if (value == "align")
00064 setSpacingBaseValue(SVG_TEXTPATH_METHODTYPE_ALIGN);
00065 else if(value == "stretch")
00066 setSpacingBaseValue(SVG_TEXTPATH_METHODTYPE_STRETCH);
00067 } else if (attr->name() == SVGNames::spacingAttr) {
00068 if (value == "auto")
00069 setMethodBaseValue(SVG_TEXTPATH_SPACINGTYPE_AUTO);
00070 else if (value == "exact")
00071 setMethodBaseValue(SVG_TEXTPATH_SPACINGTYPE_EXACT);
00072 } else {
00073 if (SVGURIReference::parseMappedAttribute(attr))
00074 return;
00075 SVGTextContentElement::parseMappedAttribute(attr);
00076 }
00077 }
00078
00079 RenderObject* SVGTextPathElement::createRenderer(RenderArena* arena, RenderStyle* style)
00080 {
00081 return new (arena) RenderSVGTextPath(this);
00082 }
00083
00084 bool SVGTextPathElement::childShouldCreateRenderer(Node* child) const
00085 {
00086 if (child->isTextNode()
00087 #if ENABLE(SVG_FONTS)
00088 || child->hasTagName(SVGNames::altGlyphTag)
00089 #endif
00090 || child->hasTagName(SVGNames::trefTag) || child->hasTagName(SVGNames::tspanTag) || child->hasTagName(SVGNames::textPathTag))
00091 return true;
00092
00093 return false;
00094 }
00095
00096 void SVGTextPathElement::insertedIntoDocument()
00097 {
00098 SVGElement::insertedIntoDocument();
00099
00100 String id = SVGURIReference::getTarget(href());
00101 Element* targetElement = ownerDocument()->getElementById(id);
00102 if (!targetElement) {
00103 document()->accessSVGExtensions()->addPendingResource(id, this);
00104 return;
00105 }
00106 }
00107
00108 }
00109
00110 #endif // ENABLE(SVG)
00111
00112