#include "config.h"
#if ENABLE(SVG)
#include "SVGGElement.h"
#include "RenderSVGHiddenContainer.h"
#include "RenderSVGResource.h"
#include "RenderSVGTransformableContainer.h"
#include "SVGElementInstance.h"
#include "SVGNames.h"
namespace WebCore {
DEFINE_ANIMATED_BOOLEAN(SVGGElement, SVGNames::externalResourcesRequiredAttr, ExternalResourcesRequired, externalResourcesRequired)
BEGIN_REGISTER_ANIMATED_PROPERTIES(SVGGElement)
REGISTER_LOCAL_ANIMATED_PROPERTY(externalResourcesRequired)
REGISTER_PARENT_ANIMATED_PROPERTIES(SVGStyledTransformableElement)
REGISTER_PARENT_ANIMATED_PROPERTIES(SVGTests)
END_REGISTER_ANIMATED_PROPERTIES
SVGGElement::SVGGElement(const QualifiedName& tagName, Document* document, ConstructionType constructionType)
: SVGStyledTransformableElement(tagName, document, constructionType)
{
ASSERT(hasTagName(SVGNames::gTag));
registerAnimatedPropertiesForSVGGElement();
}
PassRefPtr<SVGGElement> SVGGElement::create(const QualifiedName& tagName, Document* document)
{
return adoptRef(new SVGGElement(tagName, document));
}
bool SVGGElement::isSupportedAttribute(const QualifiedName& attrName)
{
DEFINE_STATIC_LOCAL(HashSet<QualifiedName>, supportedAttributes, ());
if (supportedAttributes.isEmpty()) {
SVGTests::addSupportedAttributes(supportedAttributes);
SVGLangSpace::addSupportedAttributes(supportedAttributes);
SVGExternalResourcesRequired::addSupportedAttributes(supportedAttributes);
}
return supportedAttributes.contains<QualifiedName, SVGAttributeHashTranslator>(attrName);
}
void SVGGElement::parseAttribute(Attribute* attr)
{
if (!isSupportedAttribute(attr->name())) {
SVGStyledTransformableElement::parseAttribute(attr);
return;
}
if (SVGTests::parseAttribute(attr))
return;
if (SVGLangSpace::parseAttribute(attr))
return;
if (SVGExternalResourcesRequired::parseAttribute(attr))
return;
ASSERT_NOT_REACHED();
}
void SVGGElement::svgAttributeChanged(const QualifiedName& attrName)
{
if (!isSupportedAttribute(attrName)) {
SVGStyledTransformableElement::svgAttributeChanged(attrName);
return;
}
SVGElementInstance::InvalidationGuard invalidationGuard(this);
if (SVGTests::handleAttributeChange(this, attrName))
return;
if (RenderObject* renderer = this->renderer())
RenderSVGResource::markForLayoutAndParentResourceInvalidation(renderer);
}
RenderObject* SVGGElement::createRenderer(RenderArena* arena, RenderStyle* style)
{
if (style->display() == NONE)
return new (arena) RenderSVGHiddenContainer(this);
return new (arena) RenderSVGTransformableContainer(this);
}
bool SVGGElement::rendererIsNeeded(const NodeRenderingContext&)
{
return parentOrHostElement() && parentOrHostElement()->isSVGElement();
}
}
#endif // ENABLE(SVG)