#ifndef SVGImage_h
#define SVGImage_h
#include "Image.h"
#include "URL.h"
namespace WebCore {
class Element;
class FrameLoader;
class FrameView;
class ImageBuffer;
class Page;
class RenderBox;
class SVGSVGElement;
class SVGFrameLoaderClient;
class SVGImageChromeClient;
class SVGImageForContainer;
class SVGImage final : public Image {
public:
static Ref<SVGImage> create(ImageObserver& observer, const URL& url)
{
return adoptRef(*new SVGImage(observer, url));
}
RenderBox* embeddedContentBox() const;
FrameView* frameView() const;
virtual bool isSVGImage() const override { return true; }
virtual FloatSize size() const override { return m_intrinsicSize; }
void setURL(const URL& url) { m_url = url; }
void setDataProtocolLoader(FrameLoader* dataProtocolLoader) { m_dataProtocolLoader = dataProtocolLoader; }
virtual bool hasSingleSecurityOrigin() const override;
virtual bool hasRelativeWidth() const override;
virtual bool hasRelativeHeight() const override;
virtual void startAnimation(CatchUpAnimation = CatchUp) override;
virtual void stopAnimation() override;
virtual void resetAnimation() override;
#if USE(CAIRO)
virtual PassNativeImagePtr nativeImageForCurrentFrame() override;
#endif
private:
friend class SVGImageChromeClient;
friend class SVGImageForContainer;
virtual ~SVGImage();
virtual String filenameExtension() const override;
virtual void setContainerSize(const FloatSize&) 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;
void reportApproximateMemoryCost() const;
virtual void destroyDecodedData(bool) override { }
virtual bool currentFrameKnownToBeOpaque() override { return false; }
SVGImage(ImageObserver&, const URL&);
virtual void draw(GraphicsContext*, const FloatRect& dstRect, const FloatRect& srcRect, ColorSpace styleColorSpace, CompositeOperator, BlendMode, ImageOrientationDescription) override;
void drawForContainer(GraphicsContext*, const FloatSize, float, const FloatRect&, const FloatRect&, ColorSpace, CompositeOperator, BlendMode);
void drawPatternForContainer(GraphicsContext*, const FloatSize& containerSize, float zoom, const FloatRect& srcRect, const AffineTransform&, const FloatPoint& phase, const FloatSize& spacing, ColorSpace,
CompositeOperator, const FloatRect&, BlendMode);
SVGSVGElement* rootElement() const;
std::unique_ptr<SVGFrameLoaderClient> m_loaderClient;
std::unique_ptr<SVGImageChromeClient> m_chromeClient;
std::unique_ptr<Page> m_page;
FloatSize m_intrinsicSize;
URL m_url;
FrameLoader* m_dataProtocolLoader { nullptr };
};
bool isInSVGImage(const Element*);
}
SPECIALIZE_TYPE_TRAITS_IMAGE(SVGImage)
#endif // SVGImage_h