25#if ENABLE(SVG) && ENABLE(SVG_FOREIGN_OBJECT)
28#include "CSSPropertyNames.h"
29#include "RenderForeignObject.h"
33#include <wtf/Assertions.h>
37SVGForeignObjectElement::SVGForeignObjectElement(
const QualifiedName& tagName, Document *doc)
38 : SVGStyledTransformableElement(tagName, doc)
41 , SVGExternalResourcesRequired()
42 , m_x(this, LengthModeWidth)
43 , m_y(this, LengthModeHeight)
44 , m_width(this, LengthModeWidth)
45 , m_height(this, LengthModeHeight)
49SVGForeignObjectElement::~SVGForeignObjectElement()
53ANIMATED_PROPERTY_DEFINITIONS(SVGForeignObjectElement, SVGLength, Length, length,
X, x, SVGNames::xAttr, m_x)
54ANIMATED_PROPERTY_DEFINITIONS(SVGForeignObjectElement, SVGLength, Length, length, Y, y, SVGNames::yAttr, m_y)
55ANIMATED_PROPERTY_DEFINITIONS(SVGForeignObjectElement, SVGLength, Length, length, Width, width, SVGNames::widthAttr, m_width)
56ANIMATED_PROPERTY_DEFINITIONS(SVGForeignObjectElement, SVGLength, Length, length, Height, height, SVGNames::heightAttr, m_height)
58void SVGForeignObjectElement::parseMappedAttribute(MappedAttribute* attr)
60 const AtomicString& value = attr->value();
61 if (attr->name() == SVGNames::xAttr)
62 setXBaseValue(SVGLength(
this, LengthModeWidth, value));
63 else if (attr->name() == SVGNames::yAttr)
64 setYBaseValue(SVGLength(
this, LengthModeHeight, value));
65 else if (attr->name() == SVGNames::widthAttr)
66 setWidthBaseValue(SVGLength(
this, LengthModeWidth, value));
67 else if (attr->name() == SVGNames::heightAttr)
68 setHeightBaseValue(SVGLength(
this, LengthModeHeight, value));
70 if (SVGTests::parseMappedAttribute(attr))
72 if (SVGLangSpace::parseMappedAttribute(attr))
74 if (SVGExternalResourcesRequired::parseMappedAttribute(attr))
76 SVGStyledTransformableElement::parseMappedAttribute(attr);
87static inline void addCSSPropertyAndNotifyAttributeMap(StyledElement* element,
const QualifiedName& name,
int cssProperty,
const String& value)
94 NamedMappedAttrMap* attrs = element->mappedAttributes();
100 MappedAttribute* mappedAttr = attrs->getAttributeItem(name);
105 MappedAttributeEntry entry;
106 bool needToParse = element->mapToEntry(mappedAttr->name(), entry);
109 ASSERT(entry == eNone);
111 if (!needToParse || entry != eNone)
114 if (mappedAttr->decl()) {
115 mappedAttr->setDecl(0);
116 attrs->declRemoved();
119 element->setChanged();
120 element->addCSSProperty(mappedAttr, cssProperty, value);
122 if (CSSMappedAttributeDeclaration* decl = mappedAttr->decl()) {
124 element->setMappedAttributeDecl(entry, mappedAttr, decl);
126 decl->setMappedState(entry, mappedAttr->name(), mappedAttr->value());
134void SVGForeignObjectElement::svgAttributeChanged(
const QualifiedName& attrName)
136 SVGStyledTransformableElement::svgAttributeChanged(attrName);
138 if (attrName == SVGNames::widthAttr) {
139 addCSSPropertyAndNotifyAttributeMap(
this, attrName, CSSPropertyWidth, width().valueAsString());
141 }
else if (attrName == SVGNames::heightAttr) {
142 addCSSPropertyAndNotifyAttributeMap(
this, attrName, CSSPropertyHeight, height().valueAsString());
149 if (attrName == SVGNames::xAttr || attrName == SVGNames::yAttr ||
150 SVGTests::isKnownAttribute(attrName) ||
151 SVGLangSpace::isKnownAttribute(attrName) ||
152 SVGExternalResourcesRequired::isKnownAttribute(attrName) ||
153 SVGStyledTransformableElement::isKnownAttribute(attrName))
154 renderer()->setNeedsLayout(
true);
157RenderObject* SVGForeignObjectElement::createRenderer(RenderArena* arena, RenderStyle* style)
159 return new (arena) RenderForeignObject(
this);
162bool SVGForeignObjectElement::childShouldCreateRenderer(Node* child)
const
165 return StyledElement::childShouldCreateRenderer(child);