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 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13 * Library General Public License for more details.
14 *
15 * You should have received a copy of the GNU Library General Public License
16 * along with this library; see the file COPYING.LIB.  If not, write to
17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 * Boston, MA 02110-1301, USA.
19 */
20
21#ifndef SVGGraphicsElement_h
22#define SVGGraphicsElement_h
23
24#include "SVGAnimatedTransformList.h"
25#include "SVGElement.h"
26#include "SVGTests.h"
27#include "SVGTransformable.h"
28
29namespace WebCore {
30
31class AffineTransform;
32class Path;
33
34class SVGGraphicsElement : public SVGElement, public SVGTransformable, public SVGTests {
35public:
36    virtual ~SVGGraphicsElement();
37
38    virtual AffineTransform getCTM(StyleUpdateStrategy = AllowStyleUpdate) override;
39    virtual AffineTransform getScreenCTM(StyleUpdateStrategy = AllowStyleUpdate) override;
40    virtual SVGElement* nearestViewportElement() const override;
41    virtual SVGElement* farthestViewportElement() const override;
42
43    virtual AffineTransform localCoordinateSpaceTransform(SVGLocatable::CTMScope mode) const override { return SVGTransformable::localCoordinateSpaceTransform(mode); }
44    virtual AffineTransform animatedLocalTransform() const override;
45    virtual AffineTransform* supplementalTransform() override;
46
47    virtual FloatRect getBBox(StyleUpdateStrategy = AllowStyleUpdate) override;
48
49    bool shouldIsolateBlending() const { return m_shouldIsolateBlending; }
50    void setShouldIsolateBlending(bool isolate) { m_shouldIsolateBlending = isolate; }
51
52    // "base class" methods for all the elements which render as paths
53    virtual void toClipPath(Path&);
54    virtual RenderPtr<RenderElement> createElementRenderer(PassRef<RenderStyle>) override;
55
56protected:
57    SVGGraphicsElement(const QualifiedName&, Document&);
58
59    bool isSupportedAttribute(const QualifiedName&);
60
61    virtual bool supportsFocus() const override { return Element::supportsFocus() || hasFocusEventListeners(); }
62
63    virtual void parseAttribute(const QualifiedName&, const AtomicString&) override;
64    virtual void svgAttributeChanged(const QualifiedName&) override;
65
66    BEGIN_DECLARE_ANIMATED_PROPERTIES(SVGGraphicsElement)
67        DECLARE_ANIMATED_TRANSFORM_LIST(Transform, transform)
68    END_DECLARE_ANIMATED_PROPERTIES
69
70private:
71    virtual bool isSVGGraphicsElement() const override { return true; }
72
73    // SVGTests
74    virtual void synchronizeRequiredFeatures() override { SVGTests::synchronizeRequiredFeatures(this); }
75    virtual void synchronizeRequiredExtensions() override { SVGTests::synchronizeRequiredExtensions(this); }
76    virtual void synchronizeSystemLanguage() override { SVGTests::synchronizeSystemLanguage(this); }
77
78    // Used by <animateMotion>
79    std::unique_ptr<AffineTransform> m_supplementalTransform;
80
81    // Used to isolate blend operations caused by masking.
82    bool m_shouldIsolateBlending;
83};
84
85void isSVGGraphicsElement(const SVGGraphicsElement&); // Catch unnecessary runtime check of type known at compile time.
86inline bool isSVGGraphicsElement(const SVGElement& element) { return element.isSVGGraphicsElement(); }
87inline bool isSVGGraphicsElement(const Node& node) { return node.isSVGElement() && toSVGElement(node).isSVGGraphicsElement(); }
88NODE_TYPE_CASTS(SVGGraphicsElement)
89
90} // namespace WebCore
91
92#endif // SVGGraphicsElement_h
93