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