24 #include "wtf/Platform.h"
29 #include "RenderPath.h"
35 SVGRectElement::SVGRectElement(
const QualifiedName& tagName, Document *doc)
36 : SVGStyledTransformableElement(tagName, doc)
39 , SVGExternalResourcesRequired()
40 , m_x(this, LengthModeWidth)
41 , m_y(this, LengthModeHeight)
42 , m_width(this, LengthModeWidth)
43 , m_height(this, LengthModeHeight)
44 , m_rx(this, LengthModeWidth)
45 , m_ry(this, LengthModeHeight)
49 SVGRectElement::~SVGRectElement()
53 ANIMATED_PROPERTY_DEFINITIONS(SVGRectElement, SVGLength, Length, length, X, x,
SVGNames::xAttr, m_x)
54 ANIMATED_PROPERTY_DEFINITIONS(SVGRectElement, SVGLength, Length, length, Y, y, SVGNames::
yAttr, m_y)
55 ANIMATED_PROPERTY_DEFINITIONS(SVGRectElement, SVGLength, Length, length, Width, width, SVGNames::
widthAttr, m_width)
56 ANIMATED_PROPERTY_DEFINITIONS(SVGRectElement, SVGLength, Length, length, Height, height, SVGNames::
heightAttr, m_height)
57 ANIMATED_PROPERTY_DEFINITIONS(SVGRectElement, SVGLength, Length, length, Rx, rx, SVGNames::
rxAttr, m_rx)
58 ANIMATED_PROPERTY_DEFINITIONS(SVGRectElement, SVGLength, Length, length, Ry, ry, SVGNames::
ryAttr, m_ry)
60 void SVGRectElement::parseMappedAttribute(MappedAttribute* attr)
62 kDebug() <<
"called with" << attr->localName() << attr->value() << endl;
64 setXBaseValue(SVGLength(
this, LengthModeWidth, attr->value()));
66 setYBaseValue(SVGLength(
this, LengthModeHeight, attr->value()));
68 setRxBaseValue(SVGLength(
this, LengthModeWidth, attr->value()));
69 if (rx().value() < 0.0)
70 document()->accessSVGExtensions()->reportError(
"A negative value for rect <rx> is not allowed");
72 setRyBaseValue(SVGLength(
this, LengthModeHeight, attr->value()));
73 if (ry().value() < 0.0)
74 document()->accessSVGExtensions()->reportError(
"A negative value for rect <ry> is not allowed");
76 setWidthBaseValue(SVGLength(
this, LengthModeWidth, attr->value()));
77 if (width().value() < 0.0)
78 document()->accessSVGExtensions()->reportError(
"A negative value for rect <width> is not allowed");
80 setHeightBaseValue(SVGLength(
this, LengthModeHeight, attr->value()));
81 if (height().value() < 0.0)
82 document()->accessSVGExtensions()->reportError(
"A negative value for rect <height> is not allowed");
84 if (SVGTests::parseMappedAttribute(attr))
86 if (SVGLangSpace::parseMappedAttribute(attr))
88 if (SVGExternalResourcesRequired::parseMappedAttribute(attr))
90 SVGStyledTransformableElement::parseMappedAttribute(attr);
94 void SVGRectElement::svgAttributeChanged(
const QualifiedName& attrName)
96 SVGStyledTransformableElement::svgAttributeChanged(attrName);
104 SVGTests::isKnownAttribute(attrName) ||
105 SVGLangSpace::isKnownAttribute(attrName) ||
106 SVGExternalResourcesRequired::isKnownAttribute(attrName) ||
107 SVGStyledTransformableElement::isKnownAttribute(attrName))
108 renderer()->setNeedsLayout(
true);
111 Path SVGRectElement::toPathData()
const
113 FloatRect rect(x().value(), y().value(), width().value(), height().value());
117 if (hasRx || hasRy) {
118 float _rx = hasRx ? rx().value() : ry().value();
119 float _ry = hasRy ? ry().value() : rx().value();
120 return Path::createRoundedRectangle(rect, FloatSize(_rx, _ry));
123 return Path::createRectangle(rect);
126 bool SVGRectElement::hasRelativeValues()
const
128 return (x().isRelative() || width().isRelative() ||
129 y().isRelative() || height().isRelative() ||
130 rx().isRelative() || ry().isRelative());
134 quint32 SVGRectElement::id()
const
141 #endif // ENABLE(SVG)
DOM::QualifiedName widthAttr
DOM::QualifiedName rxAttr
static QDebug kDebug(bool cond, int area=KDE_DEFAULT_DEBUG_AREA)
DOM::QualifiedName rectTag
DOM::QualifiedName heightAttr
DOM::QualifiedName ryAttr