*/
#include "config.h"
-
#include "core/svg/SVGRectElement.h"
-#include "SVGNames.h"
#include "core/rendering/svg/RenderSVGRect.h"
-#include "core/rendering/svg/RenderSVGResource.h"
-#include "core/svg/SVGElementInstance.h"
#include "core/svg/SVGLength.h"
-namespace WebCore {
-
-// Animated property definitions
-DEFINE_ANIMATED_LENGTH(SVGRectElement, SVGNames::xAttr, X, x)
-DEFINE_ANIMATED_LENGTH(SVGRectElement, SVGNames::yAttr, Y, y)
-DEFINE_ANIMATED_LENGTH(SVGRectElement, SVGNames::widthAttr, Width, width)
-DEFINE_ANIMATED_LENGTH(SVGRectElement, SVGNames::heightAttr, Height, height)
-DEFINE_ANIMATED_LENGTH(SVGRectElement, SVGNames::rxAttr, Rx, rx)
-DEFINE_ANIMATED_LENGTH(SVGRectElement, SVGNames::ryAttr, Ry, ry)
-DEFINE_ANIMATED_BOOLEAN(SVGRectElement, SVGNames::externalResourcesRequiredAttr, ExternalResourcesRequired, externalResourcesRequired)
-
-BEGIN_REGISTER_ANIMATED_PROPERTIES(SVGRectElement)
- REGISTER_LOCAL_ANIMATED_PROPERTY(x)
- REGISTER_LOCAL_ANIMATED_PROPERTY(y)
- REGISTER_LOCAL_ANIMATED_PROPERTY(width)
- REGISTER_LOCAL_ANIMATED_PROPERTY(height)
- REGISTER_LOCAL_ANIMATED_PROPERTY(rx)
- REGISTER_LOCAL_ANIMATED_PROPERTY(ry)
- REGISTER_LOCAL_ANIMATED_PROPERTY(externalResourcesRequired)
- REGISTER_PARENT_ANIMATED_PROPERTIES(SVGGraphicsElement)
-END_REGISTER_ANIMATED_PROPERTIES
-
-inline SVGRectElement::SVGRectElement(const QualifiedName& tagName, Document& document)
- : SVGGraphicsElement(tagName, document)
- , m_x(LengthModeWidth)
- , m_y(LengthModeHeight)
- , m_width(LengthModeWidth)
- , m_height(LengthModeHeight)
- , m_rx(LengthModeWidth)
- , m_ry(LengthModeHeight)
-{
- ASSERT(hasTagName(SVGNames::rectTag));
- ScriptWrappable::init(this);
- registerAnimatedPropertiesForSVGRectElement();
-}
+namespace blink {
-PassRefPtr<SVGRectElement> SVGRectElement::create(const QualifiedName& tagName, Document& document)
+inline SVGRectElement::SVGRectElement(Document& document)
+ : SVGGeometryElement(SVGNames::rectTag, document)
+ , m_x(SVGAnimatedLength::create(this, SVGNames::xAttr, SVGLength::create(LengthModeWidth), AllowNegativeLengths))
+ , m_y(SVGAnimatedLength::create(this, SVGNames::yAttr, SVGLength::create(LengthModeHeight), AllowNegativeLengths))
+ , m_width(SVGAnimatedLength::create(this, SVGNames::widthAttr, SVGLength::create(LengthModeWidth), ForbidNegativeLengths))
+ , m_height(SVGAnimatedLength::create(this, SVGNames::heightAttr, SVGLength::create(LengthModeHeight), ForbidNegativeLengths))
+ , m_rx(SVGAnimatedLength::create(this, SVGNames::rxAttr, SVGLength::create(LengthModeWidth), ForbidNegativeLengths))
+ , m_ry(SVGAnimatedLength::create(this, SVGNames::ryAttr, SVGLength::create(LengthModeHeight), ForbidNegativeLengths))
{
- return adoptRef(new SVGRectElement(tagName, document));
+ addToPropertyMap(m_x);
+ addToPropertyMap(m_y);
+ addToPropertyMap(m_width);
+ addToPropertyMap(m_height);
+ addToPropertyMap(m_rx);
+ addToPropertyMap(m_ry);
}
+DEFINE_NODE_FACTORY(SVGRectElement)
+
bool SVGRectElement::isSupportedAttribute(const QualifiedName& attrName)
{
DEFINE_STATIC_LOCAL(HashSet<QualifiedName>, supportedAttributes, ());
if (supportedAttributes.isEmpty()) {
- SVGLangSpace::addSupportedAttributes(supportedAttributes);
- SVGExternalResourcesRequired::addSupportedAttributes(supportedAttributes);
supportedAttributes.add(SVGNames::xAttr);
supportedAttributes.add(SVGNames::yAttr);
supportedAttributes.add(SVGNames::widthAttr);
void SVGRectElement::parseAttribute(const QualifiedName& name, const AtomicString& value)
{
- SVGParsingError parseError = NoError;
-
- if (!isSupportedAttribute(name))
- SVGGraphicsElement::parseAttribute(name, value);
- else if (name == SVGNames::xAttr)
- setXBaseValue(SVGLength::construct(LengthModeWidth, value, parseError));
- else if (name == SVGNames::yAttr)
- setYBaseValue(SVGLength::construct(LengthModeHeight, value, parseError));
- else if (name == SVGNames::rxAttr)
- setRxBaseValue(SVGLength::construct(LengthModeWidth, value, parseError, ForbidNegativeLengths));
- else if (name == SVGNames::ryAttr)
- setRyBaseValue(SVGLength::construct(LengthModeHeight, value, parseError, ForbidNegativeLengths));
- else if (name == SVGNames::widthAttr)
- setWidthBaseValue(SVGLength::construct(LengthModeWidth, value, parseError, ForbidNegativeLengths));
- else if (name == SVGNames::heightAttr)
- setHeightBaseValue(SVGLength::construct(LengthModeHeight, value, parseError, ForbidNegativeLengths));
- else if (SVGLangSpace::parseAttribute(name, value)
- || SVGExternalResourcesRequired::parseAttribute(name, value)) {
- } else
- ASSERT_NOT_REACHED();
-
- reportAttributeParsingError(parseError, name, value);
+ parseAttributeNew(name, value);
}
void SVGRectElement::svgAttributeChanged(const QualifiedName& attrName)
{
if (!isSupportedAttribute(attrName)) {
- SVGGraphicsElement::svgAttributeChanged(attrName);
+ SVGGeometryElement::svgAttributeChanged(attrName);
return;
}
- SVGElementInstance::InvalidationGuard invalidationGuard(this);
+ SVGElement::InvalidationGuard invalidationGuard(this);
bool isLengthAttribute = attrName == SVGNames::xAttr
|| attrName == SVGNames::yAttr
if (isLengthAttribute) {
renderer->setNeedsShapeUpdate();
- RenderSVGResource::markForLayoutAndParentResourceInvalidation(renderer);
- return;
- }
-
- if (SVGLangSpace::isKnownAttribute(attrName) || SVGExternalResourcesRequired::isKnownAttribute(attrName)) {
- RenderSVGResource::markForLayoutAndParentResourceInvalidation(renderer);
+ markForLayoutAndParentResourceInvalidation(renderer);
return;
}
bool SVGRectElement::selfHasRelativeLengths() const
{
- return xCurrentValue().isRelative()
- || yCurrentValue().isRelative()
- || widthCurrentValue().isRelative()
- || heightCurrentValue().isRelative()
- || rxCurrentValue().isRelative()
- || ryCurrentValue().isRelative();
+ return m_x->currentValue()->isRelative()
+ || m_y->currentValue()->isRelative()
+ || m_width->currentValue()->isRelative()
+ || m_height->currentValue()->isRelative()
+ || m_rx->currentValue()->isRelative()
+ || m_ry->currentValue()->isRelative();
}
RenderObject* SVGRectElement::createRenderer(RenderStyle*)
return new RenderSVGRect(this);
}
-}
+} // namespace blink