29 #include "RenderSVGViewportContainer.h"
39 SVGMarkerElement::SVGMarkerElement(
const QualifiedName& tagName, Document* doc)
40 : SVGStyledElement(tagName, doc)
42 , SVGExternalResourcesRequired()
44 , m_refX(this, LengthModeWidth)
45 , m_refY(this, LengthModeHeight)
46 , m_markerWidth(this, LengthModeWidth)
47 , m_markerHeight(this, LengthModeHeight)
48 , m_markerUnits(SVG_MARKERUNITS_STROKEWIDTH)
50 , m_orientAngle(new SVGAngle())
53 setMarkerWidthBaseValue(SVGLength(
this, LengthModeWidth,
"3"));
54 setMarkerHeightBaseValue(SVGLength(
this, LengthModeHeight,
"3"));
57 SVGMarkerElement::~SVGMarkerElement()
61 ANIMATED_PROPERTY_DEFINITIONS(SVGMarkerElement, SVGLength, Length, length, RefX, refX,
SVGNames::refXAttr, m_refX)
62 ANIMATED_PROPERTY_DEFINITIONS(SVGMarkerElement, SVGLength, Length, length, RefY, refY, SVGNames::
refYAttr, m_refY)
63 ANIMATED_PROPERTY_DEFINITIONS(SVGMarkerElement,
int, Enumeration, enumeration, MarkerUnits, markerUnits, SVGNames::
markerUnitsAttr, m_markerUnits)
64 ANIMATED_PROPERTY_DEFINITIONS(SVGMarkerElement, SVGLength, Length, length, MarkerWidth, markerWidth, SVGNames::
markerWidthAttr, m_markerWidth)
65 ANIMATED_PROPERTY_DEFINITIONS(SVGMarkerElement, SVGLength, Length, length, MarkerHeight, markerHeight, SVGNames::
markerHeightAttr, m_markerHeight)
66 ANIMATED_PROPERTY_DEFINITIONS_WITH_CUSTOM_IDENTIFIER(SVGMarkerElement,
int, Enumeration, enumeration, OrientType, orientType, SVGNames::
orientAttr, "orientType", m_orientType)
67 ANIMATED_PROPERTY_DEFINITIONS_WITH_CUSTOM_IDENTIFIER(SVGMarkerElement, SVGAngle*, Angle, angle, OrientAngle, orientAngle, SVGNames::orientAttr, "orientAngle", m_orientAngle.get())
69 void SVGMarkerElement::parseMappedAttribute(MappedAttribute* attr)
72 if (attr->value() ==
"userSpaceOnUse")
73 setMarkerUnitsBaseValue(SVG_MARKERUNITS_USERSPACEONUSE);
75 setRefXBaseValue(SVGLength(
this, LengthModeWidth, attr->value()));
77 setRefYBaseValue(SVGLength(
this, LengthModeHeight, attr->value()));
79 setMarkerWidthBaseValue(SVGLength(
this, LengthModeWidth, attr->value()));
81 setMarkerHeightBaseValue(SVGLength(
this, LengthModeHeight, attr->value()));
83 if (attr->value() ==
"auto")
86 SVGAngle* angle =
new SVGAngle();
87 angle->setValueAsString(attr->value());
88 setOrientToAngle(angle);
91 if (SVGLangSpace::parseMappedAttribute(attr))
93 if (SVGExternalResourcesRequired::parseMappedAttribute(attr))
95 if (SVGFitToViewBox::parseMappedAttribute(attr))
98 SVGStyledElement::parseMappedAttribute(attr);
102 void SVGMarkerElement::svgAttributeChanged(
const QualifiedName& attrName)
104 SVGStyledElement::svgAttributeChanged(attrName);
112 SVGLangSpace::isKnownAttribute(attrName) ||
113 SVGExternalResourcesRequired::isKnownAttribute(attrName) ||
114 SVGFitToViewBox::isKnownAttribute(attrName) ||
115 SVGStyledElement::isKnownAttribute(attrName)) {
117 renderer()->setNeedsLayout(
true);
119 m_marker->invalidate();
123 void SVGMarkerElement::childrenChanged(
bool changedByParser, Node* beforeChange, Node* afterChange,
int childCountDelta)
125 SVGStyledElement::childrenChanged(changedByParser, beforeChange, afterChange, childCountDelta);
128 renderer()->setNeedsLayout(
true);
131 m_marker->invalidate();
134 void SVGMarkerElement::setOrientToAuto()
136 setOrientTypeBaseValue(SVG_MARKER_ORIENT_AUTO);
139 void SVGMarkerElement::setOrientToAngle(SVGAngle* angle)
141 setOrientTypeBaseValue(SVG_MARKER_ORIENT_ANGLE);
142 setOrientAngleBaseValue(angle);
145 SVGResource* SVGMarkerElement::canvasResource()
148 m_marker = SVGResourceMarker::create();
150 m_marker->setMarker(static_cast<RenderSVGViewportContainer*>(renderer()));
155 setOrientToAngle(SVGSVGElement::createSVGAngle());
157 if (orientType() == SVG_MARKER_ORIENT_ANGLE)
158 m_marker->setAngle(orientAngle()->value());
160 m_marker->setAutoAngle();
162 m_marker->setRef(refX().value(), refY().value());
163 m_marker->setUseStrokeWidth(markerUnits() == SVG_MARKERUNITS_STROKEWIDTH);
165 return m_marker.get();
168 RenderObject* SVGMarkerElement::createRenderer(RenderArena* arena, RenderStyle* style)
170 RenderSVGViewportContainer* markerContainer =
new (arena) RenderSVGViewportContainer(
this);
171 markerContainer->setDrawsContents(
false);
172 return markerContainer;
177 #endif // ENABLE(SVG)
DOM::QualifiedName markerWidthAttr
DOM::QualifiedName orientAttr
DOM::QualifiedName markerHeightAttr
DOM::QualifiedName refXAttr
DOM::QualifiedName refYAttr
DOM::QualifiedName markerUnitsAttr