1/*
2    Copyright (C) 2005 Alexander Kellett <lypanov@kde.org>
3
4    This library is free software; you can redistribute it and/or
5    modify it under the terms of the GNU Library General Public
6    License as published by the Free Software Foundation; either
7    version 2 of the License, or (at your option) any later version.
8
9    This library is distributed in the hope that it will be useful,
10    but WITHOUT ANY WARRANTY; without even the implied warranty of
11    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12    Library General Public License for more details.
13
14    You should have received a copy of the GNU Library General Public License
15    along with this library; see the file COPYING.LIB.  If not, write to
16    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17    Boston, MA 02110-1301, USA.
18*/
19
20#ifndef SVGMaskElement_h
21#define SVGMaskElement_h
22
23#if ENABLE(SVG)
24#include "RenderObject.h"
25#include "SVGResourceMasker.h"
26#include "SVGExternalResourcesRequired.h"
27#include "SVGLangSpace.h"
28#include "SVGStyledLocatableElement.h"
29#include "SVGTests.h"
30#include "SVGURIReference.h"
31#include <wtf/HashMap.h>
32#include <wtf/PassOwnPtr.h>
33
34namespace WebCore {
35
36    class SVGLength;
37    class SVGResourceMasker;
38
39    class SVGMaskElement : public SVGStyledLocatableElement,
40                           public SVGURIReference,
41                           public SVGTests,
42                           public SVGLangSpace,
43                           public SVGExternalResourcesRequired {
44    public:
45        SVGMaskElement(const QualifiedName&, Document*);
46        virtual ~SVGMaskElement();
47        virtual bool isValid() const { return SVGTests::isValid(); }
48
49        FloatRect maskBoundingBox(const FloatRect&) const;
50        virtual void parseMappedAttribute(MappedAttribute*);
51        virtual void svgAttributeChanged(const QualifiedName&);
52        virtual void synchronizeProperty(const QualifiedName&);
53        virtual void childrenChanged(bool changedByParser = false, Node* beforeChange = 0, Node* afterChange = 0, int childCountDelta = 0);
54
55        virtual RenderObject* createRenderer(RenderArena*, RenderStyle*);
56        virtual SVGResource* canvasResource(const RenderObject*);
57
58        PassOwnPtr<ImageBuffer> drawMaskerContent(const RenderObject*, FloatRect& maskRect, bool& emptyMask) const;
59
60    private:
61        DECLARE_ANIMATED_PROPERTY(SVGMaskElement, SVGNames::maskUnitsAttr, int, MaskUnits, maskUnits)
62        DECLARE_ANIMATED_PROPERTY(SVGMaskElement, SVGNames::maskContentUnitsAttr, int, MaskContentUnits, maskContentUnits)
63        DECLARE_ANIMATED_PROPERTY(SVGMaskElement, SVGNames::xAttr, SVGLength, X, x)
64        DECLARE_ANIMATED_PROPERTY(SVGMaskElement, SVGNames::yAttr, SVGLength, Y, y)
65        DECLARE_ANIMATED_PROPERTY(SVGMaskElement, SVGNames::widthAttr, SVGLength, Width, width)
66        DECLARE_ANIMATED_PROPERTY(SVGMaskElement, SVGNames::heightAttr, SVGLength, Height, height)
67
68        // SVGURIReference
69        DECLARE_ANIMATED_PROPERTY(SVGMaskElement, XLinkNames::hrefAttr, String, Href, href)
70
71        // SVGExternalResourcesRequired
72        DECLARE_ANIMATED_PROPERTY(SVGMaskElement, SVGNames::externalResourcesRequiredAttr, bool, ExternalResourcesRequired, externalResourcesRequired)
73
74        virtual void invalidateCanvasResources();
75
76        HashMap<const RenderObject*, RefPtr<SVGResourceMasker> > m_masker;
77    };
78
79} // namespace WebCore
80
81#endif // ENABLE(SVG)
82#endif
83