2 Copyright (C) 2004, 2005, 2006 Nikolas Zimmermann <zimmermann@kde.org>
3 2004, 2005, 2006, 2007 Rob Buis <buis@kde.org>
5 This file is part of the KDE project
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.
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.
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.
23 #ifndef SVGSVGElement_h
24 #define SVGSVGElement_h
28 #include "FloatRect.h"
31 #include "SVGExternalResourcesRequired.h"
32 #include "SVGFitToViewBox.h"
33 #include "SVGLangSpace.h"
34 #include "SVGStyledLocatableElement.h"
36 #include "SVGZoomAndPan.h"
44 /*class SVGViewElement;
45 class SMILTimeContainer;*/
46 class SVGSVGElement
: public SVGStyledLocatableElement
,
49 public SVGExternalResourcesRequired
,
50 public SVGFitToViewBox
,
54 SVGSVGElement(const QualifiedName
&, Document
*);
55 virtual ~SVGSVGElement();
57 virtual bool isSVG() const { return true; }
59 virtual bool isValid() const { return SVGTests::isValid(); }
61 // 'SVGSVGElement' functions
62 const AtomicString
& contentScriptType() const;
63 void setContentScriptType(const AtomicString
& type
);
65 const AtomicString
& contentStyleType() const;
66 void setContentStyleType(const AtomicString
& type
);
68 FloatRect
viewport() const;
70 void setContainerSize(const IntSize
& containerSize
) { m_containerSize
= containerSize
; m_hasSetContainerSize
= true; }
71 IntSize
containerSize() const { return m_containerSize
; }
72 bool hasSetContainerSize() const { return m_hasSetContainerSize
; }
73 int relativeWidthValue() const;
74 int relativeHeightValue() const;
76 float pixelUnitToMillimeterX() const;
77 float pixelUnitToMillimeterY() const;
78 float screenPixelToMillimeterX() const;
79 float screenPixelToMillimeterY() const;
81 bool useCurrentView() const;
82 void setUseCurrentView(bool currentView
);
84 SVGViewSpec
* currentView() const;
86 float currentScale() const;
87 void setCurrentScale(float scale
);
89 FloatPoint
currentTranslate() const;
90 void setCurrentTranslate(const FloatPoint
&);
92 /*SMILTimeContainer* timeContainer() const { return m_timeContainer.get(); }*/
94 void pauseAnimations();
95 void unpauseAnimations();
96 bool animationsPaused() const;
98 float getCurrentTime() const;
99 void setCurrentTime(float seconds
);
101 unsigned long suspendRedraw(unsigned long max_wait_milliseconds
);
102 void unsuspendRedraw(unsigned long suspend_handle_id
, ExceptionCode
&);
103 void unsuspendRedrawAll();
106 NodeList
* getIntersectionList(const FloatRect
&, SVGElement
* referenceElement
);
107 NodeList
* getEnclosureList(const FloatRect
&, SVGElement
* referenceElement
);
108 bool checkIntersection(SVGElement
*, const FloatRect
&);
109 bool checkEnclosure(SVGElement
*, const FloatRect
&);
112 static float createSVGNumber();
113 static SVGLength
createSVGLength();
114 static SVGAngle
* createSVGAngle();
115 static FloatPoint
createSVGPoint();
116 static AffineTransform
createSVGMatrix();
117 static FloatRect
createSVGRect();
118 static SVGTransform
createSVGTransform();
119 static SVGTransform
createSVGTransformFromMatrix(const AffineTransform
&);
121 virtual void parseMappedAttribute(MappedAttribute
*);
123 // 'virtual SVGLocatable' functions
124 virtual AffineTransform
getCTM() const;
125 virtual AffineTransform
getScreenCTM() const;
127 virtual bool rendererIsNeeded(RenderStyle
* style
) { return StyledElement::rendererIsNeeded(style
); }
128 virtual RenderObject
* createRenderer(RenderArena
*, RenderStyle
*);
130 virtual void insertedIntoDocument();
131 virtual void removedFromDocument();
133 virtual void svgAttributeChanged(const QualifiedName
&);
135 virtual AffineTransform
viewBoxToViewTransform(float viewWidth
, float viewHeight
) const;
137 //void inheritViewAttributes(SVGViewElement*);
139 // KHTML ElementImpl pure virtual method
140 virtual quint32
id() const;
141 virtual DOMString
tagName() const { return SVGNames::svgTag
.tagName(); }
142 //virtual void parseAttribute(Attribute*);
145 virtual const SVGElement
* contextElement() const { return this; }
147 friend class RenderSVGRoot
;
148 /*friend class RenderSVGViewportContainer;*/
150 virtual bool hasRelativeValues() const;
152 bool isOutermostSVG() const;
155 void addSVGWindowEventListener(const AtomicString
& eventType
, const Attribute
* attr
);
157 ANIMATED_PROPERTY_FORWARD_DECLARATIONS(SVGExternalResourcesRequired
, bool, ExternalResourcesRequired
, externalResourcesRequired
)
158 ANIMATED_PROPERTY_FORWARD_DECLARATIONS(SVGFitToViewBox
, FloatRect
, ViewBox
, viewBox
)
159 ANIMATED_PROPERTY_FORWARD_DECLARATIONS(SVGFitToViewBox
, SVGPreserveAspectRatio
*, PreserveAspectRatio
, preserveAspectRatio
)
161 ANIMATED_PROPERTY_DECLARATIONS(SVGSVGElement
, SVGLength
, SVGLength
, X
, x
)
162 ANIMATED_PROPERTY_DECLARATIONS(SVGSVGElement
, SVGLength
, SVGLength
, Y
, y
)
163 ANIMATED_PROPERTY_DECLARATIONS(SVGSVGElement
, SVGLength
, SVGLength
, Width
, width
)
164 ANIMATED_PROPERTY_DECLARATIONS(SVGSVGElement
, SVGLength
, SVGLength
, Height
, height
)
166 virtual void willSaveToCache();
167 virtual void willRestoreFromCache();
169 bool m_useCurrentView
;
170 /*RefPtr<SMILTimeContainer> m_timeContainer;*/
171 FloatPoint m_translation
;
172 mutable OwnPtr
<SVGViewSpec
> m_viewSpec
;
173 IntSize m_containerSize
;
174 bool m_hasSetContainerSize
;
177 } // namespace WebCore
179 #endif // ENABLE(SVG)