Home | History | Annotate | Download | only in svg
      1 /*
      2  * Copyright (C) 2004, 2005, 2008 Nikolas Zimmermann <zimmermann (at) kde.org>
      3  * Copyright (C) 2004, 2005, 2006, 2007 Rob Buis <buis (at) 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 SVGGraphicsElement_h
     23 #define SVGGraphicsElement_h
     24 
     25 #include "core/svg/SVGAnimatedTransformList.h"
     26 #include "core/svg/SVGElement.h"
     27 #include "core/svg/SVGRectTearOff.h"
     28 #include "core/svg/SVGTests.h"
     29 
     30 namespace blink {
     31 
     32 class AffineTransform;
     33 class Path;
     34 class SVGMatrixTearOff;
     35 
     36 class SVGGraphicsElement : public SVGElement, public SVGTests {
     37     DEFINE_WRAPPERTYPEINFO();
     38 public:
     39     virtual ~SVGGraphicsElement();
     40 
     41     enum StyleUpdateStrategy { AllowStyleUpdate, DisallowStyleUpdate };
     42 
     43     AffineTransform getCTM(StyleUpdateStrategy = AllowStyleUpdate);
     44     AffineTransform getScreenCTM(StyleUpdateStrategy = AllowStyleUpdate);
     45     PassRefPtr<SVGMatrixTearOff> getCTMFromJavascript();
     46     PassRefPtr<SVGMatrixTearOff> getScreenCTMFromJavascript();
     47 
     48     PassRefPtr<SVGMatrixTearOff> getTransformToElement(SVGElement*, ExceptionState&);
     49 
     50     SVGElement* nearestViewportElement() const;
     51     SVGElement* farthestViewportElement() const;
     52 
     53     virtual AffineTransform localCoordinateSpaceTransform(SVGElement::CTMScope) const OVERRIDE { return animatedLocalTransform(); }
     54     virtual AffineTransform animatedLocalTransform() const;
     55     virtual AffineTransform* supplementalTransform() OVERRIDE;
     56 
     57     virtual FloatRect getBBox();
     58     PassRefPtr<SVGRectTearOff> getBBoxFromJavascript();
     59 
     60     // "base class" methods for all the elements which render as paths
     61     virtual void toClipPath(Path&);
     62     virtual RenderObject* createRenderer(RenderStyle*) OVERRIDE;
     63 
     64     virtual bool isValid() const OVERRIDE FINAL { return SVGTests::isValid(); }
     65 
     66     SVGAnimatedTransformList* transform() { return m_transform.get(); }
     67     const SVGAnimatedTransformList* transform() const { return m_transform.get(); }
     68 
     69     AffineTransform computeCTM(SVGElement::CTMScope mode, SVGGraphicsElement::StyleUpdateStrategy,
     70         const SVGGraphicsElement* ancestor = 0) const;
     71 
     72 protected:
     73     SVGGraphicsElement(const QualifiedName&, Document&, ConstructionType = CreateSVGElement);
     74 
     75     virtual bool supportsFocus() const OVERRIDE { return Element::supportsFocus() || hasFocusEventListeners(); }
     76 
     77     bool isSupportedAttribute(const QualifiedName&);
     78     virtual void parseAttribute(const QualifiedName&, const AtomicString&) OVERRIDE;
     79     virtual void svgAttributeChanged(const QualifiedName&) OVERRIDE;
     80 
     81     RefPtr<SVGAnimatedTransformList> m_transform;
     82 
     83 private:
     84     virtual bool isSVGGraphicsElement() const OVERRIDE FINAL { return true; }
     85 
     86     // Used by <animateMotion>
     87     OwnPtr<AffineTransform> m_supplementalTransform;
     88 };
     89 
     90 inline bool isSVGGraphicsElement(const SVGElement& element)
     91 {
     92     return element.isSVGGraphicsElement();
     93 }
     94 
     95 DEFINE_SVGELEMENT_TYPE_CASTS_WITH_FUNCTION(SVGGraphicsElement);
     96 
     97 } // namespace blink
     98 
     99 #endif // SVGGraphicsElement_h
    100