Home | History | Annotate | Download | only in svg
      1 /*
      2  * Copyright (C) 2007 Eric Seidel <eric (at) webkit.org>
      3  *
      4  * This library is free software; you can redistribute it and/or
      5  * modify it under the terms of the GNU Library General Public
      6  * License as published by the Free Software Foundation; either
      7  * version 2 of the License, or (at your option) any later version.
      8  *
      9  * This library is distributed in the hope that it will be useful,
     10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
     11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
     12  * Library General Public License for more details.
     13  *
     14  * You should have received a copy of the GNU Library General Public License
     15  * along with this library; see the file COPYING.LIB.  If not, write to
     16  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
     17  * Boston, MA 02110-1301, USA.
     18  */
     19 
     20 #include "config.h"
     21 
     22 #if ENABLE(SVG)
     23 #include "SVGMPathElement.h"
     24 
     25 #include "Document.h"
     26 #include "SVGNames.h"
     27 #include "SVGPathElement.h"
     28 
     29 namespace WebCore {
     30 
     31 // Animated property definitions
     32 DEFINE_ANIMATED_STRING(SVGMPathElement, XLinkNames::hrefAttr, Href, href)
     33 DEFINE_ANIMATED_BOOLEAN(SVGMPathElement, SVGNames::externalResourcesRequiredAttr, ExternalResourcesRequired, externalResourcesRequired)
     34 
     35 inline SVGMPathElement::SVGMPathElement(const QualifiedName& tagName, Document* document)
     36     : SVGElement(tagName, document)
     37 {
     38 }
     39 
     40 PassRefPtr<SVGMPathElement> SVGMPathElement::create(const QualifiedName& tagName, Document* document)
     41 {
     42     return adoptRef(new SVGMPathElement(tagName, document));
     43 }
     44 
     45 void SVGMPathElement::parseMappedAttribute(Attribute* attr)
     46 {
     47     if (SVGURIReference::parseMappedAttribute(attr))
     48         return;
     49     SVGElement::parseMappedAttribute(attr);
     50 }
     51 
     52 void SVGMPathElement::synchronizeProperty(const QualifiedName& attrName)
     53 {
     54     SVGElement::synchronizeProperty(attrName);
     55 
     56     if (attrName == anyQName()) {
     57         synchronizeExternalResourcesRequired();
     58         synchronizeHref();
     59         return;
     60     }
     61 
     62     if (SVGExternalResourcesRequired::isKnownAttribute(attrName))
     63         synchronizeExternalResourcesRequired();
     64     else if (SVGURIReference::isKnownAttribute(attrName))
     65         synchronizeHref();
     66 }
     67 
     68 AttributeToPropertyTypeMap& SVGMPathElement::attributeToPropertyTypeMap()
     69 {
     70     DEFINE_STATIC_LOCAL(AttributeToPropertyTypeMap, s_attributeToPropertyTypeMap, ());
     71     return s_attributeToPropertyTypeMap;
     72 }
     73 
     74 void SVGMPathElement::fillAttributeToPropertyTypeMap()
     75 {
     76     attributeToPropertyTypeMap().set(XLinkNames::hrefAttr, AnimatedString);
     77 }
     78 
     79 SVGPathElement* SVGMPathElement::pathElement()
     80 {
     81     Element* target = document()->getElementById(getTarget(href()));
     82     if (target && target->hasTagName(SVGNames::pathTag))
     83         return static_cast<SVGPathElement*>(target);
     84     return 0;
     85 }
     86 
     87 } // namespace WebCore
     88 
     89 #endif // ENABLE(SVG)
     90