KHTML
SVGTextElement.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
00023 #include "config.h"
00024 #include "wtf/Platform.h"
00025
00026 #if ENABLE(SVG)
00027 #include "SVGTextElement.h"
00028
00029 #include "AffineTransform.h"
00030 #include "FloatRect.h"
00031 #include "RenderSVGText.h"
00032 #include "SVGLengthList.h"
00033 #include "SVGRenderStyle.h"
00034 #include "SVGTSpanElement.h"
00035 #include "SVGTransformList.h"
00036
00037 namespace WebCore {
00038
00039 SVGTextElement::SVGTextElement(const QualifiedName& tagName, Document* doc)
00040 : SVGTextPositioningElement(tagName, doc)
00041 , SVGTransformable()
00042 , m_transform(SVGTransformList::create(SVGNames::transformAttr))
00043 {
00044 }
00045
00046 SVGTextElement::~SVGTextElement()
00047 {
00048 }
00049
00050 ANIMATED_PROPERTY_DEFINITIONS(SVGTextElement, SVGTransformList*, TransformList, transformList, Transform, transform, SVGNames::transformAttr, m_transform.get())
00051
00052 void SVGTextElement::parseMappedAttribute(MappedAttribute* attr)
00053 {
00054 if (attr->name() == SVGNames::transformAttr) {
00055 SVGTransformList* localTransforms = transformBaseValue();
00056
00057 ExceptionCode ec = 0;
00058 localTransforms->clear(ec);
00059
00060 if (!SVGTransformable::parseTransformAttribute(localTransforms, attr->value()))
00061 localTransforms->clear(ec);
00062 else {
00063 setTransformBaseValue(localTransforms);
00064 if (renderer())
00065 renderer()->setNeedsLayout(true);
00066 }
00067 } else
00068 SVGTextPositioningElement::parseMappedAttribute(attr);
00069 }
00070
00071 SVGElement* SVGTextElement::nearestViewportElement() const
00072 {
00073 return SVGTransformable::nearestViewportElement(this);
00074 }
00075
00076 SVGElement* SVGTextElement::farthestViewportElement() const
00077 {
00078 return SVGTransformable::farthestViewportElement(this);
00079 }
00080
00081 FloatRect SVGTextElement::getBBox() const
00082 {
00083 return SVGTransformable::getBBox(this);
00084 }
00085
00086 AffineTransform SVGTextElement::getScreenCTM() const
00087 {
00088 return SVGTransformable::getScreenCTM(this);
00089 }
00090
00091 AffineTransform SVGTextElement::getCTM() const
00092 {
00093 return SVGTransformable::getCTM(this);
00094 }
00095
00096 AffineTransform SVGTextElement::animatedLocalTransform() const
00097 {
00098 return m_supplementalTransform ? transform()->concatenate().matrix() * *m_supplementalTransform : transform()->concatenate().matrix();
00099 }
00100
00101 AffineTransform* SVGTextElement::supplementalTransform()
00102 {
00103 if (!m_supplementalTransform)
00104 m_supplementalTransform.set(new AffineTransform());
00105 return m_supplementalTransform.get();
00106 }
00107
00108 RenderObject* SVGTextElement::createRenderer(RenderArena* arena, RenderStyle* style)
00109 {
00110 kDebug() << "create renderer for <text>" << endl;
00111 return new (arena) RenderSVGText(this);
00112 }
00113
00114 bool SVGTextElement::childShouldCreateRenderer(Node* child) const
00115 {
00116 if (child->isTextNode()
00117 #if ENABLE(SVG_FONTS)
00118 || child->hasTagName(SVGNames::altGlyphTag)
00119 #endif
00120 || child->hasTagName(SVGNames::tspanTag) || child->hasTagName(SVGNames::trefTag) || child->hasTagName(SVGNames::aTag) || child->hasTagName(SVGNames::textPathTag))
00121 return true;
00122 return false;
00123 }
00124
00125 void SVGTextElement::svgAttributeChanged(const QualifiedName& attrName)
00126 {
00127 SVGTextPositioningElement::svgAttributeChanged(attrName);
00128
00129 if (!renderer())
00130 return;
00131
00132 if (SVGTextPositioningElement::isKnownAttribute(attrName))
00133 renderer()->setNeedsLayout(true);
00134 }
00135
00136 }
00137
00138 #endif // ENABLE(SVG)