SVGForeignObjectElement.cpp [plain text]
#include "config.h"
#if ENABLE(SVG) && ENABLE(SVG_FOREIGN_OBJECT)
#include "SVGForeignObjectElement.h"
#include "CSSPropertyNames.h"
#include "MappedAttribute.h"
#include "RenderForeignObject.h"
#include "SVGLength.h"
#include "SVGNames.h"
#include <wtf/Assertions.h>
namespace WebCore {
SVGForeignObjectElement::SVGForeignObjectElement(const QualifiedName& tagName, Document *doc)
: SVGStyledTransformableElement(tagName, doc)
, SVGTests()
, SVGLangSpace()
, SVGExternalResourcesRequired()
, m_x(LengthModeWidth)
, m_y(LengthModeHeight)
, m_width(LengthModeWidth)
, m_height(LengthModeHeight)
{
}
SVGForeignObjectElement::~SVGForeignObjectElement()
{
}
void SVGForeignObjectElement::parseMappedAttribute(MappedAttribute* attr)
{
const AtomicString& value = attr->value();
if (attr->name() == SVGNames::xAttr)
setXBaseValue(SVGLength(LengthModeWidth, value));
else if (attr->name() == SVGNames::yAttr)
setYBaseValue(SVGLength(LengthModeHeight, value));
else if (attr->name() == SVGNames::widthAttr)
setWidthBaseValue(SVGLength(LengthModeWidth, value));
else if (attr->name() == SVGNames::heightAttr)
setHeightBaseValue(SVGLength(LengthModeHeight, value));
else {
if (SVGTests::parseMappedAttribute(attr))
return;
if (SVGLangSpace::parseMappedAttribute(attr))
return;
if (SVGExternalResourcesRequired::parseMappedAttribute(attr))
return;
SVGStyledTransformableElement::parseMappedAttribute(attr);
}
}
void SVGForeignObjectElement::svgAttributeChanged(const QualifiedName& attrName)
{
SVGStyledTransformableElement::svgAttributeChanged(attrName);
RenderObject* renderer = this->renderer();
if (!renderer)
return;
if (SVGStyledTransformableElement::isKnownAttribute(attrName)) {
renderer->setNeedsTransformUpdate();
renderer->setNeedsLayout(true);
return;
}
if (attrName == SVGNames::xAttr
|| attrName == SVGNames::yAttr
|| attrName == SVGNames::widthAttr
|| attrName == SVGNames::heightAttr
|| SVGTests::isKnownAttribute(attrName)
|| SVGLangSpace::isKnownAttribute(attrName)
|| SVGExternalResourcesRequired::isKnownAttribute(attrName))
renderer->setNeedsLayout(true);
}
void SVGForeignObjectElement::synchronizeProperty(const QualifiedName& attrName)
{
SVGStyledTransformableElement::synchronizeProperty(attrName);
if (attrName == anyQName()) {
synchronizeX();
synchronizeY();
synchronizeWidth();
synchronizeHeight();
synchronizeExternalResourcesRequired();
synchronizeHref();
return;
}
if (attrName == SVGNames::xAttr)
synchronizeX();
else if (attrName == SVGNames::yAttr)
synchronizeY();
else if (attrName == SVGNames::widthAttr)
synchronizeWidth();
else if (attrName == SVGNames::heightAttr)
synchronizeHeight();
else if (SVGExternalResourcesRequired::isKnownAttribute(attrName))
synchronizeExternalResourcesRequired();
else if (SVGURIReference::isKnownAttribute(attrName))
synchronizeHref();
}
RenderObject* SVGForeignObjectElement::createRenderer(RenderArena* arena, RenderStyle*)
{
return new (arena) RenderForeignObject(this);
}
bool SVGForeignObjectElement::childShouldCreateRenderer(Node* child) const
{
return StyledElement::childShouldCreateRenderer(child);
}
}
#endif