1 /*
2 Copyright (C) 2004, 2005, 2007 Nikolas Zimmermann <zimmermann@kde.org>
3 2004, 2005, 2007 Rob Buis <buis@kde.org>
4 Copyright (C) 2009 Google, Inc. All rights reserved.
5 Copyright (C) 2009 Apple Inc. All rights reserved.
6
7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Library General Public
9 License as published by the Free Software Foundation; either
10 version 2 of the License, or (at your option) any later version.
11
12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Library General Public License for more details.
16
17 You should have received a copy of the GNU Library General Public License
18 aint with this library; see the file COPYING.LIB. If not, write to
19 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20 Boston, MA 02110-1301, USA.
21 */
22
23 #ifndef RenderSVGRoot_h
24 #define RenderSVGRoot_h
25
26 #if ENABLE(SVG)
27 #include "RenderBox.h"
28 #include "FloatRect.h"
29 #include "SVGRenderSupport.h"
30
31 namespace WebCore {
32
33 class SVGStyledElement;
34 class TransformationMatrix;
35
36 class RenderSVGRoot : public RenderBox, SVGRenderBase {
37 public:
38 RenderSVGRoot(SVGStyledElement*);
39
children()40 const RenderObjectChildList* children() const { return &m_children; }
children()41 RenderObjectChildList* children() { return &m_children; }
42
43 private:
virtualChildren()44 virtual RenderObjectChildList* virtualChildren() { return children(); }
virtualChildren()45 virtual const RenderObjectChildList* virtualChildren() const { return children(); }
46
isSVGRoot()47 virtual bool isSVGRoot() const { return true; }
renderName()48 virtual const char* renderName() const { return "RenderSVGRoot"; }
49
50 virtual int lineHeight(bool b, bool isRootLineBox = false) const;
51 virtual int baselinePosition(bool b, bool isRootLineBox = false) const;
52 virtual void calcPrefWidths();
53
54 virtual void layout();
55 virtual void paint(PaintInfo&, int parentX, int parentY);
56
57 virtual TransformationMatrix localToParentTransform() const;
58
59 bool fillContains(const FloatPoint&) const;
60 bool strokeContains(const FloatPoint&) const;
61
62 virtual FloatRect objectBoundingBox() const;
63 virtual FloatRect repaintRectInLocalCoordinates() const;
64
65 // FIXME: Both of these overrides should be removed.
66 virtual TransformationMatrix localTransform() const;
67 virtual TransformationMatrix absoluteTransform() const;
68
69 virtual bool nodeAtPoint(const HitTestRequest&, HitTestResult&, int x, int y, int tx, int ty, HitTestAction);
70
71 virtual void computeRectForRepaint(RenderBoxModelObject* repaintContainer, IntRect& repaintRect, bool fixed);
72
73 virtual void mapLocalToContainer(RenderBoxModelObject* repaintContainer, bool useTransforms, bool fixed, TransformState&) const;
74
75 void calcViewport();
76 const FloatSize& viewportSize() const;
77
78 bool selfWillPaint() const;
79
80 IntSize parentOriginToBorderBox() const;
81 IntSize borderOriginToContentBox() const;
82 TransformationMatrix localToRepaintContainerTransform(const IntPoint& parentOriginInContainer) const;
83 TransformationMatrix localToBorderBoxTransform() const;
84
85 RenderObjectChildList m_children;
86 FloatSize m_viewportSize;
87 };
88
toRenderSVGRoot(RenderObject * object)89 inline RenderSVGRoot* toRenderSVGRoot(RenderObject* object)
90 {
91 ASSERT(!object || object->isSVGRoot());
92 return static_cast<RenderSVGRoot*>(object);
93 }
94
toRenderSVGRoot(const RenderObject * object)95 inline const RenderSVGRoot* toRenderSVGRoot(const RenderObject* object)
96 {
97 ASSERT(!object || object->isSVGRoot());
98 return static_cast<const RenderSVGRoot*>(object);
99 }
100
101 // This will catch anyone doing an unnecessary cast.
102 void toRenderSVGRoot(const RenderSVGRoot*);
103
104 } // namespace WebCore
105
106 #endif // ENABLE(SVG)
107 #endif // RenderSVGRoot_h
108
109 // vim:ts=4:noet
110