1 /* 2 * Copyright (C) 2004, 2005, 2007 Nikolas Zimmermann <zimmermann (at) kde.org> 3 * Copyright (C) 2004, 2005, 2007 Rob Buis <buis (at) 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 42 const RenderObjectChildList* children() const { return &m_children; } 43 RenderObjectChildList* children() { return &m_children; } 44 45 bool isLayoutSizeChanged() const { return m_isLayoutSizeChanged; } 46 virtual void setNeedsBoundariesUpdate() { m_needsBoundariesOrTransformUpdate = true; } 47 virtual void setNeedsTransformUpdate() { m_needsBoundariesOrTransformUpdate = true; } 48 49 private: 50 virtual RenderObjectChildList* virtualChildren() { return children(); } 51 virtual const RenderObjectChildList* virtualChildren() const { return children(); } 52 53 virtual bool isSVGRoot() const { return true; } 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 72 virtual FloatRect objectBoundingBox() const { return m_objectBoundingBox; } 73 virtual FloatRect strokeBoundingBox() const { return m_strokeBoundingBox; } 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 103 inline RenderSVGRoot* toRenderSVGRoot(RenderObject* object) 104 { 105 ASSERT(!object || object->isSVGRoot()); 106 return static_cast<RenderSVGRoot*>(object); 107 } 108 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