25 #if ENABLE(SVG) && ENABLE(SVG_FOREIGN_OBJECT)
28 #include "CSSPropertyNames.h"
29 #include "RenderForeignObject.h"
33 #include <wtf/Assertions.h>
37 SVGForeignObjectElement::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)
49 SVGForeignObjectElement::~SVGForeignObjectElement()
53 ANIMATED_PROPERTY_DEFINITIONS(SVGForeignObjectElement, SVGLength, Length, length, X, x,
SVGNames::xAttr, m_x)
54 ANIMATED_PROPERTY_DEFINITIONS(SVGForeignObjectElement, SVGLength, Length, length, Y, y, SVGNames::
yAttr, m_y)
55 ANIMATED_PROPERTY_DEFINITIONS(SVGForeignObjectElement, SVGLength, Length, length, Width, width, SVGNames::
widthAttr, m_width)
56 ANIMATED_PROPERTY_DEFINITIONS(SVGForeignObjectElement, SVGLength, Length, length, Height, height, SVGNames::
heightAttr, m_height)
58 void SVGForeignObjectElement::parseMappedAttribute(MappedAttribute* attr)
60 const AtomicString& value = attr->value();
62 setXBaseValue(SVGLength(
this, LengthModeWidth, value));
64 setYBaseValue(SVGLength(
this, LengthModeHeight, value));
66 setWidthBaseValue(SVGLength(
this, LengthModeWidth, value));
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);
87 static 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());
134 void SVGForeignObjectElement::svgAttributeChanged(
const QualifiedName& attrName)
136 SVGStyledTransformableElement::svgAttributeChanged(attrName);
139 addCSSPropertyAndNotifyAttributeMap(
this, attrName, CSSPropertyWidth, width().valueAsString());
142 addCSSPropertyAndNotifyAttributeMap(
this, attrName, CSSPropertyHeight, height().valueAsString());
150 SVGTests::isKnownAttribute(attrName) ||
151 SVGLangSpace::isKnownAttribute(attrName) ||
152 SVGExternalResourcesRequired::isKnownAttribute(attrName) ||
153 SVGStyledTransformableElement::isKnownAttribute(attrName))
154 renderer()->setNeedsLayout(
true);
157 RenderObject* SVGForeignObjectElement::createRenderer(RenderArena* arena, RenderStyle* style)
159 return new (arena) RenderForeignObject(
this);
162 bool SVGForeignObjectElement::childShouldCreateRenderer(Node* child)
const
165 return StyledElement::childShouldCreateRenderer(child);
170 #endif // ENABLE(SVG) && ENABLE(SVG_FOREIGN_OBJECT)
DOM::QualifiedName widthAttr
DOM::QualifiedName heightAttr