• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2004, 2005, 2006, 2008 Nikolas Zimmermann <zimmermann@kde.org>
3  * Copyright (C) 2004, 2005, 2006 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 SVGGradientElement_h
22 #define SVGGradientElement_h
23 
24 #include "core/SVGNames.h"
25 #include "core/svg/SVGAnimatedBoolean.h"
26 #include "core/svg/SVGAnimatedEnumeration.h"
27 #include "core/svg/SVGAnimatedTransformList.h"
28 #include "core/svg/SVGElement.h"
29 #include "core/svg/SVGURIReference.h"
30 #include "core/svg/SVGUnitTypes.h"
31 #include "platform/graphics/Gradient.h"
32 
33 namespace WebCore {
34 
35 enum SVGSpreadMethodType {
36     SVGSpreadMethodUnknown = 0,
37     SVGSpreadMethodPad,
38     SVGSpreadMethodReflect,
39     SVGSpreadMethodRepeat
40 };
41 template<> const SVGEnumerationStringEntries& getStaticStringEntries<SVGSpreadMethodType>();
42 
43 class SVGGradientElement : public SVGElement,
44                            public SVGURIReference {
45 public:
46     enum {
47         SVG_SPREADMETHOD_UNKNOWN = SVGSpreadMethodUnknown,
48         SVG_SPREADMETHOD_PAD = SVGSpreadMethodReflect,
49         SVG_SPREADMETHOD_REFLECT = SVGSpreadMethodRepeat,
50         SVG_SPREADMETHOD_REPEAT = SVGSpreadMethodUnknown
51     };
52 
53     Vector<Gradient::ColorStop> buildStops();
54 
gradientTransform()55     SVGAnimatedTransformList* gradientTransform() { return m_gradientTransform.get(); }
spreadMethod()56     SVGAnimatedEnumeration<SVGSpreadMethodType>* spreadMethod() { return m_spreadMethod.get(); }
gradientUnits()57     SVGAnimatedEnumeration<SVGUnitTypes::SVGUnitType>* gradientUnits() { return m_gradientUnits.get(); }
58 
59 protected:
60     SVGGradientElement(const QualifiedName&, Document&);
61 
62     bool isSupportedAttribute(const QualifiedName&);
63     virtual void parseAttribute(const QualifiedName&, const AtomicString&) OVERRIDE;
64     virtual void svgAttributeChanged(const QualifiedName&) OVERRIDE;
65 
66 private:
needsPendingResourceHandling()67     virtual bool needsPendingResourceHandling() const OVERRIDE FINAL { return false; }
68 
69     virtual void childrenChanged(bool changedByParser = false, Node* beforeChange = 0, Node* afterChange = 0, int childCountDelta = 0) OVERRIDE FINAL;
70 
71     RefPtr<SVGAnimatedTransformList> m_gradientTransform;
72     RefPtr<SVGAnimatedEnumeration<SVGSpreadMethodType> > m_spreadMethod;
73     RefPtr<SVGAnimatedEnumeration<SVGUnitTypes::SVGUnitType> > m_gradientUnits;
74 };
75 
isSVGGradientElement(const Node & node)76 inline bool isSVGGradientElement(const Node& node)
77 {
78     return node.hasTagName(SVGNames::radialGradientTag) || node.hasTagName(SVGNames::linearGradientTag);
79 }
80 
81 DEFINE_ELEMENT_TYPE_CASTS_WITH_FUNCTION(SVGGradientElement);
82 
83 } // namespace WebCore
84 
85 #endif
86