#ifndef RenderImage_h
#define RenderImage_h
#include "core/rendering/RenderImageResource.h"
#include "core/rendering/RenderReplaced.h"
namespace WebCore {
class HTMLAreaElement;
class HTMLMapElement;
class RenderImage : public RenderReplaced {
public:
RenderImage(Element*);
virtual ~RenderImage();
static RenderImage* createAnonymous(Document*);
void setImageResource(PassOwnPtr<RenderImageResource>);
RenderImageResource* imageResource() { return m_imageResource.get(); }
const RenderImageResource* imageResource() const { return m_imageResource.get(); }
ImageResource* cachedImage() const { return m_imageResource ? m_imageResource->cachedImage() : 0; }
bool setImageSizeForAltText(ImageResource* newImage = 0);
void updateAltText();
HTMLMapElement* imageMap() const;
void areaElementFocusChanged(HTMLAreaElement*);
void highQualityRepaintTimerFired(Timer<RenderImage>*);
void setIsGeneratedContent(bool generated = true) { m_isGeneratedContent = generated; }
bool isGeneratedContent() const { return m_isGeneratedContent; }
String altText() const { return m_altText; }
inline void setImageDevicePixelRatio(float factor) { m_imageDevicePixelRatio = factor; }
float imageDevicePixelRatio() const { return m_imageDevicePixelRatio; }
protected:
virtual bool needsPreferredWidthsRecalculation() const OVERRIDE FINAL;
virtual RenderBox* embeddedContentBox() const OVERRIDE FINAL;
virtual void computeIntrinsicRatioInformation(FloatSize& intrinsicSize, double& intrinsicRatio, bool& isPercentageIntrinsicSize) const OVERRIDE FINAL;
virtual void styleDidChange(StyleDifference, const RenderStyle*) OVERRIDE FINAL;
virtual void imageChanged(WrappedImagePtr, const IntRect* = 0) OVERRIDE;
void paintIntoRect(GraphicsContext*, const LayoutRect&);
virtual void paint(PaintInfo&, const LayoutPoint&) OVERRIDE FINAL;
virtual void layout() OVERRIDE;
virtual bool updateImageLoadingPriorities() OVERRIDE FINAL;
virtual void intrinsicSizeChanged() OVERRIDE
{
if (m_imageResource)
imageChanged(m_imageResource->imagePtr());
}
private:
virtual const char* renderName() const OVERRIDE { return "RenderImage"; }
virtual bool isImage() const OVERRIDE { return true; }
virtual bool isRenderImage() const OVERRIDE FINAL { return true; }
virtual void paintReplaced(PaintInfo&, const LayoutPoint&) OVERRIDE;
virtual bool foregroundIsKnownToBeOpaqueInRect(const LayoutRect& localRect, unsigned maxDepthToTest) const OVERRIDE FINAL;
virtual bool computeBackgroundIsKnownToBeObscured() OVERRIDE FINAL;
virtual LayoutUnit minimumReplacedHeight() const OVERRIDE;
virtual void notifyFinished(Resource*) OVERRIDE FINAL;
virtual bool nodeAtPoint(const HitTestRequest&, HitTestResult&, const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOffset, HitTestAction) OVERRIDE FINAL;
virtual bool boxShadowShouldBeAppliedToBackground(BackgroundBleedAvoidance, InlineFlowBox*) const OVERRIDE FINAL;
IntSize imageSizeForError(ImageResource*) const;
void imageDimensionsChanged(bool imageSizeChanged, const IntRect* = 0);
bool updateIntrinsicSizeIfNeeded(const LayoutSize&, bool imageSizeChanged);
void updateInnerContentRect();
void paintAreaElementFocusRing(PaintInfo&);
String m_altText;
OwnPtr<RenderImageResource> m_imageResource;
bool m_didIncrementVisuallyNonEmptyPixelCount;
bool m_isGeneratedContent;
float m_imageDevicePixelRatio;
friend class RenderImageScaleObserver;
};
DEFINE_RENDER_OBJECT_TYPE_CASTS(RenderImage, isRenderImage());
}
#endif