29 #include "CSSPropertyNames.h"
30 #include "RenderSVGImage.h"
40 SVGImageElement::SVGImageElement(
const QualifiedName& tagName, Document* doc)
41 : SVGStyledTransformableElement(tagName, doc)
44 , SVGExternalResourcesRequired()
46 , m_x(this, LengthModeWidth)
47 , m_y(this, LengthModeHeight)
48 , m_width(this, LengthModeWidth)
49 , m_height(this, LengthModeHeight)
50 , m_preserveAspectRatio(SVGPreserveAspectRatio::
create())
55 SVGImageElement::~SVGImageElement()
59 ANIMATED_PROPERTY_DEFINITIONS(SVGImageElement, SVGLength, Length, length, X, x,
SVGNames::xAttr, m_x)
60 ANIMATED_PROPERTY_DEFINITIONS(SVGImageElement, SVGLength, Length, length, Y, y, SVGNames::
yAttr, m_y)
61 ANIMATED_PROPERTY_DEFINITIONS(SVGImageElement, SVGLength, Length, length, Width, width, SVGNames::
widthAttr, m_width)
62 ANIMATED_PROPERTY_DEFINITIONS(SVGImageElement, SVGLength, Length, length, Height, height, SVGNames::
heightAttr, m_height)
63 ANIMATED_PROPERTY_DEFINITIONS(SVGImageElement, SVGPreserveAspectRatio*, PreserveAspectRatio, preserveAspectRatio, PreserveAspectRatio, preserveAspectRatio, SVGNames::
preserveAspectRatioAttr, m_preserveAspectRatio.get())
65 void SVGImageElement::parseMappedAttribute(MappedAttribute *attr)
68 setXBaseValue(SVGLength(
this, LengthModeWidth, attr->value()));
70 setYBaseValue(SVGLength(
this, LengthModeHeight, attr->value()));
72 const UChar* c = attr->value().characters();
73 const UChar*
end = c + attr->value().length();
74 preserveAspectRatioBaseValue()->parsePreserveAspectRatio(c, end);
76 setWidthBaseValue(SVGLength(
this, LengthModeWidth, attr->value()));
77 addCSSProperty(attr, CSSPropertyWidth, attr->value());
78 if (width().value() < 0.0)
79 document()->accessSVGExtensions()->reportError(
"A negative value for image attribute <width> is not allowed");
81 setHeightBaseValue(SVGLength(
this, LengthModeHeight, attr->value()));
82 addCSSProperty(attr, CSSPropertyHeight, attr->value());
83 if (height().value() < 0.0)
84 document()->accessSVGExtensions()->reportError(
"A negative value for image attribute <height> is not allowed");
86 if (SVGTests::parseMappedAttribute(attr))
88 if (SVGLangSpace::parseMappedAttribute(attr))
90 if (SVGExternalResourcesRequired::parseMappedAttribute(attr))
92 if (SVGURIReference::parseMappedAttribute(attr))
94 SVGStyledTransformableElement::parseMappedAttribute(attr);
98 void SVGImageElement::svgAttributeChanged(
const QualifiedName& attrName)
100 SVGStyledTransformableElement::svgAttributeChanged(attrName);
105 bool isURIAttribute = SVGURIReference::isKnownAttribute(attrName);
109 SVGTests::isKnownAttribute(attrName) ||
110 SVGLangSpace::isKnownAttribute(attrName) ||
111 SVGExternalResourcesRequired::isKnownAttribute(attrName) ||
113 SVGStyledTransformableElement::isKnownAttribute(attrName)) {
114 renderer()->setNeedsLayout(
true);
117 m_imageLoader.updateFromElement();
121 bool SVGImageElement::hasRelativeValues()
const
123 return (x().isRelative() || width().isRelative() ||
124 y().isRelative() || height().isRelative());
127 RenderObject* SVGImageElement::createRenderer(RenderArena* arena, RenderStyle* style)
129 return new (arena) RenderSVGImage(
this);
132 bool SVGImageElement::haveLoadedRequiredResources()
134 return !externalResourcesRequiredBaseValue() || m_imageLoader.haveFiredLoadEvent();
137 void SVGImageElement::attach()
139 SVGStyledTransformableElement::attach();
140 m_imageLoader.updateFromElement();
141 if (RenderSVGImage* imageObj = static_cast<RenderSVGImage*>(renderer()))
142 imageObj->setCachedImage(m_imageLoader.image());
145 void SVGImageElement::getSubresourceAttributeStrings(Vector<String>& urls)
const
152 #endif // ENABLE(SVG)
DOM::QualifiedName widthAttr
DOM::QualifiedName preserveAspectRatioAttr
DOM::QualifiedName heightAttr
KAction * create(StandardAction id, const QObject *recvr, const char *slot, QObject *parent)