This source file includes following definitions.
- m_fixedSize
- cssValue
- imageSize
- computeIntrinsicDimensions
- addClient
- removeClient
- image
- knownToBeOpaque
#include "config.h"
#include "core/rendering/style/StyleGeneratedImage.h"
#include "core/css/CSSImageGeneratorValue.h"
#include "core/css/resolver/StyleResolver.h"
#include "core/rendering/RenderObject.h"
namespace WebCore {
StyleGeneratedImage::StyleGeneratedImage(PassRefPtrWillBeRawPtr<CSSImageGeneratorValue> value)
: m_imageGeneratorValue(value)
, m_fixedSize(m_imageGeneratorValue->isFixedSize())
{
m_isGeneratedImage = true;
}
PassRefPtrWillBeRawPtr<CSSValue> StyleGeneratedImage::cssValue() const
{
return m_imageGeneratorValue.get();
}
LayoutSize StyleGeneratedImage::imageSize(const RenderObject* renderer, float multiplier) const
{
if (m_fixedSize) {
IntSize fixedSize = m_imageGeneratorValue->fixedSize(renderer);
if (multiplier == 1.0f)
return fixedSize;
LayoutUnit width = fixedSize.width() * multiplier;
LayoutUnit height = fixedSize.height() * multiplier;
if (fixedSize.width() > 0)
width = max<LayoutUnit>(1, width);
if (fixedSize.height() > 0)
height = max<LayoutUnit>(1, height);
return LayoutSize(width, height);
}
return m_containerSize;
}
void StyleGeneratedImage::computeIntrinsicDimensions(const RenderObject* renderer, Length& intrinsicWidth, Length& intrinsicHeight, FloatSize& intrinsicRatio)
{
IntSize size = flooredIntSize(imageSize(renderer, 1));
intrinsicWidth = Length(size.width(), Fixed);
intrinsicHeight = Length(size.height(), Fixed);
intrinsicRatio = size;
}
void StyleGeneratedImage::addClient(RenderObject* renderer)
{
m_imageGeneratorValue->addClient(renderer, IntSize());
}
void StyleGeneratedImage::removeClient(RenderObject* renderer)
{
m_imageGeneratorValue->removeClient(renderer);
}
PassRefPtr<Image> StyleGeneratedImage::image(RenderObject* renderer, const IntSize& size) const
{
return m_imageGeneratorValue->image(renderer, size);
}
bool StyleGeneratedImage::knownToBeOpaque(const RenderObject* renderer) const
{
return m_imageGeneratorValue->knownToBeOpaque(renderer);
}
}