This source file includes following definitions.
- m_ry
- create
- isSupportedAttribute
- parseAttribute
- svgAttributeChanged
- selfHasRelativeLengths
- createRenderer
#include "config.h"
#include "core/svg/SVGRectElement.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 {
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))
{
ScriptWrappable::init(this);
addToPropertyMap(m_x);
addToPropertyMap(m_y);
addToPropertyMap(m_width);
addToPropertyMap(m_height);
addToPropertyMap(m_rx);
addToPropertyMap(m_ry);
}
PassRefPtr<SVGRectElement> SVGRectElement::create(Document& document)
{
return adoptRef(new SVGRectElement(document));
}
bool SVGRectElement::isSupportedAttribute(const QualifiedName& attrName)
{
DEFINE_STATIC_LOCAL(HashSet<QualifiedName>, supportedAttributes, ());
if (supportedAttributes.isEmpty()) {
supportedAttributes.add(SVGNames::xAttr);
supportedAttributes.add(SVGNames::yAttr);
supportedAttributes.add(SVGNames::widthAttr);
supportedAttributes.add(SVGNames::heightAttr);
supportedAttributes.add(SVGNames::rxAttr);
supportedAttributes.add(SVGNames::ryAttr);
}
return supportedAttributes.contains<SVGAttributeHashTranslator>(attrName);
}
void SVGRectElement::parseAttribute(const QualifiedName& name, const AtomicString& value)
{
SVGParsingError parseError = NoError;
if (!isSupportedAttribute(name))
SVGGeometryElement::parseAttribute(name, value);
else if (name == SVGNames::xAttr)
m_x->setBaseValueAsString(value, parseError);
else if (name == SVGNames::yAttr)
m_y->setBaseValueAsString(value, parseError);
else if (name == SVGNames::rxAttr)
m_rx->setBaseValueAsString(value, parseError);
else if (name == SVGNames::ryAttr)
m_ry->setBaseValueAsString(value, parseError);
else if (name == SVGNames::widthAttr)
m_width->setBaseValueAsString(value, parseError);
else if (name == SVGNames::heightAttr)
m_height->setBaseValueAsString(value, parseError);
else
ASSERT_NOT_REACHED();
reportAttributeParsingError(parseError, name, value);
}
void SVGRectElement::svgAttributeChanged(const QualifiedName& attrName)
{
if (!isSupportedAttribute(attrName)) {
SVGGeometryElement::svgAttributeChanged(attrName);
return;
}
SVGElementInstance::InvalidationGuard invalidationGuard(this);
bool isLengthAttribute = attrName == SVGNames::xAttr
|| attrName == SVGNames::yAttr
|| attrName == SVGNames::widthAttr
|| attrName == SVGNames::heightAttr
|| attrName == SVGNames::rxAttr
|| attrName == SVGNames::ryAttr;
if (isLengthAttribute)
updateRelativeLengthsInformation();
RenderSVGShape* renderer = toRenderSVGShape(this->renderer());
if (!renderer)
return;
if (isLengthAttribute) {
renderer->setNeedsShapeUpdate();
RenderSVGResource::markForLayoutAndParentResourceInvalidation(renderer);
return;
}
ASSERT_NOT_REACHED();
}
bool SVGRectElement::selfHasRelativeLengths() const
{
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);
}
}