initial import
[vuplus_webkit] / 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 protected:
105     SVGElement(const QualifiedName&, Document*);
106
107     virtual void parseMappedAttribute(Attribute*);
108
109     virtual void finishParsingChildren();
110     virtual void attributeChanged(Attribute*, bool preserveDecls = false);
111     virtual bool childShouldCreateRenderer(Node*) const;
112     
113     virtual void removedFromDocument();
114
115     SVGElementRareData* rareSVGData() const;
116     SVGElementRareData* ensureRareSVGData();
117
118     void reportAttributeParsingError(SVGParsingError, Attribute*);
119
120 private:
121     friend class SVGElementInstance;
122
123     virtual bool rendererIsNeeded(const NodeRenderingContext&) { return false; }
124
125     virtual bool isSupported(StringImpl* feature, StringImpl* version) const;
126
127     void mapInstanceToElement(SVGElementInstance*);
128     void removeInstanceMapping(SVGElementInstance*);
129
130     virtual bool haveLoadedRequiredResources();
131 };
132
133 }
134
135 #endif
136 #endif