SVGForeignObjectElement.cpp [plain text]
#include "config.h"
#if SVG_SUPPORT
#include "SVGForeignObjectElement.h"
#include "SVGNames.h"
#include "SVGHelper.h"
#include "SVGAnimatedLength.h"
#include "RenderForeignObject.h"
#include <wtf/Assertions.h>
#include "CSSPropertyNames.h"
namespace WebCore {
SVGForeignObjectElement::SVGForeignObjectElement(const QualifiedName& tagName, Document *doc)
: SVGStyledTransformableElement(tagName, doc), SVGTests(), SVGLangSpace(), SVGExternalResourcesRequired()
{
}
SVGForeignObjectElement::~SVGForeignObjectElement()
{
}
SVGAnimatedLength *SVGForeignObjectElement::x() const
{
return lazy_create<SVGAnimatedLength>(m_x, this, LM_WIDTH, viewportElement());
}
SVGAnimatedLength *SVGForeignObjectElement::y() const
{
return lazy_create<SVGAnimatedLength>(m_y, this, LM_HEIGHT, viewportElement());
}
SVGAnimatedLength *SVGForeignObjectElement::width() const
{
return lazy_create<SVGAnimatedLength>(m_width, this, LM_WIDTH, viewportElement());
}
SVGAnimatedLength *SVGForeignObjectElement::height() const
{
return lazy_create<SVGAnimatedLength>(m_height, this, LM_HEIGHT, viewportElement());
}
void SVGForeignObjectElement::parseMappedAttribute(MappedAttribute *attr)
{
const AtomicString& value = attr->value();
if (attr->name() == SVGNames::xAttr)
x()->baseVal()->setValueAsString(value.impl());
else if (attr->name() == SVGNames::yAttr)
y()->baseVal()->setValueAsString(value.impl());
else if (attr->name() == SVGNames::widthAttr) {
width()->baseVal()->setValueAsString(value.impl());
addCSSProperty(attr, CSS_PROP_WIDTH, value);
} else if (attr->name() == SVGNames::heightAttr) {
height()->baseVal()->setValueAsString(value.impl());
addCSSProperty(attr, CSS_PROP_HEIGHT, value);
} else {
if (SVGTests::parseMappedAttribute(attr))
return;
if (SVGLangSpace::parseMappedAttribute(attr))
return;
if (SVGExternalResourcesRequired::parseMappedAttribute(attr))
return;
SVGStyledTransformableElement::parseMappedAttribute(attr);
}
}
RenderObject *SVGForeignObjectElement::createRenderer(RenderArena *arena, RenderStyle *style)
{
return new (arena) RenderForeignObject(this);
}
bool SVGForeignObjectElement::childShouldCreateRenderer(Node *child) const
{
return StyledElement::childShouldCreateRenderer(child);
}
};
#endif // SVG_SUPPORT