• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2     Copyright (C) 2004, 2005, 2006, 2008 Nikolas Zimmermann <zimmermann@kde.org>
3                   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 SVGPatternElement_h
22 #define SVGPatternElement_h
23 
24 #if ENABLE(SVG)
25 #include "RenderObject.h"
26 #include "SVGExternalResourcesRequired.h"
27 #include "SVGFitToViewBox.h"
28 #include "SVGLangSpace.h"
29 #include "SVGPaintServerPattern.h"
30 #include "SVGStyledElement.h"
31 #include "SVGTests.h"
32 #include "SVGTransformList.h"
33 #include "SVGURIReference.h"
34 
35 namespace WebCore {
36 
37     struct PatternAttributes;
38 
39     class SVGLength;
40 
41     class SVGPatternElement : public SVGStyledElement,
42                               public SVGURIReference,
43                               public SVGTests,
44                               public SVGLangSpace,
45                               public SVGExternalResourcesRequired,
46                               public SVGFitToViewBox {
47     public:
48         SVGPatternElement(const QualifiedName&, Document*);
49         virtual ~SVGPatternElement();
50 
isValid()51         virtual bool isValid() const { return SVGTests::isValid(); }
52 
53         virtual void parseMappedAttribute(MappedAttribute*);
54         virtual void svgAttributeChanged(const QualifiedName&);
55         virtual void synchronizeProperty(const QualifiedName&);
56         virtual void childrenChanged(bool changedByParser = false, Node* beforeChange = 0, Node* afterChange = 0, int childCountDelta = 0);
57 
58         virtual RenderObject* createRenderer(RenderArena*, RenderStyle*);
59         virtual SVGResource* canvasResource(const RenderObject*);
60 
61     private:
62         DECLARE_ANIMATED_PROPERTY(SVGPatternElement, SVGNames::xAttr, SVGLength, X, x)
63         DECLARE_ANIMATED_PROPERTY(SVGPatternElement, SVGNames::yAttr, SVGLength, Y, y)
64         DECLARE_ANIMATED_PROPERTY(SVGPatternElement, SVGNames::widthAttr, SVGLength, Width, width)
65         DECLARE_ANIMATED_PROPERTY(SVGPatternElement, SVGNames::heightAttr, SVGLength, Height, height)
66         DECLARE_ANIMATED_PROPERTY(SVGPatternElement, SVGNames::patternUnitsAttr, int, PatternUnits, patternUnits)
67         DECLARE_ANIMATED_PROPERTY(SVGPatternElement, SVGNames::patternContentUnitsAttr, int, PatternContentUnits, patternContentUnits)
68         DECLARE_ANIMATED_PROPERTY(SVGPatternElement, SVGNames::patternTransformAttr, SVGTransformList*, PatternTransform, patternTransform)
69 
70         // SVGURIReference
71         DECLARE_ANIMATED_PROPERTY(SVGPatternElement, XLinkNames::hrefAttr, String, Href, href)
72 
73         // SVGExternalResourcesRequired
74         DECLARE_ANIMATED_PROPERTY(SVGPatternElement, SVGNames::externalResourcesRequiredAttr, bool, ExternalResourcesRequired, externalResourcesRequired)
75 
76         // SVGPatternElement
77         DECLARE_ANIMATED_PROPERTY(SVGPatternElement, SVGNames::viewBoxAttr, FloatRect, ViewBox, viewBox)
78         DECLARE_ANIMATED_PROPERTY(SVGPatternElement, SVGNames::preserveAspectRatioAttr, SVGPreserveAspectRatio, PreserveAspectRatio, preserveAspectRatio)
79 
80         mutable RefPtr<SVGPaintServerPattern> m_resource;
81 
82     private:
83         friend class SVGPaintServerPattern;
84         void buildPattern(const FloatRect& targetRect) const;
85 
86         PatternAttributes collectPatternProperties() const;
87     };
88 
89 } // namespace WebCore
90 
91 #endif // ENABLE(SVG)
92 #endif
93