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