2 * Copyright (C) 2004, 2005, 2007 Nikolas Zimmermann <zimmermann@kde.org>
3 * Copyright (C) 2004, 2005 Rob Buis <buis@kde.org>
4 * Copyright (C) 2005 Eric Seidel <eric@webkit.org>
5 * Copyright (C) 2006 Apple Computer, Inc
6 * Copyright (C) 2009 Google, Inc.
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either
11 * version 2 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Library General Public License for more details.
18 * You should have received a copy of the GNU Library General Public License
19 * along with this library; see the file COPYING.LIB. If not, write to
20 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21 * Boston, MA 02110-1301, USA.
24 #ifndef RenderSVGPath_h
25 #define RenderSVGPath_h
28 #include "AffineTransform.h"
29 #include "FloatRect.h"
30 #include "RenderSVGModelObject.h"
31 #include "SVGMarkerLayoutInfo.h"
36 class GraphicsContextStateSaver;
37 class RenderSVGContainer;
38 class SVGStyledTransformableElement;
40 class RenderSVGPath : public RenderSVGModelObject {
42 explicit RenderSVGPath(SVGStyledTransformableElement*);
43 virtual ~RenderSVGPath();
45 const Path& path() const { return m_path; }
46 void setNeedsPathUpdate() { m_needsPathUpdate = true; }
47 virtual void setNeedsBoundariesUpdate() { m_needsBoundariesUpdate = true; }
48 virtual void setNeedsTransformUpdate() { m_needsTransformUpdate = true; }
51 // Hit-detection seperated for the fill and the stroke
52 bool fillContains(const FloatPoint&, bool requiresFill = true, WindRule fillRule = RULE_NONZERO);
53 bool strokeContains(const FloatPoint&, bool requiresStroke = true);
55 virtual FloatRect objectBoundingBox() const { return m_fillBoundingBox; }
56 virtual FloatRect strokeBoundingBox() const { return m_strokeAndMarkerBoundingBox; }
57 virtual FloatRect repaintRectInLocalCoordinates() const { return m_repaintBoundingBox; }
58 virtual const AffineTransform& localToParentTransform() const { return m_localTransform; }
60 virtual bool isSVGPath() const { return true; }
61 virtual const char* renderName() const { return "RenderSVGPath"; }
63 virtual void layout();
64 virtual void paint(PaintInfo&, const LayoutPoint&);
65 virtual void addFocusRingRects(Vector<LayoutRect>&, const LayoutPoint&);
67 virtual bool nodeAtFloatPoint(const HitTestRequest&, HitTestResult&, const FloatPoint& pointInParent, HitTestAction);
69 FloatRect calculateMarkerBoundsIfNeeded();
70 void updateCachedBoundaries();
72 void setupSquareCapPath(Path*& usePath, int& applyMode);
73 bool setupNonScalingStrokePath(Path*& usePath, GraphicsContextStateSaver&);
74 bool shouldStrokeZeroLengthSubpath() const;
75 FloatRect zeroLengthSubpathRect() const;
78 virtual AffineTransform localTransform() const { return m_localTransform; }
79 void fillAndStrokePath(GraphicsContext*);
81 bool m_needsBoundariesUpdate : 1;
82 bool m_needsPathUpdate : 1;
83 bool m_needsTransformUpdate : 1;
86 FloatRect m_fillBoundingBox;
87 FloatRect m_strokeAndMarkerBoundingBox;
88 FloatRect m_repaintBoundingBox;
89 SVGMarkerLayoutInfo m_markerLayoutInfo;
90 AffineTransform m_localTransform;
93 inline RenderSVGPath* toRenderSVGPath(RenderObject* object)
95 ASSERT(!object || object->isSVGPath());
96 return static_cast<RenderSVGPath*>(object);
99 inline const RenderSVGPath* toRenderSVGPath(const RenderObject* object)
101 ASSERT(!object || object->isSVGPath());
102 return static_cast<const RenderSVGPath*>(object);
105 // This will catch anyone doing an unnecessary cast.
106 void toRenderSVGPath(const RenderSVGPath*);
110 #endif // ENABLE(SVG)