This source file includes following definitions.
- customCSSText
- canvasChanged
- canvasResized
- canvasDestroyed
- fixedSize
- element
- image
- equals
#include "config.h"
#include "core/css/CSSCanvasValue.h"
#include "core/rendering/RenderObject.h"
#include "wtf/text/StringBuilder.h"
namespace WebCore {
CSSCanvasValue::~CSSCanvasValue()
{
if (m_element)
m_element->removeObserver(&m_canvasObserver);
}
String CSSCanvasValue::customCSSText() const
{
StringBuilder result;
result.appendLiteral("-webkit-canvas(");
result.append(m_name);
result.append(')');
return result.toString();
}
void CSSCanvasValue::canvasChanged(HTMLCanvasElement*, const FloatRect& changedRect)
{
IntRect imageChangeRect = enclosingIntRect(changedRect);
RenderObjectSizeCountMap::const_iterator end = clients().end();
for (RenderObjectSizeCountMap::const_iterator curr = clients().begin(); curr != end; ++curr)
const_cast<RenderObject*>(curr->key)->imageChanged(static_cast<WrappedImagePtr>(this), &imageChangeRect);
}
void CSSCanvasValue::canvasResized(HTMLCanvasElement*)
{
RenderObjectSizeCountMap::const_iterator end = clients().end();
for (RenderObjectSizeCountMap::const_iterator curr = clients().begin(); curr != end; ++curr)
const_cast<RenderObject*>(curr->key)->imageChanged(static_cast<WrappedImagePtr>(this));
}
void CSSCanvasValue::canvasDestroyed(HTMLCanvasElement* element)
{
ASSERT_UNUSED(element, element == m_element);
m_element = 0;
}
IntSize CSSCanvasValue::fixedSize(const RenderObject* renderer)
{
if (HTMLCanvasElement* elt = element(&renderer->document()))
return IntSize(elt->width(), elt->height());
return IntSize();
}
HTMLCanvasElement* CSSCanvasValue::element(Document* document)
{
if (!m_element) {
m_element = &document->getCSSCanvasElement(m_name);
m_element->addObserver(&m_canvasObserver);
}
return m_element;
}
PassRefPtr<Image> CSSCanvasValue::image(RenderObject* renderer, const IntSize& )
{
ASSERT(clients().contains(renderer));
HTMLCanvasElement* elt = element(&renderer->document());
if (!elt || !elt->buffer())
return nullptr;
return elt->copiedImage();
}
bool CSSCanvasValue::equals(const CSSCanvasValue& other) const
{
return m_name == other.m_name;
}
}