tizen beta release
[profile/ivi/webkit-efl.git] / Source / WebCore / svg / SVGElement.h
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 <wtf/HashMap.h>
31
32 namespace WebCore {
33
34 class AffineTransform;
35 class CSSCursorImageValue;
36 class Document;
37 class SVGAttributeToPropertyMap;
38 class SVGCursorElement;
39 class SVGDocumentExtensions;
40 class SVGElementInstance;
41 class SVGElementRareData;
42 class SVGSVGElement;
43
44 class SVGElement : public StyledElement {
45 public:
46     static PassRefPtr<SVGElement> create(const QualifiedName&, Document*);
47     virtual ~SVGElement();
48
49     String xmlbase() const;
50     void setXmlbase(const String&, ExceptionCode&);
51
52     SVGSVGElement* ownerSVGElement() const;
53     SVGElement* viewportElement() const;
54
55     SVGDocumentExtensions* accessDocumentSVGExtensions();
56
57     virtual bool isStyled() const { return false; }
58     virtual bool isStyledTransformable() const { return false; }
59     virtual bool isStyledLocatable() const { return false; }
60     virtual bool isSVG() const { return false; }
61     virtual bool isFilterEffect() const { return false; }
62     virtual bool isGradientStop() const { return false; }
63     virtual bool isTextContent() const { return false; }
64
65     // For SVGTests
66     virtual bool isValid() const { return true; }
67
68     virtual void svgAttributeChanged(const QualifiedName&) { }
69
70     virtual void animatedPropertyTypeForAttribute(const QualifiedName&, Vector<AnimatedPropertyType>&);
71
72     void sendSVGLoadEventIfPossible(bool sendParentLoadEvents = false);
73
74     virtual AffineTransform* supplementalTransform() { return 0; }
75
76     void invalidateSVGAttributes() { clearAreSVGAttributesValid(); }
77
78     const HashSet<SVGElementInstance*>& instancesForElement() const;
79
80     bool boundingBox(FloatRect&, SVGLocatable::StyleUpdateStrategy = SVGLocatable::AllowStyleUpdate);
81
82     void setCursorElement(SVGCursorElement*);
83     void cursorElementRemoved();
84     void setCursorImageValue(CSSCursorImageValue*);
85     void cursorImageValueRemoved();
86
87     SVGElement* correspondingElement();
88     void setCorrespondingElement(SVGElement*);
89
90     virtual void updateAnimatedSVGAttribute(const QualifiedName&) const;
91  
92     virtual PassRefPtr<RenderStyle> customStyleForRenderer();
93
94     static void synchronizeRequiredFeatures(void* contextElement);
95     static void synchronizeRequiredExtensions(void* contextElement);
96     static void synchronizeSystemLanguage(void* contextElement);
97
98     virtual void synchronizeRequiredFeatures() { }
99     virtual void synchronizeRequiredExtensions() { }
100     virtual void synchronizeSystemLanguage() { }
101
102     virtual SVGAttributeToPropertyMap& localAttributeToPropertyMap();
103
104 #ifndef NDEBUG
105     static bool isAnimatableAttribute(const QualifiedName&);
106 #endif
107
108 protected:
109     SVGElement(const QualifiedName&, Document*, ConstructionType = CreateSVGElement);
110
111     virtual void parseMappedAttribute(Attribute*);
112
113     virtual void finishParsingChildren();
114     virtual void attributeChanged(Attribute*, bool preserveDecls = false);
115     virtual bool childShouldCreateRenderer(Node*) const;
116     
117     virtual void removedFromDocument();
118
119     SVGElementRareData* rareSVGData() const;
120     SVGElementRareData* ensureRareSVGData();
121
122     void reportAttributeParsingError(SVGParsingError, Attribute*);
123
124 private:
125     friend class SVGElementInstance;
126
127     virtual bool rendererIsNeeded(const NodeRenderingContext&) { return false; }
128
129     virtual bool isSupported(StringImpl* feature, StringImpl* version) const;
130
131     void mapInstanceToElement(SVGElementInstance*);
132     void removeInstanceMapping(SVGElementInstance*);
133
134     virtual bool haveLoadedRequiredResources();
135 };
136
137 struct SVGAttributeHashTranslator {
138     static unsigned hash(QualifiedName key)
139     {
140         key.setPrefix(nullAtom);
141         return DefaultHash<QualifiedName>::Hash::hash(key);
142     }
143     static bool equal(QualifiedName a, QualifiedName b) { return a.matches(b); }
144 };
145
146 }
147
148 #endif
149 #endif