File indexing completed on 2024-04-28 15:24:41

0001 /*
0002     Copyright (C) 2004, 2005, 2006 Nikolas Zimmermann <zimmermann@kde.org>
0003                   2004, 2005, 2006, 2007 Rob Buis <buis@kde.org>
0004 
0005     This file is part of the KDE project
0006 
0007     This library is free software; you can redistribute it and/or
0008     modify it under the terms of the GNU Library General Public
0009     License as published by the Free Software Foundation; either
0010     version 2 of the License, or (at your option) any later version.
0011 
0012     This library is distributed in the hope that it will be useful,
0013     but WITHOUT ANY WARRANTY; without even the implied warranty of
0014     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0015     Library General Public License for more details.
0016 
0017     You should have received a copy of the GNU Library General Public License
0018     along with this library; see the file COPYING.LIB.  If not, write to
0019     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
0020     Boston, MA 02110-1301, USA.
0021 */
0022 
0023 #ifndef SVGSVGElement_h
0024 #define SVGSVGElement_h
0025 
0026 #if ENABLE(SVG)
0027 
0028 #include "FloatRect.h"
0029 
0030 #include "IntSize.h"
0031 #include "SVGExternalResourcesRequired.h"
0032 #include "SVGFitToViewBox.h"
0033 #include "SVGLangSpace.h"
0034 #include "SVGStyledLocatableElement.h"
0035 #include "SVGTests.h"
0036 #include "SVGZoomAndPan.h"
0037 
0038 namespace WebCore
0039 {
0040 class SVGAngle;
0041 class SVGLength;
0042 class SVGTransform;
0043 class SVGViewSpec;
0044 /*class SVGViewElement;
0045 class SMILTimeContainer;*/
0046 class SVGSVGElement : public SVGStyledLocatableElement,
0047     public SVGTests,
0048     public SVGLangSpace,
0049     public SVGExternalResourcesRequired,
0050     public SVGFitToViewBox,
0051     public SVGZoomAndPan
0052 {
0053 public:
0054     SVGSVGElement(const QualifiedName &, Document *);
0055     virtual ~SVGSVGElement();
0056 
0057     bool isSVG() const override
0058     {
0059         return true;
0060     }
0061 
0062     bool isValid() const override
0063     {
0064         return SVGTests::isValid();
0065     }
0066 
0067     // 'SVGSVGElement' functions
0068     DOMString contentScriptType() const;
0069     void setContentScriptType(const DOMString &type);
0070 
0071     DOMString contentStyleType() const;
0072     void setContentStyleType(const DOMString &type);
0073 
0074     FloatRect viewport() const;
0075 
0076     IntSize containerSize() const;
0077     bool hasSetContainerSize() const;
0078     int relativeWidthValue() const;
0079     int relativeHeightValue() const;
0080 
0081     float pixelUnitToMillimeterX() const;
0082     float pixelUnitToMillimeterY() const;
0083     float screenPixelToMillimeterX() const;
0084     float screenPixelToMillimeterY() const;
0085 
0086     bool useCurrentView() const;
0087     void setUseCurrentView(bool currentView);
0088 
0089     SVGViewSpec *currentView() const;
0090 
0091     float currentScale() const;
0092     void setCurrentScale(float scale);
0093 
0094     FloatPoint currentTranslate() const;
0095     void setCurrentTranslate(const FloatPoint &);
0096 
0097     /*SMILTimeContainer* timeContainer() const { return m_timeContainer.get(); }*/
0098 
0099     void pauseAnimations();
0100     void unpauseAnimations();
0101     bool animationsPaused() const;
0102 
0103     float getCurrentTime() const;
0104     void setCurrentTime(float seconds);
0105 
0106     unsigned long suspendRedraw(unsigned long max_wait_milliseconds);
0107     void unsuspendRedraw(unsigned long suspend_handle_id, ExceptionCode &);
0108     void unsuspendRedrawAll();
0109     void forceRedraw();
0110 
0111     DOM::NodeListImpl *getIntersectionList(const FloatRect &, SVGElement *referenceElement);
0112     DOM::NodeListImpl *getEnclosureList(const FloatRect &, SVGElement *referenceElement);
0113     bool checkIntersection(SVGElement *, const FloatRect &);
0114     bool checkEnclosure(SVGElement *, const FloatRect &);
0115     void deselectAll();
0116 
0117     static float createSVGNumber();
0118     static SVGLength createSVGLength();
0119     static SVGAngle *createSVGAngle();
0120     static FloatPoint createSVGPoint();
0121     static AffineTransform createSVGMatrix();
0122     static FloatRect createSVGRect();
0123     static SVGTransform createSVGTransform();
0124     static SVGTransform createSVGTransformFromMatrix(const AffineTransform &);
0125 
0126     void parseMappedAttribute(MappedAttribute *) override;
0127 
0128     // 'virtual SVGLocatable' functions
0129     AffineTransform getCTM() const override;
0130     AffineTransform getScreenCTM() const override;
0131 
0132     bool rendererIsNeeded(RenderStyle *style) override
0133     {
0134         return StyledElement::rendererIsNeeded(style);
0135     }
0136     RenderObject *createRenderer(RenderArena *, RenderStyle *) override;
0137 
0138     void insertedIntoDocument() override;
0139     void removedFromDocument() override;
0140 
0141     void svgAttributeChanged(const QualifiedName &) override;
0142 
0143     AffineTransform viewBoxToViewTransform(float viewWidth, float viewHeight) const override;
0144 
0145     //void inheritViewAttributes(SVGViewElement*);
0146 
0147     // KHTML ElementImpl pure virtual method
0148     quint32 id() const override;
0149 protected:
0150     const SVGElement *contextElement() const override
0151     {
0152         return this;
0153     }
0154 
0155     friend class RenderSVGRoot;
0156     /*friend class RenderSVGViewportContainer;*/
0157 
0158     bool hasRelativeValues() const override;
0159 
0160     bool isOutermostSVG() const;
0161 
0162 private:
0163     void addSVGWindowEventListener(const AtomicString &eventType, const Attribute *attr);
0164 
0165     ANIMATED_PROPERTY_FORWARD_DECLARATIONS(SVGExternalResourcesRequired, bool, ExternalResourcesRequired, externalResourcesRequired)
0166     ANIMATED_PROPERTY_FORWARD_DECLARATIONS(SVGFitToViewBox, FloatRect, ViewBox, viewBox)
0167     ANIMATED_PROPERTY_FORWARD_DECLARATIONS(SVGFitToViewBox, SVGPreserveAspectRatio *, PreserveAspectRatio, preserveAspectRatio)
0168 
0169     ANIMATED_PROPERTY_DECLARATIONS(SVGSVGElement, SVGLength, SVGLength, X, x)
0170     ANIMATED_PROPERTY_DECLARATIONS(SVGSVGElement, SVGLength, SVGLength, Y, y)
0171     ANIMATED_PROPERTY_DECLARATIONS(SVGSVGElement, SVGLength, SVGLength, Width, width)
0172     ANIMATED_PROPERTY_DECLARATIONS(SVGSVGElement, SVGLength, SVGLength, Height, height)
0173 
0174     virtual void willSaveToCache();
0175     virtual void willRestoreFromCache();
0176 
0177     bool m_useCurrentView;
0178     /*RefPtr<SMILTimeContainer> m_timeContainer;*/
0179     FloatPoint m_translation;
0180     mutable OwnPtr<SVGViewSpec> m_viewSpec;
0181 };
0182 
0183 } // namespace WebCore
0184 
0185 #endif // ENABLE(SVG)
0186 #endif
0187