2
* Copyright (C) 2004, 2005, 2006, 2008 Nikolas Zimmermann <zimmermann@kde.org>
3
* Copyright (C) 2004, 2005, 2006, 2007 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 "SVGCursorElement.h"
28
#include "SVGElementInstance.h"
33
// Animated property definitions
34
DEFINE_ANIMATED_LENGTH(SVGCursorElement, SVGNames::xAttr, X, x)
35
DEFINE_ANIMATED_LENGTH(SVGCursorElement, SVGNames::yAttr, Y, y)
36
DEFINE_ANIMATED_STRING(SVGCursorElement, XLinkNames::hrefAttr, Href, href)
37
DEFINE_ANIMATED_BOOLEAN(SVGCursorElement, SVGNames::externalResourcesRequiredAttr, ExternalResourcesRequired, externalResourcesRequired)
39
BEGIN_REGISTER_ANIMATED_PROPERTIES(SVGCursorElement)
40
REGISTER_LOCAL_ANIMATED_PROPERTY(x)
41
REGISTER_LOCAL_ANIMATED_PROPERTY(y)
42
REGISTER_LOCAL_ANIMATED_PROPERTY(href)
43
REGISTER_LOCAL_ANIMATED_PROPERTY(externalResourcesRequired)
44
REGISTER_PARENT_ANIMATED_PROPERTIES(SVGTests)
45
END_REGISTER_ANIMATED_PROPERTIES
47
inline SVGCursorElement::SVGCursorElement(const QualifiedName& tagName, Document* document)
48
: SVGElement(tagName, document)
49
, m_x(LengthModeWidth)
50
, m_y(LengthModeHeight)
52
ASSERT(hasTagName(SVGNames::cursorTag));
53
registerAnimatedPropertiesForSVGCursorElement();
56
PassRefPtr<SVGCursorElement> SVGCursorElement::create(const QualifiedName& tagName, Document* document)
58
return adoptRef(new SVGCursorElement(tagName, document));
61
SVGCursorElement::~SVGCursorElement()
63
HashSet<SVGElement*>::iterator end = m_clients.end();
64
for (HashSet<SVGElement*>::iterator it = m_clients.begin(); it != end; ++it)
65
(*it)->cursorElementRemoved();
68
bool SVGCursorElement::isSupportedAttribute(const QualifiedName& attrName)
70
DEFINE_STATIC_LOCAL(HashSet<QualifiedName>, supportedAttributes, ());
71
if (supportedAttributes.isEmpty()) {
72
SVGTests::addSupportedAttributes(supportedAttributes);
73
SVGExternalResourcesRequired::addSupportedAttributes(supportedAttributes);
74
SVGURIReference::addSupportedAttributes(supportedAttributes);
75
supportedAttributes.add(SVGNames::xAttr);
76
supportedAttributes.add(SVGNames::yAttr);
78
return supportedAttributes.contains<QualifiedName, SVGAttributeHashTranslator>(attrName);
81
void SVGCursorElement::parseAttribute(const QualifiedName& name, const AtomicString& value)
83
SVGParsingError parseError = NoError;
85
if (!isSupportedAttribute(name))
86
SVGElement::parseAttribute(name, value);
87
else if (name == SVGNames::xAttr)
88
setXBaseValue(SVGLength::construct(LengthModeWidth, value, parseError));
89
else if (name == SVGNames::yAttr)
90
setYBaseValue(SVGLength::construct(LengthModeHeight, value, parseError));
91
else if (SVGTests::parseAttribute(name, value)
92
|| SVGExternalResourcesRequired::parseAttribute(name, value)
93
|| SVGURIReference::parseAttribute(name, value)) {
97
reportAttributeParsingError(parseError, name, value);
100
void SVGCursorElement::addClient(SVGElement* element)
102
m_clients.add(element);
103
element->setCursorElement(this);
106
void SVGCursorElement::removeClient(SVGElement* element)
108
HashSet<SVGElement*>::iterator it = m_clients.find(element);
109
if (it != m_clients.end()) {
110
m_clients.remove(it);
111
element->cursorElementRemoved();
115
void SVGCursorElement::removeReferencedElement(SVGElement* element)
117
m_clients.remove(element);
120
void SVGCursorElement::svgAttributeChanged(const QualifiedName& attrName)
122
if (!isSupportedAttribute(attrName)) {
123
SVGElement::svgAttributeChanged(attrName);
127
SVGElementInstance::InvalidationGuard invalidationGuard(this);
129
// Any change of a cursor specific attribute triggers this recalc.
130
HashSet<SVGElement*>::const_iterator it = m_clients.begin();
131
HashSet<SVGElement*>::const_iterator end = m_clients.end();
133
for (; it != end; ++it)
134
(*it)->setNeedsStyleRecalc();
137
void SVGCursorElement::addSubresourceAttributeURLs(ListHashSet<KURL>& urls) const
139
SVGElement::addSubresourceAttributeURLs(urls);
141
addSubresourceURL(urls, document()->completeURL(href()));
146
#endif // ENABLE(SVG)