32 #include "GraphicsContext.h"
33 #include "RenderSVGViewportContainer.h"
34 #include "TextStream.h"
38 SVGResourceMarker::SVGResourceMarker()
44 , m_useStrokeWidth(true)
48 SVGResourceMarker::~SVGResourceMarker()
52 void SVGResourceMarker::setMarker(RenderSVGViewportContainer* marker)
57 void SVGResourceMarker::setRef(
double refX,
double refY)
63 void SVGResourceMarker::draw(GraphicsContext* context,
const FloatRect& rect,
double x,
double y,
double strokeWidth,
double angle)
68 static HashSet<SVGResourceMarker*> currentlyDrawingMarkers;
71 if (currentlyDrawingMarkers.contains(
this))
74 currentlyDrawingMarkers.add(
this);
76 AffineTransform transform;
77 transform.translate(x, y);
78 transform.rotate(m_angle > -1 ? m_angle : angle);
82 AffineTransform viewportTransform;
84 viewportTransform.scale(strokeWidth, strokeWidth);
85 viewportTransform *= m_marker->viewportTransform();
87 viewportTransform.map(m_refX, m_refY, &refX, &refY);
88 transform.translate(-refX, -refY);
91 transform.scale(strokeWidth, strokeWidth);
95 RenderObject::PaintInfo info(context,
enclosingIntRect(rect), PaintPhaseForeground, 0, 0, 0);
98 context->concatCTM(transform);
99 m_marker->setDrawsContents(
true);
100 m_marker->paint(info, 0, 0);
101 m_marker->setDrawsContents(
false);
104 m_cachedBounds = transform.mapRect(m_marker->absoluteClippedOverflowRect());
106 currentlyDrawingMarkers.remove(
this);
109 FloatRect SVGResourceMarker::cachedBounds()
const
111 return m_cachedBounds;
114 TextStream& SVGResourceMarker::externalRepresentation(TextStream& ts)
const
116 ts <<
"[type=MARKER]"
122 ts << angle() <<
"]";
124 ts <<
" [ref x=" << refX() <<
" y=" << refY() <<
"]";
128 SVGResourceMarker* getMarkerById(Document* document,
const AtomicString&
id)
130 SVGResource* resource = getResourceById(document,
id);
131 if (resource && resource->isMarker())
132 return static_cast<SVGResourceMarker*>(resource);
IntRect enclosingIntRect(const FloatRect &rect)