Home | History | Annotate | Download | only in svg
      1 /*
      2  * Copyright (C) 2004, 2005 Nikolas Zimmermann <zimmermann (at) kde.org>
      3  * Copyright (C) 2004, 2005, 2006, 2007 Rob Buis <buis (at) kde.org>
      4  * Copyright (C) 2007 Eric Seidel <eric (at) 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/SVGTransformable.h"
     29 
     30 namespace WebCore {
     31 
     32 inline SVGAnimateTransformElement::SVGAnimateTransformElement(const QualifiedName& tagName, Document* document)
     33     : SVGAnimateElement(tagName, document)
     34     , m_type(SVGTransform::SVG_TRANSFORM_UNKNOWN)
     35 {
     36     ASSERT(hasTagName(SVGNames::animateTransformTag));
     37     ScriptWrappable::init(this);
     38 }
     39 
     40 PassRefPtr<SVGAnimateTransformElement> SVGAnimateTransformElement::create(const QualifiedName& tagName, Document* document)
     41 {
     42     return adoptRef(new SVGAnimateTransformElement(tagName, document));
     43 }
     44 
     45 bool SVGAnimateTransformElement::hasValidAttributeType()
     46 {
     47     SVGElement* targetElement = this->targetElement();
     48     if (!targetElement)
     49         return false;
     50 
     51     return m_animatedPropertyType == AnimatedTransformList;
     52 }
     53 
     54 bool SVGAnimateTransformElement::isSupportedAttribute(const QualifiedName& attrName)
     55 {
     56     DEFINE_STATIC_LOCAL(HashSet<QualifiedName>, supportedAttributes, ());
     57     if (supportedAttributes.isEmpty())
     58         supportedAttributes.add(SVGNames::typeAttr);
     59     return supportedAttributes.contains<SVGAttributeHashTranslator>(attrName);
     60 }
     61 
     62 void SVGAnimateTransformElement::parseAttribute(const QualifiedName& name, const AtomicString& value)
     63 {
     64     if (!isSupportedAttribute(name)) {
     65         SVGAnimateElement::parseAttribute(name, value);
     66         return;
     67     }
     68 
     69     if (name == SVGNames::typeAttr) {
     70         m_type = SVGTransformable::parseTransformType(value);
     71         if (m_type == SVGTransform::SVG_TRANSFORM_MATRIX)
     72             m_type = SVGTransform::SVG_TRANSFORM_UNKNOWN;
     73         return;
     74     }
     75 
     76     ASSERT_NOT_REACHED();
     77 }
     78 
     79 }
     80