1 /* 2 Copyright (C) 2004, 2005, 2006, 2008 Nikolas Zimmermann <zimmermann (at) kde.org> 3 2004, 2005, 2006, 2007 Rob Buis <buis (at) kde.org> 4 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. 9 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. 14 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. 19 */ 20 21 #include "config.h" 22 23 #if ENABLE(SVG) 24 #include "SVGCursorElement.h" 25 26 #include "Attr.h" 27 #include "Document.h" 28 #include "MappedAttribute.h" 29 #include "SVGLength.h" 30 #include "SVGNames.h" 31 32 namespace WebCore { 33 34 SVGCursorElement::SVGCursorElement(const QualifiedName& tagName, Document* doc) 35 : SVGElement(tagName, doc) 36 , SVGTests() 37 , SVGExternalResourcesRequired() 38 , SVGURIReference() 39 , m_x(LengthModeWidth) 40 , m_y(LengthModeHeight) 41 { 42 } 43 44 SVGCursorElement::~SVGCursorElement() 45 { 46 HashSet<SVGElement*>::iterator end = m_clients.end(); 47 for (HashSet<SVGElement*>::iterator it = m_clients.begin(); it != end; ++it) 48 (*it)->setCursorElement(0); 49 } 50 51 void SVGCursorElement::parseMappedAttribute(MappedAttribute* attr) 52 { 53 if (attr->name() == SVGNames::xAttr) 54 setXBaseValue(SVGLength(LengthModeWidth, attr->value())); 55 else if (attr->name() == SVGNames::yAttr) 56 setYBaseValue(SVGLength(LengthModeHeight, attr->value())); 57 else { 58 if (SVGTests::parseMappedAttribute(attr)) 59 return; 60 if (SVGExternalResourcesRequired::parseMappedAttribute(attr)) 61 return; 62 if (SVGURIReference::parseMappedAttribute(attr)) 63 return; 64 65 SVGElement::parseMappedAttribute(attr); 66 } 67 } 68 69 void SVGCursorElement::addClient(SVGElement* element) 70 { 71 m_clients.add(element); 72 element->setCursorElement(this); 73 } 74 75 void SVGCursorElement::removeClient(SVGElement* element) 76 { 77 m_clients.remove(element); 78 element->setCursorElement(0); 79 } 80 81 void SVGCursorElement::svgAttributeChanged(const QualifiedName& attrName) 82 { 83 SVGElement::svgAttributeChanged(attrName); 84 85 if (attrName == SVGNames::xAttr || attrName == SVGNames::yAttr || 86 SVGTests::isKnownAttribute(attrName) || 87 SVGExternalResourcesRequired::isKnownAttribute(attrName) || 88 SVGURIReference::isKnownAttribute(attrName)) { 89 HashSet<SVGElement*>::const_iterator it = m_clients.begin(); 90 HashSet<SVGElement*>::const_iterator end = m_clients.end(); 91 92 for (; it != end; ++it) 93 (*it)->setNeedsStyleRecalc(); 94 } 95 } 96 97 void SVGCursorElement::synchronizeProperty(const QualifiedName& attrName) 98 { 99 SVGElement::synchronizeProperty(attrName); 100 101 if (attrName == anyQName()) { 102 synchronizeX(); 103 synchronizeY(); 104 synchronizeExternalResourcesRequired(); 105 synchronizeHref(); 106 return; 107 } 108 109 if (attrName == SVGNames::xAttr) 110 synchronizeX(); 111 else if (attrName == SVGNames::yAttr) 112 synchronizeY(); 113 else if (SVGExternalResourcesRequired::isKnownAttribute(attrName)) 114 synchronizeExternalResourcesRequired(); 115 else if (SVGURIReference::isKnownAttribute(attrName)) 116 synchronizeHref(); 117 } 118 119 void SVGCursorElement::addSubresourceAttributeURLs(ListHashSet<KURL>& urls) const 120 { 121 SVGElement::addSubresourceAttributeURLs(urls); 122 123 addSubresourceURL(urls, document()->completeURL(href())); 124 } 125 126 } 127 128 #endif // ENABLE(SVG) 129