~ubuntu-branches/ubuntu/raring/qtwebkit-source/raring-proposed

« back to all changes in this revision

Viewing changes to Source/WebCore/svg/SVGElement.h

  • Committer: Package Import Robot
  • Author(s): Jonathan Riddell
  • Date: 2013-02-18 14:24:18 UTC
  • Revision ID: package-import@ubuntu.com-20130218142418-eon0jmjg3nj438uy
Tags: upstream-2.3
ImportĀ upstreamĀ versionĀ 2.3

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
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.
 
5
 *
 
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.
 
10
 *
 
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.
 
15
 *
 
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.
 
20
 */
 
21
 
 
22
#ifndef SVGElement_h
 
23
#define SVGElement_h
 
24
 
 
25
#if ENABLE(SVG)
 
26
#include "SVGLocatable.h"
 
27
#include "SVGParsingError.h"
 
28
#include "SVGPropertyInfo.h"
 
29
#include "StyledElement.h"
 
30
#include "Timer.h"
 
31
#include <wtf/HashMap.h>
 
32
 
 
33
namespace WebCore {
 
34
 
 
35
class AffineTransform;
 
36
class CSSCursorImageValue;
 
37
class Document;
 
38
class SVGAttributeToPropertyMap;
 
39
class SVGCursorElement;
 
40
class SVGDocumentExtensions;
 
41
class SVGElementInstance;
 
42
class SVGElementRareData;
 
43
class SVGSVGElement;
 
44
 
 
45
class SVGElement : public StyledElement {
 
46
public:
 
47
    static PassRefPtr<SVGElement> create(const QualifiedName&, Document*);
 
48
    virtual ~SVGElement();
 
49
 
 
50
    bool isOutermostSVGSVGElement() const;
 
51
 
 
52
    String xmlbase() const;
 
53
    void setXmlbase(const String&, ExceptionCode&);
 
54
 
 
55
    SVGSVGElement* ownerSVGElement() const;
 
56
    SVGElement* viewportElement() const;
 
57
 
 
58
    SVGDocumentExtensions* accessDocumentSVGExtensions();
 
59
 
 
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; }
 
67
 
 
68
    // For SVGTests
 
69
    virtual bool isValid() const { return true; }
 
70
 
 
71
    virtual void svgAttributeChanged(const QualifiedName&) { }
 
72
 
 
73
    bool hasPendingResources() const;
 
74
    void setHasPendingResources();
 
75
    void clearHasPendingResourcesIfPossible();
 
76
    virtual void buildPendingResource() { }
 
77
 
 
78
    virtual void animatedPropertyTypeForAttribute(const QualifiedName&, Vector<AnimatedPropertyType>&);
 
79
 
 
80
    void sendSVGLoadEventIfPossible(bool sendParentLoadEvents = false);
 
81
    void sendSVGLoadEventIfPossibleAsynchronously();
 
82
    void svgLoadEventTimerFired(Timer<SVGElement>*);
 
83
    virtual Timer<SVGElement>* svgLoadEventTimer();
 
84
 
 
85
    virtual AffineTransform* supplementalTransform() { return 0; }
 
86
 
 
87
    void invalidateSVGAttributes() { ensureAttributeData()->m_animatedSVGAttributesAreDirty = true; }
 
88
 
 
89
    const HashSet<SVGElementInstance*>& instancesForElement() const;
 
90
 
 
91
    bool getBoundingBox(FloatRect&, SVGLocatable::StyleUpdateStrategy = SVGLocatable::AllowStyleUpdate);
 
92
 
 
93
    void setCursorElement(SVGCursorElement*);
 
94
    void cursorElementRemoved();
 
95
    void setCursorImageValue(CSSCursorImageValue*);
 
96
    void cursorImageValueRemoved();
 
97
 
 
98
    SVGElement* correspondingElement();
 
99
    void setCorrespondingElement(SVGElement*);
 
100
 
 
101
    virtual void updateAnimatedSVGAttribute(const QualifiedName&) const;
 
102
 
 
103
    virtual PassRefPtr<RenderStyle> customStyleForRenderer() OVERRIDE;
 
104
 
 
105
    static void synchronizeRequiredFeatures(void* contextElement);
 
106
    static void synchronizeRequiredExtensions(void* contextElement);
 
107
    static void synchronizeSystemLanguage(void* contextElement);
 
108
 
 
109
    virtual void synchronizeRequiredFeatures() { }
 
110
    virtual void synchronizeRequiredExtensions() { }
 
111
    virtual void synchronizeSystemLanguage() { }
 
112
 
 
113
    virtual SVGAttributeToPropertyMap& localAttributeToPropertyMap();
 
114
 
 
115
#ifndef NDEBUG
 
116
    static bool isAnimatableAttribute(const QualifiedName&);
 
117
#endif
 
118
 
 
119
    StylePropertySet* animatedSMILStyleProperties() const;
 
120
    StylePropertySet* ensureAnimatedSMILStyleProperties();
 
121
    void setUseOverrideComputedStyle(bool);
 
122
 
 
123
    virtual bool haveLoadedRequiredResources();
 
124
 
 
125
    virtual bool addEventListener(const AtomicString& eventType, PassRefPtr<EventListener>, bool useCapture) OVERRIDE;
 
126
    virtual bool removeEventListener(const AtomicString& eventType, EventListener*, bool useCapture) OVERRIDE;
 
127
 
 
128
protected:
 
129
    SVGElement(const QualifiedName&, Document*, ConstructionType = CreateSVGElement);
 
130
 
 
131
    virtual void parseAttribute(const QualifiedName&, const AtomicString&) OVERRIDE;
 
132
 
 
133
    virtual void finishParsingChildren();
 
134
    virtual void attributeChanged(const QualifiedName&, const AtomicString&) OVERRIDE;
 
135
    virtual bool childShouldCreateRenderer(const NodeRenderingContext&) const OVERRIDE;
 
136
    
 
137
    virtual void removedFrom(ContainerNode*) OVERRIDE;
 
138
 
 
139
    SVGElementRareData* svgRareData() const;
 
140
    SVGElementRareData* ensureSVGRareData();
 
141
 
 
142
    void reportAttributeParsingError(SVGParsingError, const QualifiedName&, const AtomicString&);
 
143
 
 
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; }
 
