This source file includes following definitions.
- m_cachedImage
- initialize
- shutdown
- setImageResource
- resetAnimation
- setContainerSizeForRenderer
- getImageSize
#include "config.h"
#include "core/rendering/RenderImageResource.h"
#include "core/rendering/RenderImage.h"
#include "core/rendering/RenderObject.h"
namespace WebCore {
RenderImageResource::RenderImageResource()
: m_renderer(0)
, m_cachedImage(0)
{
}
RenderImageResource::~RenderImageResource()
{
}
void RenderImageResource::initialize(RenderObject* renderer)
{
ASSERT(!m_renderer);
ASSERT(renderer);
m_renderer = renderer;
}
void RenderImageResource::shutdown()
{
ASSERT(m_renderer);
if (m_cachedImage)
m_cachedImage->removeClient(m_renderer);
}
void RenderImageResource::setImageResource(ImageResource* newImage)
{
ASSERT(m_renderer);
if (m_cachedImage == newImage)
return;
if (m_cachedImage)
m_cachedImage->removeClient(m_renderer);
m_cachedImage = newImage;
if (m_cachedImage) {
m_cachedImage->addClient(m_renderer);
if (m_cachedImage->errorOccurred())
m_renderer->imageChanged(m_cachedImage.get());
} else {
m_renderer->imageChanged(m_cachedImage.get());
}
}
void RenderImageResource::resetAnimation()
{
ASSERT(m_renderer);
if (!m_cachedImage)
return;
image()->resetAnimation();
if (!m_renderer->needsLayout())
m_renderer->repaint();
}
void RenderImageResource::setContainerSizeForRenderer(const IntSize& imageContainerSize)
{
ASSERT(m_renderer);
if (m_cachedImage)
m_cachedImage->setContainerSizeForRenderer(m_renderer, imageContainerSize, m_renderer->style()->effectiveZoom());
}
LayoutSize RenderImageResource::getImageSize(float multiplier, ImageResource::SizeType type) const
{
if (!m_cachedImage)
return LayoutSize();
LayoutSize size = m_cachedImage->imageSizeForRenderer(m_renderer, multiplier, type);
if (m_renderer && m_renderer->isRenderImage())
size.scale(toRenderImage(m_renderer)->imageDevicePixelRatio());
return size;
}
}