1 /* 2 * Copyright (C) 2004, 2005, 2006 Nikolas Zimmermann <zimmermann@kde.org> 3 * Copyright (C) 2004, 2005, 2006, 2007, 2010 Rob Buis <buis@kde.org> 4 * Copyright (C) 2014 Google, Inc. 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 SVGSVGElement_h 23 #define SVGSVGElement_h 24 25 #include "core/svg/SVGAnimatedBoolean.h" 26 #include "core/svg/SVGAnimatedLength.h" 27 #include "core/svg/SVGFitToViewBox.h" 28 #include "core/svg/SVGGraphicsElement.h" 29 #include "core/svg/SVGLengthTearOff.h" 30 #include "core/svg/SVGPointTearOff.h" 31 #include "core/svg/SVGZoomAndPan.h" 32 33 namespace WebCore { 34 35 class SVGMatrixTearOff; 36 class SVGAngleTearOff; 37 class SVGNumberTearOff; 38 class SVGTransformTearOff; 39 class SVGViewSpec; 40 class SVGViewElement; 41 class SMILTimeContainer; 42 43 class SVGSVGElement FINAL : public SVGGraphicsElement, 44 public SVGFitToViewBox, 45 public SVGZoomAndPan { 46 public: 47 DECLARE_NODE_FACTORY(SVGSVGElement); 48 49 #if !ENABLE(OILPAN) 50 using SVGGraphicsElement::ref; 51 using SVGGraphicsElement::deref; 52 #endif 53 54 // 'SVGSVGElement' functions 55 PassRefPtr<SVGRectTearOff> viewport() const; 56 57 float pixelUnitToMillimeterX() const; 58 float pixelUnitToMillimeterY() const; 59 float screenPixelToMillimeterX() const; 60 float screenPixelToMillimeterY() const; 61 useCurrentView()62 bool useCurrentView() const { return m_useCurrentView; } 63 SVGViewSpec* currentView(); 64 65 Length intrinsicWidth() const; 66 Length intrinsicHeight() const; 67 FloatSize currentViewportSize() const; 68 FloatRect currentViewBoxRect() const; 69 70 float currentScale() const; 71 void setCurrentScale(float scale); 72 currentTranslate()73 FloatPoint currentTranslate() { return m_translation->value(); } 74 void setCurrentTranslate(const FloatPoint&); 75 PassRefPtr<SVGPointTearOff> currentTranslateFromJavascript(); 76 timeContainer()77 SMILTimeContainer* timeContainer() const { return m_timeContainer.get(); } 78 79 void pauseAnimations(); 80 void unpauseAnimations(); 81 bool animationsPaused() const; 82 83 float getCurrentTime() const; 84 void setCurrentTime(float seconds); 85 86 // Stubs for the deprecated 'redraw' interface. suspendRedraw(unsigned)87 unsigned suspendRedraw(unsigned) { return 1; } unsuspendRedraw(unsigned)88 void unsuspendRedraw(unsigned) { } unsuspendRedrawAll()89 void unsuspendRedrawAll() { } forceRedraw()90 void forceRedraw() { } 91 92 PassRefPtrWillBeRawPtr<StaticNodeList> getIntersectionList(PassRefPtr<SVGRectTearOff>, SVGElement* referenceElement) const; 93 PassRefPtrWillBeRawPtr<StaticNodeList> getEnclosureList(PassRefPtr<SVGRectTearOff>, SVGElement* referenceElement) const; 94 bool checkIntersection(SVGElement*, PassRefPtr<SVGRectTearOff>) const; 95 bool checkEnclosure(SVGElement*, PassRefPtr<SVGRectTearOff>) const; 96 void deselectAll(); 97 98 static PassRefPtr<SVGNumberTearOff> createSVGNumber(); 99 static PassRefPtr<SVGLengthTearOff> createSVGLength(); 100 static PassRefPtr<SVGAngleTearOff> createSVGAngle(); 101 static PassRefPtr<SVGPointTearOff> createSVGPoint(); 102 static PassRefPtr<SVGMatrixTearOff> createSVGMatrix(); 103 static PassRefPtr<SVGRectTearOff> createSVGRect(); 104 static PassRefPtr<SVGTransformTearOff> createSVGTransform(); 105 static PassRefPtr<SVGTransformTearOff> createSVGTransformFromMatrix(PassRefPtr<SVGMatrixTearOff>); 106 107 AffineTransform viewBoxToViewTransform(float viewWidth, float viewHeight) const; 108 109 void setupInitialView(const String& fragmentIdentifier, Element* anchorNode); 110 111 bool hasIntrinsicWidth() const; 112 bool hasIntrinsicHeight() const; 113 x()114 SVGAnimatedLength* x() const { return m_x.get(); } y()115 SVGAnimatedLength* y() const { return m_y.get(); } width()116 SVGAnimatedLength* width() const { return m_width.get(); } height()117 SVGAnimatedLength* height() const { return m_height.get(); } 118 119 virtual void trace(Visitor*) OVERRIDE; 120 121 private: 122 explicit SVGSVGElement(Document&); 123 virtual ~SVGSVGElement(); 124 125 virtual void parseAttribute(const QualifiedName&, const AtomicString&) OVERRIDE; 126 virtual bool isPresentationAttribute(const QualifiedName&) const OVERRIDE; 127 virtual void collectStyleForPresentationAttribute(const QualifiedName&, const AtomicString&, MutableStylePropertySet*) OVERRIDE; 128 129 virtual bool rendererIsNeeded(const RenderStyle&) OVERRIDE; 130 virtual RenderObject* createRenderer(RenderStyle*) OVERRIDE; 131 132 virtual InsertionNotificationRequest insertedInto(ContainerNode*) OVERRIDE; 133 virtual void removedFrom(ContainerNode*) OVERRIDE; 134 135 virtual void svgAttributeChanged(const QualifiedName&) OVERRIDE; 136 137 virtual bool selfHasRelativeLengths() const OVERRIDE; 138 139 void inheritViewAttributes(SVGViewElement*); 140 141 void updateCurrentTranslate(); 142 143 virtual void finishParsingChildren() OVERRIDE; 144 145 enum CheckIntersectionOrEnclosure { 146 CheckIntersection, 147 CheckEnclosure 148 }; 149 150 bool checkIntersectionOrEnclosure(const SVGElement&, const FloatRect&, CheckIntersectionOrEnclosure) const; 151 PassRefPtrWillBeRawPtr<StaticNodeList> collectIntersectionOrEnclosureList(const FloatRect&, SVGElement*, CheckIntersectionOrEnclosure) const; 152 153 RefPtr<SVGAnimatedLength> m_x; 154 RefPtr<SVGAnimatedLength> m_y; 155 RefPtr<SVGAnimatedLength> m_width; 156 RefPtr<SVGAnimatedLength> m_height; 157 158 virtual AffineTransform localCoordinateSpaceTransform(SVGElement::CTMScope) const OVERRIDE; 159 160 bool m_useCurrentView; 161 RefPtrWillBeMember<SMILTimeContainer> m_timeContainer; 162 RefPtr<SVGPoint> m_translation; 163 RefPtrWillBeMember<SVGViewSpec> m_viewSpec; 164 165 friend class SVGCurrentTranslateTearOff; 166 }; 167 168 } // namespace WebCore 169 170 #endif 171