29#include "RenderSVGViewportContainer.h"
39SVGMarkerElement::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"));
57SVGMarkerElement::~SVGMarkerElement()
61ANIMATED_PROPERTY_DEFINITIONS(SVGMarkerElement, SVGLength, Length, length, RefX, refX, SVGNames::refXAttr, m_refX)
62ANIMATED_PROPERTY_DEFINITIONS(SVGMarkerElement, SVGLength, Length, length, RefY, refY, SVGNames::refYAttr, m_refY)
63ANIMATED_PROPERTY_DEFINITIONS(SVGMarkerElement,
int, Enumeration, enumeration, MarkerUnits, markerUnits, SVGNames::markerUnitsAttr, m_markerUnits)
64ANIMATED_PROPERTY_DEFINITIONS(SVGMarkerElement, SVGLength, Length, length, MarkerWidth, markerWidth, SVGNames::markerWidthAttr, m_markerWidth)
65ANIMATED_PROPERTY_DEFINITIONS(SVGMarkerElement, SVGLength, Length, length, MarkerHeight, markerHeight, SVGNames::markerHeightAttr, m_markerHeight)
66ANIMATED_PROPERTY_DEFINITIONS_WITH_CUSTOM_IDENTIFIER(SVGMarkerElement,
int, Enumeration, enumeration, OrientType, orientType, SVGNames::orientAttr,
"orientType", m_orientType)
67ANIMATED_PROPERTY_DEFINITIONS_WITH_CUSTOM_IDENTIFIER(SVGMarkerElement, SVGAngle*, Angle, angle, OrientAngle, orientAngle, SVGNames::orientAttr,
"orientAngle", m_orientAngle.get())
69void SVGMarkerElement::parseMappedAttribute(MappedAttribute* attr)
71 if (attr->name() == SVGNames::markerUnitsAttr) {
72 if (attr->value() ==
"userSpaceOnUse")
73 setMarkerUnitsBaseValue(SVG_MARKERUNITS_USERSPACEONUSE);
74 }
else if (attr->name() == SVGNames::refXAttr)
75 setRefXBaseValue(SVGLength(
this, LengthModeWidth, attr->value()));
76 else if (attr->name() == SVGNames::refYAttr)
77 setRefYBaseValue(SVGLength(
this, LengthModeHeight, attr->value()));
78 else if (attr->name() == SVGNames::markerWidthAttr)
79 setMarkerWidthBaseValue(SVGLength(
this, LengthModeWidth, attr->value()));
80 else if (attr->name() == SVGNames::markerHeightAttr)
81 setMarkerHeightBaseValue(SVGLength(
this, LengthModeHeight, attr->value()));
82 else if (attr->name() == SVGNames::orientAttr) {
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);
102void SVGMarkerElement::svgAttributeChanged(
const QualifiedName& attrName)
104 SVGStyledElement::svgAttributeChanged(attrName);
109 if (attrName == SVGNames::markerUnitsAttr || attrName == SVGNames::refXAttr ||
110 attrName == SVGNames::refYAttr || attrName == SVGNames::markerWidthAttr ||
111 attrName == SVGNames::markerHeightAttr || attrName == SVGNames::orientAttr ||
112 SVGLangSpace::isKnownAttribute(attrName) ||
113 SVGExternalResourcesRequired::isKnownAttribute(attrName) ||
114 SVGFitToViewBox::isKnownAttribute(attrName) ||
115 SVGStyledElement::isKnownAttribute(attrName)) {
117 renderer()->setNeedsLayout(
true);
119 m_marker->invalidate();
123void 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();
134void SVGMarkerElement::setOrientToAuto()
136 setOrientTypeBaseValue(SVG_MARKER_ORIENT_AUTO);
139void SVGMarkerElement::setOrientToAngle(SVGAngle* angle)
141 setOrientTypeBaseValue(SVG_MARKER_ORIENT_ANGLE);
142 setOrientAngleBaseValue(angle);
145SVGResource* 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();
168RenderObject* SVGMarkerElement::createRenderer(RenderArena* arena, RenderStyle* style)
170 RenderSVGViewportContainer* markerContainer =
new (arena) RenderSVGViewportContainer(
this);
171 markerContainer->setDrawsContents(
false);
172 return markerContainer;