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 RenderSVGContainer_h 24 #define RenderSVGContainer_h 25 26 #include "core/rendering/svg/RenderSVGModelObject.h" 27 28 namespace WebCore { 29 30 class SVGElement; 31 32 class RenderSVGContainer : public RenderSVGModelObject { 33 public: 34 explicit RenderSVGContainer(SVGElement*); 35 virtual ~RenderSVGContainer(); 36 firstChild()37 RenderObject* firstChild() const { ASSERT(children() == virtualChildren()); return children()->firstChild(); } lastChild()38 RenderObject* lastChild() const { ASSERT(children() == virtualChildren()); return children()->lastChild(); } 39 children()40 const RenderObjectChildList* children() const { return &m_children; } children()41 RenderObjectChildList* children() { return &m_children; } 42 43 virtual void paint(PaintInfo&, const LayoutPoint&); setNeedsBoundariesUpdate()44 virtual void setNeedsBoundariesUpdate() OVERRIDE FINAL { m_needsBoundariesUpdate = true; } needsBoundariesUpdate()45 virtual bool needsBoundariesUpdate() OVERRIDE FINAL { return m_needsBoundariesUpdate; } didTransformToRootUpdate()46 virtual bool didTransformToRootUpdate() { return false; } isObjectBoundingBoxValid()47 bool isObjectBoundingBoxValid() const { return m_objectBoundingBoxValid; } 48 49 protected: virtualChildren()50 virtual RenderObjectChildList* virtualChildren() OVERRIDE FINAL { return children(); } virtualChildren()51 virtual const RenderObjectChildList* virtualChildren() const OVERRIDE FINAL { return children(); } 52 isSVGContainer()53 virtual bool isSVGContainer() const OVERRIDE FINAL { return true; } renderName()54 virtual const char* renderName() const { return "RenderSVGContainer"; } 55 56 virtual void layout(); 57 58 virtual void addChild(RenderObject* child, RenderObject* beforeChild = 0) OVERRIDE FINAL; 59 virtual void removeChild(RenderObject*) OVERRIDE FINAL; 60 virtual void addFocusRingRects(Vector<IntRect>&, const LayoutPoint& additionalOffset, const RenderLayerModelObject* paintContainer = 0) OVERRIDE FINAL; 61 objectBoundingBox()62 virtual FloatRect objectBoundingBox() const OVERRIDE FINAL { return m_objectBoundingBox; } strokeBoundingBox()63 virtual FloatRect strokeBoundingBox() const OVERRIDE FINAL { return m_strokeBoundingBox; } repaintRectInLocalCoordinates()64 virtual FloatRect repaintRectInLocalCoordinates() const OVERRIDE FINAL { return m_repaintBoundingBox; } 65 66 virtual bool nodeAtFloatPoint(const HitTestRequest&, HitTestResult&, const FloatPoint& pointInParent, HitTestAction); 67 68 // Allow RenderSVGTransformableContainer to hook in at the right time in layout() calculateLocalTransform()69 virtual bool calculateLocalTransform() { return false; } 70 71 // Allow RenderSVGViewportContainer to hook in at the right times in layout(), paint() and nodeAtFloatPoint() calcViewport()72 virtual void calcViewport() { } applyViewportClip(PaintInfo &)73 virtual void applyViewportClip(PaintInfo&) { } pointIsInsideViewportClip(const FloatPoint &)74 virtual bool pointIsInsideViewportClip(const FloatPoint& /*pointInParent*/) { return true; } 75 determineIfLayoutSizeChanged()76 virtual void determineIfLayoutSizeChanged() { } 77 78 bool selfWillPaint(); 79 void updateCachedBoundaries(); 80 81 private: 82 RenderObjectChildList m_children; 83 FloatRect m_objectBoundingBox; 84 bool m_objectBoundingBoxValid; 85 FloatRect m_strokeBoundingBox; 86 FloatRect m_repaintBoundingBox; 87 bool m_needsBoundariesUpdate : 1; 88 }; 89 90 DEFINE_RENDER_OBJECT_TYPE_CASTS(RenderSVGContainer, isSVGContainer()); 91 92 } // namespace WebCore 93 94 #endif // RenderSVGContainer_h 95