• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2     Copyright (C) 2004, 2005, 2007 Nikolas Zimmermann <zimmermann@kde.org>
3                   2004, 2005 Rob Buis <buis@kde.org>
4                   2005 Eric Seidel <eric@webkit.org>
5                   2006 Apple Computer, Inc
6                   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     aint 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 RenderPath_h
25 #define RenderPath_h
26 
27 #if ENABLE(SVG)
28 
29 #include "FloatRect.h"
30 #include "RenderSVGModelObject.h"
31 #include "TransformationMatrix.h"
32 
33 namespace WebCore {
34 
35 class FloatPoint;
36 class RenderSVGContainer;
37 class SVGStyledTransformableElement;
38 
39 class RenderPath : public RenderSVGModelObject {
40 public:
41     RenderPath(SVGStyledTransformableElement*);
42 
43     const Path& path() const;
44 
45 private:
46     // Hit-detection seperated for the fill and the stroke
47     bool fillContains(const FloatPoint&, bool requiresFill = true) const;
48     bool strokeContains(const FloatPoint&, bool requiresStroke = true) const;
49 
50     virtual FloatRect objectBoundingBox() const;
51     virtual FloatRect repaintRectInLocalCoordinates() const;
52 
53     virtual TransformationMatrix localToParentTransform() const;
54 
55     void setPath(const Path&);
56 
isRenderPath()57     virtual bool isRenderPath() const { return true; }
renderName()58     virtual const char* renderName() const { return "RenderPath"; }
59 
60     virtual void layout();
61     virtual void paint(PaintInfo&, int parentX, int parentY);
62     virtual void addFocusRingRects(GraphicsContext*, int tx, int ty);
63 
64     virtual bool nodeAtFloatPoint(const HitTestRequest&, HitTestResult&, const FloatPoint& pointInParent, HitTestAction);
65 
66     FloatRect drawMarkersIfNeeded(GraphicsContext*, const FloatRect&, const Path&) const;
67 
68 private:
69     virtual TransformationMatrix localTransform() const;
70 
71     mutable Path m_path;
72     mutable FloatRect m_cachedLocalFillBBox;
73     mutable FloatRect m_cachedLocalRepaintRect;
74     FloatRect m_markerBounds;
75     TransformationMatrix m_localTransform;
76 };
77 
toRenderPath(RenderObject * object)78 inline RenderPath* toRenderPath(RenderObject* object)
79 {
80     ASSERT(!object || object->isRenderPath());
81     return static_cast<RenderPath*>(object);
82 }
83 
toRenderPath(const RenderObject * object)84 inline const RenderPath* toRenderPath(const RenderObject* object)
85 {
86     ASSERT(!object || object->isRenderPath());
87     return static_cast<const RenderPath*>(object);
88 }
89 
90 // This will catch anyone doing an unnecessary cast.
91 void toRenderPath(const RenderPath*);
92 
93 }
94 
95 #endif // ENABLE(SVG)
96 #endif
97 
98 // vim:ts=4:noet
99