1/*
2 * Copyright (C) 2004, 2005 Nikolas Zimmermann <zimmermann@kde.org>
3 * Copyright (C) 2004, 2005, 2006, 2007 Rob Buis <buis@kde.org>
4 * Copyright (C) 2007 Eric Seidel <eric@webkit.org>
5 * Copyright (C) 2008 Apple Inc. All rights reserved.
6 *
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version.
11 *
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15 * Library General Public License for more details.
16 *
17 * You should have received a copy of the GNU Library General Public License
18 * along with this library; see the file COPYING.LIB.  If not, write to
19 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20 * Boston, MA 02110-1301, USA.
21 */
22
23#include "config.h"
24
25#include "core/svg/SVGAnimateTransformElement.h"
26
27#include "SVGNames.h"
28#include "core/svg/SVGParserUtilities.h"
29
30namespace WebCore {
31
32inline SVGAnimateTransformElement::SVGAnimateTransformElement(Document& document)
33    : SVGAnimateElement(SVGNames::animateTransformTag, document)
34    , m_type(SVGTransform::SVG_TRANSFORM_UNKNOWN)
35{
36    ScriptWrappable::init(this);
37}
38
39PassRefPtr<SVGAnimateTransformElement> SVGAnimateTransformElement::create(Document& document)
40{
41    return adoptRef(new SVGAnimateTransformElement(document));
42}
43
44bool SVGAnimateTransformElement::hasValidAttributeType()
45{
46    SVGElement* targetElement = this->targetElement();
47    if (!targetElement)
48        return false;
49
50    if (attributeType() == AttributeTypeCSS)
51        return false;
52
53    return m_animatedPropertyType == AnimatedTransformList;
54}
55
56bool SVGAnimateTransformElement::isSupportedAttribute(const QualifiedName& attrName)
57{
58    DEFINE_STATIC_LOCAL(HashSet<QualifiedName>, supportedAttributes, ());
59    if (supportedAttributes.isEmpty())
60        supportedAttributes.add(SVGNames::typeAttr);
61    return supportedAttributes.contains<SVGAttributeHashTranslator>(attrName);
62}
63
64void SVGAnimateTransformElement::parseAttribute(const QualifiedName& name, const AtomicString& value)
65{
66    if (!isSupportedAttribute(name)) {
67        SVGAnimateElement::parseAttribute(name, value);
68        return;
69    }
70
71    if (name == SVGNames::typeAttr) {
72        m_type = parseTransformType(value);
73        if (m_type == SVGTransform::SVG_TRANSFORM_MATRIX)
74            m_type = SVGTransform::SVG_TRANSFORM_UNKNOWN;
75        return;
76    }
77
78    ASSERT_NOT_REACHED();
79}
80
81}
82