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 "SVGLineElement.h"
00028
00029 #include "FloatPoint.h"
00030 #include "RenderPath.h"
00031 #include "SVGLength.h"
00032 #include "SVGNames.h"
00033
00034 namespace WebCore {
00035
00036 SVGLineElement::SVGLineElement(const QualifiedName& tagName, Document* doc)
00037 : SVGStyledTransformableElement(tagName, doc)
00038 , SVGTests()
00039 , SVGLangSpace()
00040 , SVGExternalResourcesRequired()
00041 , m_x1(this, LengthModeWidth)
00042 , m_y1(this, LengthModeHeight)
00043 , m_x2(this, LengthModeWidth)
00044 , m_y2(this, LengthModeHeight)
00045 {
00046 }
00047
00048 SVGLineElement::~SVGLineElement()
00049 {
00050 }
00051
00052 ANIMATED_PROPERTY_DEFINITIONS(SVGLineElement, SVGLength, Length, length, X1, x1, SVGNames::x1Attr, m_x1)
00053 ANIMATED_PROPERTY_DEFINITIONS(SVGLineElement, SVGLength, Length, length, Y1, y1, SVGNames::y1Attr, m_y1)
00054 ANIMATED_PROPERTY_DEFINITIONS(SVGLineElement, SVGLength, Length, length, X2, x2, SVGNames::x2Attr, m_x2)
00055 ANIMATED_PROPERTY_DEFINITIONS(SVGLineElement, SVGLength, Length, length, Y2, y2, SVGNames::y2Attr, m_y2)
00056
00057 void SVGLineElement::parseMappedAttribute(MappedAttribute* attr)
00058 {
00059 if (attr->name() == SVGNames::x1Attr)
00060 setX1BaseValue(SVGLength(this, LengthModeWidth, attr->value()));
00061 else if (attr->name() == SVGNames::y1Attr)
00062 setY1BaseValue(SVGLength(this, LengthModeHeight, attr->value()));
00063 else if (attr->name() == SVGNames::x2Attr)
00064 setX2BaseValue(SVGLength(this, LengthModeWidth, attr->value()));
00065 else if (attr->name() == SVGNames::y2Attr)
00066 setY2BaseValue(SVGLength(this, LengthModeHeight, attr->value()));
00067 else
00068 {
00069 if (SVGTests::parseMappedAttribute(attr))
00070 return;
00071 if (SVGLangSpace::parseMappedAttribute(attr))
00072 return;
00073 if (SVGExternalResourcesRequired::parseMappedAttribute(attr))
00074 return;
00075 SVGStyledTransformableElement::parseMappedAttribute(attr);
00076 }
00077 }
00078
00079 void SVGLineElement::svgAttributeChanged(const QualifiedName& attrName)
00080 {
00081 SVGStyledTransformableElement::svgAttributeChanged(attrName);
00082
00083 if (!renderer())
00084 return;
00085
00086 if (attrName == SVGNames::x1Attr || attrName == SVGNames::y1Attr ||
00087 attrName == SVGNames::x2Attr || attrName == SVGNames::y2Attr ||
00088 SVGTests::isKnownAttribute(attrName) ||
00089 SVGLangSpace::isKnownAttribute(attrName) ||
00090 SVGExternalResourcesRequired::isKnownAttribute(attrName) ||
00091 SVGStyledTransformableElement::isKnownAttribute(attrName))
00092 renderer()->setNeedsLayout(true);
00093 }
00094
00095 Path SVGLineElement::toPathData() const
00096 {
00097 return Path::createLine(FloatPoint(x1().value(), y1().value()),
00098 FloatPoint(x2().value(), y2().value()));
00099 }
00100
00101 bool SVGLineElement::hasRelativeValues() const
00102 {
00103 return (x1().isRelative() || y1().isRelative() ||
00104 x2().isRelative() || y2().isRelative());
00105 }
00106
00107 }
00108
00109 #endif // ENABLE(SVG)