1 /*
2  * Copyright (C) 2006 Alexander Kellett <lypanov@kde.org>
3  * Copyright (C) 2006, 2009 Apple Inc. All rights reserved.
4  * Copyright (C) 2007 Rob Buis <buis@kde.org>
5  * Copyright (C) 2009 Google, Inc.
6  * Copyright (C) 2010 Patrick Gansterer <paroga@paroga.com>
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Library General Public
10  * License as published by the Free Software Foundation; either
11  * version 2 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16  * Library General Public License for more details.
17  *
18  * You should have received a copy of the GNU Library General Public License
19  * along with this library; see the file COPYING.LIB.  If not, write to
20  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21  * Boston, MA 02110-1301, USA.
22  */
23 
24 #ifndef RenderSVGImage_h
25 #define RenderSVGImage_h
26 
27 #if ENABLE(SVG)
28 #include "AffineTransform.h"
29 #include "FloatRect.h"
30 #include "RenderSVGModelObject.h"
31 #include "SVGPreserveAspectRatio.h"
32 #include "SVGRenderSupport.h"
33 
34 namespace WebCore {
35 
36 class RenderImageResource;
37 class SVGImageElement;
38 
39 class RenderSVGImage : public RenderSVGModelObject {
40 public:
41     RenderSVGImage(SVGImageElement*);
42     virtual ~RenderSVGImage();
43 
setNeedsTransformUpdate()44     virtual void setNeedsTransformUpdate() { m_needsTransformUpdate = true; }
45     virtual void updateFromElement();
46 
imageResource()47     RenderImageResource* imageResource() { return m_imageResource.get(); }
imageResource()48     const RenderImageResource* imageResource() const { return m_imageResource.get(); }
49 
50 private:
renderName()51     virtual const char* renderName() const { return "RenderSVGImage"; }
isSVGImage()52     virtual bool isSVGImage() const { return true; }
53 
localToParentTransform()54     virtual const AffineTransform& localToParentTransform() const { return m_localTransform; }
55 
objectBoundingBox()56     virtual FloatRect objectBoundingBox() const { return m_objectBoundingBox; }
strokeBoundingBox()57     virtual FloatRect strokeBoundingBox() const { return m_objectBoundingBox; }
repaintRectInLocalCoordinates()58     virtual FloatRect repaintRectInLocalCoordinates() const { return m_repaintBoundingBox; }
59 
60     virtual void addFocusRingRects(Vector<IntRect>&, int tx, int ty);
61 
62     virtual void imageChanged(WrappedImagePtr, const IntRect* = 0);
63 
64     virtual void layout();
65     virtual void paint(PaintInfo&, int parentX, int parentY);
66 
requiresLayer()67     virtual bool requiresLayer() const { return false; }
68 
69     virtual bool nodeAtFloatPoint(const HitTestRequest&, HitTestResult&, const FloatPoint& pointInParent, HitTestAction);
70 
localTransform()71     virtual AffineTransform localTransform() const { return m_localTransform; }
72 
73     bool m_updateCachedRepaintRect : 1;
74     bool m_needsTransformUpdate : 1;
75     AffineTransform m_localTransform;
76     FloatRect m_objectBoundingBox;
77     FloatRect m_repaintBoundingBox;
78     OwnPtr<RenderImageResource> m_imageResource;
79 };
80 
toRenderSVGImage(RenderObject * object)81 inline RenderSVGImage* toRenderSVGImage(RenderObject* object)
82 {
83     ASSERT(!object || object->isSVGImage());
84     return static_cast<RenderSVGImage*>(object);
85 }
86 
toRenderSVGImage(const RenderObject * object)87 inline const RenderSVGImage* toRenderSVGImage(const RenderObject* object)
88 {
89     ASSERT(!object || object->isSVGImage());
90     return static_cast<const RenderSVGImage*>(object);
91 }
92 
93 // This will catch anyone doing an unnecessary cast.
94 void toRenderSVGImage(const RenderSVGImage*);
95 
96 } // namespace WebCore
97 
98 #endif // ENABLE(SVG)
99 #endif // RenderSVGImage_h
100