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 #include "core/rendering/svg/RenderSVGModelObject.h" 28 29 namespace WebCore { 30 31 class RenderImageResource; 32 class SVGImageElement; 33 34 class RenderSVGImage FINAL : public RenderSVGModelObject { 35 public: 36 explicit RenderSVGImage(SVGImageElement*); 37 virtual ~RenderSVGImage(); 38 39 bool updateImageViewport(); setNeedsBoundariesUpdate()40 virtual void setNeedsBoundariesUpdate() OVERRIDE { m_needsBoundariesUpdate = true; } setNeedsTransformUpdate()41 virtual void setNeedsTransformUpdate() OVERRIDE { m_needsTransformUpdate = true; } 42 imageResource()43 RenderImageResource* imageResource() { return m_imageResource.get(); } 44 45 // Note: Assumes the PaintInfo context has had all local transforms applied. 46 void paintForeground(PaintInfo&); 47 48 private: renderName()49 virtual const char* renderName() const OVERRIDE { return "RenderSVGImage"; } isSVGImage()50 virtual bool isSVGImage() const OVERRIDE { return true; } 51 localToParentTransform()52 virtual const AffineTransform& localToParentTransform() const OVERRIDE { return m_localTransform; } 53 objectBoundingBox()54 virtual FloatRect objectBoundingBox() const OVERRIDE { return m_objectBoundingBox; } strokeBoundingBox()55 virtual FloatRect strokeBoundingBox() const OVERRIDE { return m_objectBoundingBox; } paintInvalidationRectInLocalCoordinates()56 virtual FloatRect paintInvalidationRectInLocalCoordinates() const OVERRIDE { return m_repaintBoundingBox; } 57 58 virtual void addFocusRingRects(Vector<IntRect>&, const LayoutPoint& additionalOffset, const RenderLayerModelObject* paintContainer = 0) OVERRIDE; 59 60 virtual void imageChanged(WrappedImagePtr, const IntRect* = 0) OVERRIDE; 61 62 virtual void layout() OVERRIDE; 63 virtual void paint(PaintInfo&, const LayoutPoint&) OVERRIDE; 64 65 void invalidateBufferedForeground(); 66 67 virtual bool nodeAtFloatPoint(const HitTestRequest&, HitTestResult&, const FloatPoint& pointInParent, HitTestAction) OVERRIDE; 68 localTransform()69 virtual AffineTransform localTransform() const OVERRIDE { return m_localTransform; } 70 71 bool m_needsBoundariesUpdate : 1; 72 bool m_needsTransformUpdate : 1; 73 AffineTransform m_localTransform; 74 FloatRect m_objectBoundingBox; 75 FloatRect m_repaintBoundingBox; 76 OwnPtr<RenderImageResource> m_imageResource; 77 78 OwnPtr<ImageBuffer> m_bufferedForeground; 79 }; 80 81 DEFINE_RENDER_OBJECT_TYPE_CASTS(RenderSVGImage, isSVGImage()); 82 83 } // namespace WebCore 84 85 #endif // RenderSVGImage_h 86