2
* Copyright (C) 2004, 2005, 2006, 2008 Nikolas Zimmermann <zimmermann@kde.org>
3
* Copyright (C) 2004, 2005, 2006 Rob Buis <buis@kde.org>
4
* Copyright (C) 2009 Apple Inc. All rights reserved.
6
* This library is free software; you can redistribute it and/or
7
* modify it under the terms of the GNU Library General Public
8
* License as published by the Free Software Foundation; either
9
* version 2 of the License, or (at your option) any later version.
11
* This library is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
* Library General Public License for more details.
16
* You should have received a copy of the GNU Library General Public License
17
* along with this library; see the file COPYING.LIB. If not, write to
18
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19
* Boston, MA 02110-1301, USA.
26
#include "SVGLocatable.h"
27
#include "SVGParsingError.h"
28
#include "SVGPropertyInfo.h"
29
#include "StyledElement.h"
31
#include <wtf/HashMap.h>
35
class AffineTransform;
36
class CSSCursorImageValue;
38
class SVGAttributeToPropertyMap;
39
class SVGCursorElement;
40
class SVGDocumentExtensions;
41
class SVGElementInstance;
42
class SVGElementRareData;
45
class SVGElement : public StyledElement {
47
static PassRefPtr<SVGElement> create(const QualifiedName&, Document*);
48
virtual ~SVGElement();
50
bool isOutermostSVGSVGElement() const;
52
String xmlbase() const;
53
void setXmlbase(const String&, ExceptionCode&);
55
SVGSVGElement* ownerSVGElement() const;
56
SVGElement* viewportElement() const;
58
SVGDocumentExtensions* accessDocumentSVGExtensions();
60
virtual bool isStyled() const { return false; }
61
virtual bool isStyledTransformable() const { return false; }
62
virtual bool isStyledLocatable() const { return false; }
63
virtual bool isSVG() const { return false; }
64
virtual bool isFilterEffect() const { return false; }
65
virtual bool isGradientStop() const { return false; }
66
virtual bool isTextContent() const { return false; }
69
virtual bool isValid() const { return true; }
71
virtual void svgAttributeChanged(const QualifiedName&) { }
73
bool hasPendingResources() const;
74
void setHasPendingResources();
75
void clearHasPendingResourcesIfPossible();
76
virtual void buildPendingResource() { }
78
virtual void animatedPropertyTypeForAttribute(const QualifiedName&, Vector<AnimatedPropertyType>&);
80
void sendSVGLoadEventIfPossible(bool sendParentLoadEvents = false);
81
void sendSVGLoadEventIfPossibleAsynchronously();
82
void svgLoadEventTimerFired(Timer<SVGElement>*);
83
virtual Timer<SVGElement>* svgLoadEventTimer();
85
virtual AffineTransform* supplementalTransform() { return 0; }
87
void invalidateSVGAttributes() { ensureAttributeData()->m_animatedSVGAttributesAreDirty = true; }
89
const HashSet<SVGElementInstance*>& instancesForElement() const;
91
bool getBoundingBox(FloatRect&, SVGLocatable::StyleUpdateStrategy = SVGLocatable::AllowStyleUpdate);
93
void setCursorElement(SVGCursorElement*);
94
void cursorElementRemoved();
95
void setCursorImageValue(CSSCursorImageValue*);
96
void cursorImageValueRemoved();
98
SVGElement* correspondingElement();
99
void setCorrespondingElement(SVGElement*);
101
virtual void updateAnimatedSVGAttribute(const QualifiedName&) const;
103
virtual PassRefPtr<RenderStyle> customStyleForRenderer() OVERRIDE;
105
static void synchronizeRequiredFeatures(void* contextElement);
106
static void synchronizeRequiredExtensions(void* contextElement);
107
static void synchronizeSystemLanguage(void* contextElement);
109
virtual void synchronizeRequiredFeatures() { }
110
virtual void synchronizeRequiredExtensions() { }
111
virtual void synchronizeSystemLanguage() { }
113
virtual SVGAttributeToPropertyMap& localAttributeToPropertyMap();
116
static bool isAnimatableAttribute(const QualifiedName&);
119
StylePropertySet* animatedSMILStyleProperties() const;
120
StylePropertySet* ensureAnimatedSMILStyleProperties();
121
void setUseOverrideComputedStyle(bool);
123
virtual bool haveLoadedRequiredResources();
125
virtual bool addEventListener(const AtomicString& eventType, PassRefPtr<EventListener>, bool useCapture) OVERRIDE;
126
virtual bool removeEventListener(const AtomicString& eventType, EventListener*, bool useCapture) OVERRIDE;
129
SVGElement(const QualifiedName&, Document*, ConstructionType = CreateSVGElement);
131
virtual void parseAttribute(const QualifiedName&, const AtomicString&) OVERRIDE;
133
virtual void finishParsingChildren();
134
virtual void attributeChanged(const QualifiedName&, const AtomicString&) OVERRIDE;
135
virtual bool childShouldCreateRenderer(const NodeRenderingContext&) const OVERRIDE;
137
virtual void removedFrom(ContainerNode*) OVERRIDE;
139
SVGElementRareData* svgRareData() const;
140
SVGElementRareData* ensureSVGRareData();
142
void reportAttributeParsingError(SVGParsingError, const QualifiedName&, const AtomicString&);
144
// FIXME: Author shadows should be allowed
145
// https://bugs.webkit.org/show_bug.cgi?id=77938
146
virtual bool areAuthorShadowsAllowed() const OVERRIDE { return false; }
149
friend class SVGElementInstance;
151
RenderStyle* computedStyle(PseudoId = NOPSEUDO);
152
virtual RenderStyle* virtualComputedStyle(PseudoId pseudoElementSpecifier = NOPSEUDO) { return computedStyle(pseudoElementSpecifier); }
153
virtual bool willRecalcStyle(StyleChange);
155
virtual bool rendererIsNeeded(const NodeRenderingContext&) { return false; }
157
virtual bool isSupported(StringImpl* feature, StringImpl* version) const;
159
void mapInstanceToElement(SVGElementInstance*);
160
void removeInstanceMapping(SVGElementInstance*);
164
struct SVGAttributeHashTranslator {
165
static unsigned hash(const QualifiedName& key)
167
if (key.hasPrefix()) {
168
QualifiedNameComponents components = { nullAtom.impl(), key.localName().impl(), key.namespaceURI().impl() };
169
return hashComponents(components);
171
return DefaultHash<QualifiedName>::Hash::hash(key);
173
static bool equal(const QualifiedName& a, const QualifiedName& b) { return a.matches(b); }
176
inline SVGElement* toSVGElement(Element* element)
178
ASSERT(!element || element->isSVGElement());
179
return static_cast<SVGElement*>(element);