• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2004, 2005, 2007 Nikolas Zimmermann <zimmermann@kde.org>
3  * Copyright (C) 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  * along 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 "FloatRect.h"
28 #include "RenderBox.h"
29 
30 #include "SVGRenderSupport.h"
31 
32 namespace WebCore {
33 
34 class SVGStyledElement;
35 class AffineTransform;
36 
37 class RenderSVGRoot : public RenderBox {
38 public:
39     explicit RenderSVGRoot(SVGStyledElement*);
40     virtual ~RenderSVGRoot();
41 
children()42     const RenderObjectChildList* children() const { return &m_children; }
children()43     RenderObjectChildList* children() { return &m_children; }
44 
isLayoutSizeChanged()45     bool isLayoutSizeChanged() const { return m_isLayoutSizeChanged; }
setNeedsBoundariesUpdate()46     virtual void setNeedsBoundariesUpdate() { m_needsBoundariesOrTransformUpdate = true; }
setNeedsTransformUpdate()47     virtual void setNeedsTransformUpdate() { m_needsBoundariesOrTransformUpdate = true; }
48 
49 private:
virtualChildren()50     virtual RenderObjectChildList* virtualChildren() { return children(); }
virtualChildren()51     virtual const RenderObjectChildList* virtualChildren() const { return children(); }
52 
isSVGRoot()53     virtual bool isSVGRoot() const { return true; }
renderName()54     virtual const char* renderName() const { return "RenderSVGRoot"; }
55 
56     virtual void computePreferredLogicalWidths();
57     virtual int computeReplacedLogicalWidth(bool includeMaxWidth = true) const;
58     virtual int computeReplacedLogicalHeight() const;
59     virtual void layout();
60     virtual void paint(PaintInfo&, int parentX, int parentY);
61 
62     virtual void destroy();
63     virtual void styleWillChange(StyleDifference, const RenderStyle* newStyle);
64     virtual void styleDidChange(StyleDifference, const RenderStyle* oldStyle);
65     virtual void updateFromElement();
66 
67     virtual const AffineTransform& localToParentTransform() const;
68 
69     bool fillContains(const FloatPoint&) const;
70     bool strokeContains(const FloatPoint&) const;
71 
objectBoundingBox()72     virtual FloatRect objectBoundingBox() const { return m_objectBoundingBox; }
strokeBoundingBox()73     virtual FloatRect strokeBoundingBox() const { return m_strokeBoundingBox; }
repaintRectInLocalCoordinates()74     virtual FloatRect repaintRectInLocalCoordinates() const { return m_repaintBoundingBox; }
75 
76     virtual bool nodeAtPoint(const HitTestRequest&, HitTestResult&, int x, int y, int tx, int ty, HitTestAction);
77 
78     virtual IntRect clippedOverflowRectForRepaint(RenderBoxModelObject* repaintContainer);
79     virtual void computeRectForRepaint(RenderBoxModelObject* repaintContainer, IntRect& repaintRect, bool fixed);
80 
81     virtual void mapLocalToContainer(RenderBoxModelObject* repaintContainer, bool useTransforms, bool fixed, TransformState&) const;
82 
83     void calcViewport();
84 
85     bool selfWillPaint();
86     void updateCachedBoundaries();
87 
88     IntSize parentOriginToBorderBox() const;
89     IntSize borderOriginToContentBox() const;
90     AffineTransform localToRepaintContainerTransform(const IntPoint& parentOriginInContainer) const;
91     AffineTransform localToBorderBoxTransform() const;
92 
93     RenderObjectChildList m_children;
94     FloatSize m_viewportSize;
95     FloatRect m_objectBoundingBox;
96     FloatRect m_strokeBoundingBox;
97     FloatRect m_repaintBoundingBox;
98     mutable AffineTransform m_localToParentTransform;
99     bool m_isLayoutSizeChanged : 1;
100     bool m_needsBoundariesOrTransformUpdate : 1;
101 };
102 
toRenderSVGRoot(RenderObject * object)103 inline RenderSVGRoot* toRenderSVGRoot(RenderObject* object)
104 {
105     ASSERT(!object || object->isSVGRoot());
106     return static_cast<RenderSVGRoot*>(object);
107 }
108 
toRenderSVGRoot(const RenderObject * object)109 inline const RenderSVGRoot* toRenderSVGRoot(const RenderObject* object)
110 {
111     ASSERT(!object || object->isSVGRoot());
112     return static_cast<const RenderSVGRoot*>(object);
113 }
114 
115 // This will catch anyone doing an unnecessary cast.
116 void toRenderSVGRoot(const RenderSVGRoot*);
117 
118 } // namespace WebCore
119 
120 #endif // ENABLE(SVG)
121 #endif // RenderSVGRoot_h
122