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 RenderSVGContainer_h
24#define RenderSVGContainer_h
25
26#if ENABLE(SVG)
27
28#include "RenderSVGModelObject.h"
29
30namespace WebCore {
31
32class SVGElement;
33
34class RenderSVGContainer : public RenderSVGModelObject {
35public:
36    RenderSVGContainer(SVGStyledElement*);
37
38    const RenderObjectChildList* children() const { return &m_children; }
39    RenderObjectChildList* children() { return &m_children; }
40
41    // <marker> uses these methods to only allow drawing children during a special marker draw time
42    void setDrawsContents(bool);
43    bool drawsContents() const;
44
45    virtual void paint(PaintInfo&, int parentX, int parentY);
46
47protected:
48    virtual RenderObjectChildList* virtualChildren() { return children(); }
49    virtual const RenderObjectChildList* virtualChildren() const { return children(); }
50
51    virtual bool isSVGContainer() const { return true; }
52    virtual const char* renderName() const { return "RenderSVGContainer"; }
53
54    virtual void layout();
55
56    virtual void addFocusRingRects(Vector<IntRect>&, int tx, int ty);
57
58    virtual FloatRect objectBoundingBox() const;
59    virtual FloatRect strokeBoundingBox() const;
60    virtual FloatRect repaintRectInLocalCoordinates() const;
61
62    virtual bool nodeAtFloatPoint(const HitTestRequest&, HitTestResult&, const FloatPoint& pointInParent, HitTestAction);
63
64    // Allow RenderSVGTransformableContainer to hook in at the right time in layout()
65    virtual void calculateLocalTransform() { }
66
67    // Allow RenderSVGViewportContainer to hook in at the right times in layout(), paint() and nodeAtFloatPoint()
68    virtual void calcViewport() { }
69    virtual void applyViewportClip(PaintInfo&) { }
70    virtual bool pointIsInsideViewportClip(const FloatPoint& /*pointInParent*/) { return true; }
71
72    bool selfWillPaint() const;
73
74private:
75    RenderObjectChildList m_children;
76    bool m_drawsContents : 1;
77};
78
79inline RenderSVGContainer* toRenderSVGContainer(RenderObject* object)
80{
81    // Note: isSVGContainer is also true for RenderSVGViewportContainer, which is not derived from this.
82    ASSERT(!object || (object->isSVGContainer() && strcmp(object->renderName(), "RenderSVGViewportContainer")));
83    return static_cast<RenderSVGContainer*>(object);
84}
85
86inline const RenderSVGContainer* toRenderSVGContainer(const RenderObject* object)
87{
88    // Note: isSVGContainer is also true for RenderSVGViewportContainer, which is not derived from this.
89    ASSERT(!object || (object->isSVGContainer() && strcmp(object->renderName(), "RenderSVGViewportContainer")));
90    return static_cast<const RenderSVGContainer*>(object);
91}
92
93// This will catch anyone doing an unnecessary cast.
94void toRenderSVGContainer(const RenderSVGContainer*);
95
96} // namespace WebCore
97
98#endif // ENABLE(SVG)
99#endif // RenderSVGContainer_h
100
101// vim:ts=4:noet
102