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 class SVGAngle; 38 class SVGLength; 39 class SVGTransform; 40 class SVGViewSpec; 41 class SVGViewElement; 42 class SMILTimeContainer; 43 class SVGSVGElement : public SVGStyledLocatableElement, 44 public SVGTests, 45 public SVGLangSpace, 46 public SVGExternalResourcesRequired, 47 public SVGFitToViewBox, 48 public SVGZoomAndPan { 49 public: 50 SVGSVGElement(const QualifiedName&, Document*); 51 virtual ~SVGSVGElement(); 52 isSVG()53 virtual bool isSVG() const { return true; } 54 isValid()55 virtual bool isValid() const { return SVGTests::isValid(); } 56 57 // 'SVGSVGElement' functions 58 const AtomicString& contentScriptType() const; 59 void setContentScriptType(const AtomicString& type); 60 61 const AtomicString& contentStyleType() const; 62 void setContentStyleType(const AtomicString& type); 63 64 FloatRect viewport() const; 65 setContainerSize(const IntSize & containerSize)66 void setContainerSize(const IntSize& containerSize) { m_containerSize = containerSize; m_hasSetContainerSize = true; } containerSize()67 IntSize containerSize() const { return m_containerSize; } hasSetContainerSize()68 bool hasSetContainerSize() const { return m_hasSetContainerSize; } 69 int relativeWidthValue() const; 70 int relativeHeightValue() const; 71 72 float pixelUnitToMillimeterX() const; 73 float pixelUnitToMillimeterY() const; 74 float screenPixelToMillimeterX() const; 75 float screenPixelToMillimeterY() const; 76 77 bool useCurrentView() const; 78 void setUseCurrentView(bool currentView); 79 80 SVGViewSpec* currentView() const; 81 82 float currentScale() const; 83 void setCurrentScale(float scale); 84 85 FloatPoint currentTranslate() const; 86 void setCurrentTranslate(const FloatPoint&); 87 timeContainer()88 SMILTimeContainer* timeContainer() const { return m_timeContainer.get(); } 89 90 void pauseAnimations(); 91 void unpauseAnimations(); 92 bool animationsPaused() const; 93 94 float getCurrentTime() const; 95 void setCurrentTime(float seconds); 96 97 unsigned long suspendRedraw(unsigned long max_wait_milliseconds); 98 void unsuspendRedraw(unsigned long suspend_handle_id, ExceptionCode&); 99 void unsuspendRedrawAll(); 100 void forceRedraw(); 101 102 NodeList* getIntersectionList(const FloatRect&, SVGElement* referenceElement); 103 NodeList* getEnclosureList(const FloatRect&, SVGElement* referenceElement); 104 bool checkIntersection(SVGElement*, const FloatRect&); 105 bool checkEnclosure(SVGElement*, const FloatRect&); 106 void deselectAll(); 107 108 static float createSVGNumber(); 109 static SVGLength createSVGLength(); 110 static PassRefPtr<SVGAngle> createSVGAngle(); 111 static FloatPoint createSVGPoint(); 112 static TransformationMatrix createSVGMatrix(); 113 static FloatRect createSVGRect(); 114 static SVGTransform createSVGTransform(); 115 static SVGTransform createSVGTransformFromMatrix(const TransformationMatrix&); 116 117 virtual void parseMappedAttribute(MappedAttribute*); 118 119 // 'virtual SVGLocatable' functions 120 virtual TransformationMatrix getCTM() const; 121 virtual TransformationMatrix getScreenCTM() const; 122 rendererIsNeeded(RenderStyle * style)123 virtual bool rendererIsNeeded(RenderStyle* style) { return StyledElement::rendererIsNeeded(style); } 124 virtual RenderObject* createRenderer(RenderArena*, RenderStyle*); 125 126 virtual void insertedIntoDocument(); 127 virtual void removedFromDocument(); 128 129 virtual void svgAttributeChanged(const QualifiedName&); 130 131 virtual TransformationMatrix viewBoxToViewTransform(float viewWidth, float viewHeight) const; 132 133 void inheritViewAttributes(SVGViewElement*); 134 135 protected: contextElement()136 virtual const SVGElement* contextElement() const { return this; } 137 138 friend class RenderSVGRoot; 139 friend class RenderSVGViewportContainer; 140 141 virtual bool hasRelativeValues() const; 142 143 bool isOutermostSVG() const; 144 145 private: 146 ANIMATED_PROPERTY_DECLARATIONS(SVGSVGElement, SVGNames::svgTagString, SVGNames::xAttrString, SVGLength, X, x) 147 ANIMATED_PROPERTY_DECLARATIONS(SVGSVGElement, SVGNames::svgTagString, SVGNames::yAttrString, SVGLength, Y, y) 148 ANIMATED_PROPERTY_DECLARATIONS(SVGSVGElement, SVGNames::svgTagString, SVGNames::widthAttrString, SVGLength, Width, width) 149 ANIMATED_PROPERTY_DECLARATIONS(SVGSVGElement, SVGNames::svgTagString, SVGNames::heightAttrString, SVGLength, Height, height) 150 151 virtual void documentWillBecomeInactive(); 152 virtual void documentDidBecomeActive(); 153 154 bool m_useCurrentView; 155 RefPtr<SMILTimeContainer> m_timeContainer; 156 FloatPoint m_translation; 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