• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2     Copyright (C) 2004, 2005, 2006 Nikolas Zimmermann <zimmermann@kde.org>
3                   2004, 2005, 2006, 2007 Rob Buis <buis@kde.org>
4 
5     This file is part of the KDE project
6 
7     This library is free software; you can redistribute it and/or
8     modify it under the terms of the GNU Library General Public
9     License as published by the Free Software Foundation; either
10     version 2 of the License, or (at your option) any later version.
11 
12     This library is distributed in the hope that it will be useful,
13     but WITHOUT ANY WARRANTY; without even the implied warranty of
14     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15     Library General Public License for more details.
16 
17     You should have received a copy of the GNU Library General Public License
18     along with this library; see the file COPYING.LIB.  If not, write to
19     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20     Boston, MA 02110-1301, USA.
21 */
22 
23 #ifndef SVGSVGElement_h
24 #define SVGSVGElement_h
25 
26 #if ENABLE(SVG)
27 
28 #include "IntSize.h"
29 #include "SVGExternalResourcesRequired.h"
30 #include "SVGFitToViewBox.h"
31 #include "SVGLangSpace.h"
32 #include "SVGStyledLocatableElement.h"
33 #include "SVGTests.h"
34 #include "SVGZoomAndPan.h"
35 
36 namespace WebCore
37 {
38     class SVGAngle;
39     class SVGLength;
40     class SVGTransform;
41     class SVGViewSpec;
42     class SVGViewElement;
43     class SMILTimeContainer;
44     class SVGSVGElement : public SVGStyledLocatableElement,
45                           public SVGTests,
46                           public SVGLangSpace,
47                           public SVGExternalResourcesRequired,
48                           public SVGFitToViewBox,
49                           public SVGZoomAndPan
50     {
51     public:
52         SVGSVGElement(const QualifiedName&, Document*);
53         virtual ~SVGSVGElement();
54 
isSVG()55         virtual bool isSVG() const { return true; }
56 
isValid()57         virtual bool isValid() const { return SVGTests::isValid(); }
58 
59         // 'SVGSVGElement' functions
60         const AtomicString& contentScriptType() const;
61         void setContentScriptType(const AtomicString& type);
62 
63         const AtomicString& contentStyleType() const;
64         void setContentStyleType(const AtomicString& type);
65 
66         FloatRect viewport() const;
67 
setContainerSize(const IntSize & containerSize)68         void setContainerSize(const IntSize& containerSize) { m_containerSize = containerSize; m_hasSetContainerSize = true; }
containerSize()69         IntSize containerSize() const { return m_containerSize; }
hasSetContainerSize()70         bool hasSetContainerSize() const { return m_hasSetContainerSize; }
71         int relativeWidthValue() const;
72         int relativeHeightValue() const;
73 
74         float pixelUnitToMillimeterX() const;
75         float pixelUnitToMillimeterY() const;
76         float screenPixelToMillimeterX() const;
77         float screenPixelToMillimeterY() const;
78 
79         bool useCurrentView() const;
80         void setUseCurrentView(bool currentView);
81 
82         SVGViewSpec* currentView() const;
83 
84         float currentScale() const;
85         void setCurrentScale(float scale);
86 
87         FloatPoint currentTranslate() const;
88         void setCurrentTranslate(const FloatPoint&);
89 
timeContainer()90         SMILTimeContainer* timeContainer() const { return m_timeContainer.get(); }
91 
92         void pauseAnimations();
93         void unpauseAnimations();
94         bool animationsPaused() const;
95 
96         float getCurrentTime() const;
97         void setCurrentTime(float seconds);
98 
99         unsigned long suspendRedraw(unsigned long max_wait_milliseconds);
100         void unsuspendRedraw(unsigned long suspend_handle_id, ExceptionCode&);
101         void unsuspendRedrawAll();
102         void forceRedraw();
103 
104         NodeList* getIntersectionList(const FloatRect&, SVGElement* referenceElement);
105         NodeList* getEnclosureList(const FloatRect&, SVGElement* referenceElement);
106         bool checkIntersection(SVGElement*, const FloatRect&);
107         bool checkEnclosure(SVGElement*, const FloatRect&);
108         void deselectAll();
109 
110         static float createSVGNumber();
111         static SVGLength createSVGLength();
112         static PassRefPtr<SVGAngle> createSVGAngle();
113         static FloatPoint createSVGPoint();
114         static TransformationMatrix createSVGMatrix();
115         static FloatRect createSVGRect();
116         static SVGTransform createSVGTransform();
117         static SVGTransform createSVGTransformFromMatrix(const TransformationMatrix&);
118 
119         virtual void parseMappedAttribute(MappedAttribute*);
120 
121         // 'virtual SVGLocatable' functions
122         virtual TransformationMatrix getCTM() const;
123         virtual TransformationMatrix getScreenCTM() const;
124 
rendererIsNeeded(RenderStyle * style)125         virtual bool rendererIsNeeded(RenderStyle* style) { return StyledElement::rendererIsNeeded(style); }
126         virtual RenderObject* createRenderer(RenderArena*, RenderStyle*);
127 
128         virtual void insertedIntoDocument();
129         virtual void removedFromDocument();
130 
131         virtual void svgAttributeChanged(const QualifiedName&);
132 
133         virtual TransformationMatrix viewBoxToViewTransform(float viewWidth, float viewHeight) const;
134 
135         void inheritViewAttributes(SVGViewElement*);
136 
137     protected:
contextElement()138         virtual const SVGElement* contextElement() const { return this; }
139 
140         friend class RenderSVGRoot;
141         friend class RenderSVGViewportContainer;
142 
143         virtual bool hasRelativeValues() const;
144 
145         bool isOutermostSVG() const;
146 
147     private:
148         ANIMATED_PROPERTY_DECLARATIONS(SVGSVGElement, SVGNames::svgTagString, SVGNames::xAttrString, SVGLength, X, x)
149         ANIMATED_PROPERTY_DECLARATIONS(SVGSVGElement, SVGNames::svgTagString, SVGNames::yAttrString, SVGLength, Y, y)
150         ANIMATED_PROPERTY_DECLARATIONS(SVGSVGElement, SVGNames::svgTagString, SVGNames::widthAttrString, SVGLength, Width, width)
151         ANIMATED_PROPERTY_DECLARATIONS(SVGSVGElement, SVGNames::svgTagString, SVGNames::heightAttrString, SVGLength, Height, height)
152 
153         virtual void documentWillBecomeInactive();
154         virtual void documentDidBecomeActive();
155 
156         bool m_useCurrentView;
157         RefPtr<SMILTimeContainer> m_timeContainer;
158         FloatPoint m_translation;
159         mutable OwnPtr<SVGViewSpec> m_viewSpec;
160         IntSize m_containerSize;
161         bool m_hasSetContainerSize;
162     };
163 
164 } // namespace WebCore
165 
166 #endif // ENABLE(SVG)
167 #endif
168