2 * Copyright (C) 2004, 2005, 2007, 2008 Nikolas Zimmermann <zimmermann@kde.org>
3 * Copyright (C) 2004, 2005, 2006 Rob Buis <buis@kde.org>
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Library General Public License for more details.
15 * You should have received a copy of the GNU Library General Public License
16 * along with this library; see the file COPYING.LIB. If not, write to
17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 * Boston, MA 02110-1301, USA.
24 #include "SVGGElement.h"
26 #include "RenderSVGHiddenContainer.h"
27 #include "RenderSVGResource.h"
28 #include "RenderSVGTransformableContainer.h"
29 #include "SVGElementInstance.h"
34 // Animated property definitions
35 DEFINE_ANIMATED_BOOLEAN(SVGGElement, SVGNames::externalResourcesRequiredAttr, ExternalResourcesRequired, externalResourcesRequired)
37 BEGIN_REGISTER_ANIMATED_PROPERTIES(SVGGElement)
38 REGISTER_LOCAL_ANIMATED_PROPERTY(externalResourcesRequired)
39 REGISTER_PARENT_ANIMATED_PROPERTIES(SVGStyledTransformableElement)
40 REGISTER_PARENT_ANIMATED_PROPERTIES(SVGTests)
41 END_REGISTER_ANIMATED_PROPERTIES
43 SVGGElement::SVGGElement(const QualifiedName& tagName, Document* document)
44 : SVGStyledTransformableElement(tagName, document)
46 ASSERT(hasTagName(SVGNames::gTag));
47 registerAnimatedPropertiesForSVGGElement();
50 PassRefPtr<SVGGElement> SVGGElement::create(const QualifiedName& tagName, Document* document)
52 return adoptRef(new SVGGElement(tagName, document));
55 bool SVGGElement::isSupportedAttribute(const QualifiedName& attrName)
57 DEFINE_STATIC_LOCAL(HashSet<QualifiedName>, supportedAttributes, ());
58 if (supportedAttributes.isEmpty()) {
59 SVGTests::addSupportedAttributes(supportedAttributes);
60 SVGLangSpace::addSupportedAttributes(supportedAttributes);
61 SVGExternalResourcesRequired::addSupportedAttributes(supportedAttributes);
63 return supportedAttributes.contains(attrName);
66 void SVGGElement::parseMappedAttribute(Attribute* attr)
68 if (!isSupportedAttribute(attr->name())) {
69 SVGStyledTransformableElement::parseMappedAttribute(attr);
73 if (SVGTests::parseMappedAttribute(attr))
75 if (SVGLangSpace::parseMappedAttribute(attr))
77 if (SVGExternalResourcesRequired::parseMappedAttribute(attr))
83 void SVGGElement::svgAttributeChanged(const QualifiedName& attrName)
85 if (!isSupportedAttribute(attrName)) {
86 SVGStyledTransformableElement::svgAttributeChanged(attrName);
90 SVGElementInstance::InvalidationGuard invalidationGuard(this);
92 if (SVGTests::handleAttributeChange(this, attrName))
95 if (RenderObject* renderer = this->renderer())
96 RenderSVGResource::markForLayoutAndParentResourceInvalidation(renderer);
99 RenderObject* SVGGElement::createRenderer(RenderArena* arena, RenderStyle* style)
101 // SVG 1.1 testsuite explicitely uses constructs like <g display="none"><linearGradient>
102 // We still have to create renderers for the <g> & <linearGradient> element, though the
103 // subtree may be hidden - we only want the resource renderers to exist so they can be
104 // referenced from somewhere else.
105 if (style->display() == NONE)
106 return new (arena) RenderSVGHiddenContainer(this);
108 return new (arena) RenderSVGTransformableContainer(this);
111 bool SVGGElement::rendererIsNeeded(const NodeRenderingContext&)
113 return parentNode() && parentNode()->isSVGElement();
118 #endif // ENABLE(SVG)