#ifndef SVGImage_h
#define SVGImage_h
#include "platform/graphics/Image.h"
namespace WebCore {
class Element;
class FrameView;
class ImageBuffer;
class Page;
class RenderBox;
class SVGImageChromeClient;
class SVGImageForContainer;
class SVGImage FINAL : public Image {
public:
static PassRefPtr<SVGImage> create(ImageObserver* observer)
{
return adoptRef(new SVGImage(observer));
}
static bool isInSVGImage(const Element*);
RenderBox* embeddedContentBox() const;
virtual bool isSVGImage() const OVERRIDE { return true; }
virtual IntSize size() const OVERRIDE { return m_intrinsicSize; }
virtual bool currentFrameHasSingleSecurityOrigin() const OVERRIDE;
virtual bool hasRelativeWidth() const OVERRIDE;
virtual bool hasRelativeHeight() const OVERRIDE;
virtual void startAnimation(bool = true) OVERRIDE;
virtual void stopAnimation() OVERRIDE;
virtual void resetAnimation() OVERRIDE;
virtual PassRefPtr<NativeImageSkia> nativeImageForCurrentFrame() OVERRIDE;
FrameView* frameView() const;
bool hasAnimations() const;
private:
friend class AXRenderObject;
friend class SVGImageChromeClient;
friend class SVGImageForContainer;
virtual ~SVGImage();
virtual String filenameExtension() const OVERRIDE;
virtual void setContainerSize(const IntSize&) OVERRIDE;
IntSize containerSize() const;
virtual bool usesContainerSize() const OVERRIDE { return true; }
virtual void computeIntrinsicDimensions(Length& intrinsicWidth, Length& intrinsicHeight, FloatSize& intrinsicRatio) OVERRIDE;
virtual bool dataChanged(bool allDataReceived) OVERRIDE;
virtual void destroyDecodedData(bool) OVERRIDE { }
virtual bool currentFrameKnownToBeOpaque() OVERRIDE { return false; }
SVGImage(ImageObserver*);
virtual void draw(GraphicsContext*, const FloatRect& fromRect, const FloatRect& toRect, CompositeOperator, blink::WebBlendMode) OVERRIDE;
void drawForContainer(GraphicsContext*, const FloatSize, float, const FloatRect&, const FloatRect&, CompositeOperator, blink::WebBlendMode);
void drawPatternForContainer(GraphicsContext*, const FloatSize, float, const FloatRect&, const FloatSize&, const FloatPoint&,
CompositeOperator, const FloatRect&, blink::WebBlendMode, const IntSize& repeatSpacing);
OwnPtr<SVGImageChromeClient> m_chromeClient;
OwnPtr<Page> m_page;
IntSize m_intrinsicSize;
};
DEFINE_IMAGE_TYPE_CASTS(SVGImage);
class ImageObserverDisabler {
WTF_MAKE_NONCOPYABLE(ImageObserverDisabler);
public:
ImageObserverDisabler(Image* image)
: m_image(image)
{
ASSERT(m_image->imageObserver());
m_observer = m_image->imageObserver();
m_image->setImageObserver(0);
}
~ImageObserverDisabler()
{
m_image->setImageObserver(m_observer);
}
private:
Image* m_image;
ImageObserver* m_observer;
};
}
#endif