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

0001 /*
0002     Copyright (C) 2005 Alexander Kellett <lypanov@kde.org>
0003 
0004     This file is part of the KDE project
0005 
0006     This library is free software; you can redistribute it and/or
0007     modify it under the terms of the GNU Library General Public
0008     License as published by the Free Software Foundation; either
0009     version 2 of the License, or (at your option) any later version.
0010 
0011     This library is distributed in the hope that it will be useful,
0012     but WITHOUT ANY WARRANTY; without even the implied warranty of
0013     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0014     Library General Public License for more details.
0015 
0016     You should have received a copy of the GNU Library General Public License
0017     along with this library; see the file COPYING.LIB.  If not, write to
0018     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
0019     Boston, MA 02110-1301, USA.
0020 */
0021 
0022 #ifndef SVGMaskElement_h
0023 #define SVGMaskElement_h
0024 
0025 #if ENABLE(SVG)
0026 #include "SVGResourceMasker.h"
0027 #include "SVGExternalResourcesRequired.h"
0028 #include "SVGLangSpace.h"
0029 #include "SVGStyledLocatableElement.h"
0030 #include "SVGTests.h"
0031 #include "SVGURIReference.h"
0032 
0033 namespace WebCore
0034 {
0035 
0036 class SVGLength;
0037 
0038 class SVGMaskElement : public SVGStyledLocatableElement,
0039     public SVGURIReference,
0040     public SVGTests,
0041     public SVGLangSpace,
0042     public SVGExternalResourcesRequired
0043 {
0044 public:
0045     SVGMaskElement(const QualifiedName &, Document *);
0046     virtual ~SVGMaskElement();
0047     virtual bool isValid() const
0048     {
0049         return SVGTests::isValid();
0050     }
0051 
0052     virtual void parseMappedAttribute(MappedAttribute *);
0053     virtual void svgAttributeChanged(const QualifiedName &);
0054     virtual void childrenChanged(bool changedByParser = false, Node *beforeChange = 0, Node *afterChange = 0, int childCountDelta = 0);
0055 
0056     virtual RenderObject *createRenderer(RenderArena *, RenderStyle *);
0057     virtual SVGResource *canvasResource();
0058 
0059     std::unique_ptr<ImageBuffer> drawMaskerContent(const FloatRect &targetRect, FloatRect &maskRect) const;
0060 
0061 protected:
0062     ANIMATED_PROPERTY_FORWARD_DECLARATIONS(SVGURIReference, String, Href, href)
0063     ANIMATED_PROPERTY_FORWARD_DECLARATIONS(SVGExternalResourcesRequired, bool, ExternalResourcesRequired, externalResourcesRequired)
0064 
0065     ANIMATED_PROPERTY_DECLARATIONS(SVGMaskElement, int, int, MaskUnits, maskUnits)
0066     ANIMATED_PROPERTY_DECLARATIONS(SVGMaskElement, int, int, MaskContentUnits, maskContentUnits)
0067 
0068     ANIMATED_PROPERTY_DECLARATIONS(SVGMaskElement, SVGLength, SVGLength, X, x)
0069     ANIMATED_PROPERTY_DECLARATIONS(SVGMaskElement, SVGLength, SVGLength, Y, y)
0070     ANIMATED_PROPERTY_DECLARATIONS(SVGMaskElement, SVGLength, SVGLength, Width, width)
0071     ANIMATED_PROPERTY_DECLARATIONS(SVGMaskElement, SVGLength, SVGLength, Height, height)
0072 
0073     virtual const SVGElement *contextElement() const
0074     {
0075         return this;
0076     }
0077 
0078 private:
0079     RefPtr<SVGResourceMasker> m_masker;
0080 };
0081 
0082 } // namespace WebCore
0083 
0084 #endif // ENABLE(SVG)
0085 #endif