• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
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.
7  *
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.
12  *
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.
17  *
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.
22  */
23 
24 #ifndef RenderSVGPath_h
25 #define RenderSVGPath_h
26 
27 #if ENABLE(SVG)
28 #include "AffineTransform.h"
29 #include "FloatRect.h"
30 #include "RenderSVGModelObject.h"
31 #include "SVGMarkerLayoutInfo.h"
32 
33 namespace WebCore {
34 
35 class FloatPoint;
36 class RenderSVGContainer;
37 class SVGStyledTransformableElement;
38 
39 class RenderSVGPath : public RenderSVGModelObject {
40 public:
41     explicit RenderSVGPath(SVGStyledTransformableElement*);
42     virtual ~RenderSVGPath();
43 
path()44     const Path& path() const { return m_path; }
setNeedsPathUpdate()45     void setNeedsPathUpdate() { m_needsPathUpdate = true; }
setNeedsBoundariesUpdate()46     virtual void setNeedsBoundariesUpdate() { m_needsBoundariesUpdate = true; }
setNeedsTransformUpdate()47     virtual void setNeedsTransformUpdate() { m_needsTransformUpdate = true; }
48 
49 private:
50     // Hit-detection seperated for the fill and the stroke
51     bool fillContains(const FloatPoint&, bool requiresFill = true, WindRule fillRule = RULE_NONZERO);
52     bool strokeContains(const FloatPoint&, bool requiresStroke = true);
53 
objectBoundingBox()54     virtual FloatRect objectBoundingBox() const { return m_fillBoundingBox; }
strokeBoundingBox()55     virtual FloatRect strokeBoundingBox() const { return m_strokeAndMarkerBoundingBox; }
repaintRectInLocalCoordinates()56     virtual FloatRect repaintRectInLocalCoordinates() const { return m_repaintBoundingBox; }
localToParentTransform()57     virtual const AffineTransform& localToParentTransform() const { return m_localTransform; }
58 
isSVGPath()59     virtual bool isSVGPath() const { return true; }
renderName()60     virtual const char* renderName() const { return "RenderSVGPath"; }
61 
62     virtual void layout();
63     virtual void paint(PaintInfo&, int parentX, int parentY);
64     virtual void addFocusRingRects(Vector<IntRect>&, int tx, int ty);
65 
66     virtual bool nodeAtFloatPoint(const HitTestRequest&, HitTestResult&, const FloatPoint& pointInParent, HitTestAction);
67 
68     FloatRect calculateMarkerBoundsIfNeeded();
69     void updateCachedBoundaries();
70 
71 private:
localTransform()72     virtual AffineTransform localTransform() const { return m_localTransform; }
73     void fillAndStrokePath(GraphicsContext*);
74 
75     bool m_needsBoundariesUpdate : 1;
76     bool m_needsPathUpdate : 1;
77     bool m_needsTransformUpdate : 1;
78 
79     mutable Path m_path;
80     FloatRect m_fillBoundingBox;
81     FloatRect m_strokeAndMarkerBoundingBox;
82     FloatRect m_repaintBoundingBox;
83     SVGMarkerLayoutInfo m_markerLayoutInfo;
84     AffineTransform m_localTransform;
85 };
86 
toRenderSVGPath(RenderObject * object)87 inline RenderSVGPath* toRenderSVGPath(RenderObject* object)
88 {
89     ASSERT(!object || object->isSVGPath());
90     return static_cast<RenderSVGPath*>(object);
91 }
92 
toRenderSVGPath(const RenderObject * object)93 inline const RenderSVGPath* toRenderSVGPath(const RenderObject* object)
94 {
95     ASSERT(!object || object->isSVGPath());
96     return static_cast<const RenderSVGPath*>(object);
97 }
98 
99 // This will catch anyone doing an unnecessary cast.
100 void toRenderSVGPath(const RenderSVGPath*);
101 
102 }
103 
104 #endif // ENABLE(SVG)
105 #endif
106