147
 
 
148
private:
 
149
    friend class SVGElementInstance;
 
150
 
 
151
    RenderStyle* computedStyle(PseudoId = NOPSEUDO);
 
152
    virtual RenderStyle* virtualComputedStyle(PseudoId pseudoElementSpecifier = NOPSEUDO) { return computedStyle(pseudoElementSpecifier); }
 
153
    virtual bool willRecalcStyle(StyleChange);
 
154
 
 
155
    virtual bool rendererIsNeeded(const NodeRenderingContext&) { return false; }
 
156
 
 
157
    virtual bool isSupported(StringImpl* feature, StringImpl* version) const;
 
158
 
 
159
    void mapInstanceToElement(SVGElementInstance*);
 
160
    void removeInstanceMapping(SVGElementInstance*);
 
161
 
 
162
};
 
163
 
 
164
struct SVGAttributeHashTranslator {
 
165
    static unsigned hash(const QualifiedName& key)
 
166
    {
 
167
        if (key.hasPrefix()) {
 
168
            QualifiedNameComponents components = { nullAtom.impl(), key.localName().impl(), key.namespaceURI().impl() };
 
169
            return hashComponents(components);
 
170
        }
 
171
        return DefaultHash<QualifiedName>::Hash::hash(key);
 
172
    }
 
173
    static bool equal(const QualifiedName& a, const QualifiedName& b) { return a.matches(b); }
 
174
};
 
175
 
 
176
inline SVGElement* toSVGElement(Element* element)
 
177
{
 
178
    ASSERT(!element || element->isSVGElement());
 
179
    return static_cast<SVGElement*>(element);
 
180
}
 
181
 
 
182
}
 
183
 
 
184
#endif
 
185
#endif