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