2 * Copyright (C) 2004, 2005, 2006, 2008 Nikolas Zimmermann <zimmermann@kde.org>
3 * Copyright (C) 2004, 2005, 2006 Rob Buis <buis@kde.org>
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.
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.
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.
21 #ifndef SVGGradientElement_h
22 #define SVGGradientElement_h
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"
35 enum SVGSpreadMethodType {
36 SVGSpreadMethodUnknown = 0,
38 SVGSpreadMethodReflect,
41 template<> const SVGEnumerationStringEntries& getStaticStringEntries<SVGSpreadMethodType>();
43 class SVGGradientElement : public SVGElement,
44 public SVGURIReference {
45 DEFINE_WRAPPERTYPEINFO();
48 SVG_SPREADMETHOD_UNKNOWN = SVGSpreadMethodUnknown,
49 SVG_SPREADMETHOD_PAD = SVGSpreadMethodReflect,
50 SVG_SPREADMETHOD_REFLECT = SVGSpreadMethodRepeat,
51 SVG_SPREADMETHOD_REPEAT = SVGSpreadMethodUnknown
54 Vector<Gradient::ColorStop> buildStops();
56 SVGAnimatedTransformList* gradientTransform() { return m_gradientTransform.get(); }
57 SVGAnimatedEnumeration<SVGSpreadMethodType>* spreadMethod() { return m_spreadMethod.get(); }
58 SVGAnimatedEnumeration<SVGUnitTypes::SVGUnitType>* gradientUnits() { return m_gradientUnits.get(); }
61 SVGGradientElement(const QualifiedName&, Document&);
63 bool isSupportedAttribute(const QualifiedName&);
64 virtual void parseAttribute(const QualifiedName&, const AtomicString&) override;
65 virtual void svgAttributeChanged(const QualifiedName&) override;
68 virtual bool needsPendingResourceHandling() const override final { return false; }
70 virtual void childrenChanged(const ChildrenChange&) override final;
72 RefPtr<SVGAnimatedTransformList> m_gradientTransform;
73 RefPtr<SVGAnimatedEnumeration<SVGSpreadMethodType> > m_spreadMethod;
74 RefPtr<SVGAnimatedEnumeration<SVGUnitTypes::SVGUnitType> > m_gradientUnits;
77 inline bool isSVGGradientElement(const SVGElement& element)
79 return element.hasTagName(SVGNames::radialGradientTag) || element.hasTagName(SVGNames::linearGradientTag);
82 DEFINE_SVGELEMENT_TYPE_CASTS_WITH_FUNCTION(SVGGradientElement);
86 #endif // SVGGradientElement_h