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