1 /* 2 * Copyright (C) 2004, 2005, 2006, 2008 Nikolas Zimmermann <zimmermann (at) kde.org> 3 * Copyright (C) 2004, 2005, 2006 Rob Buis <buis (at) 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 blink { 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 DEFINE_WRAPPERTYPEINFO(); 46 public: 47 enum { 48 SVG_SPREADMETHOD_UNKNOWN = SVGSpreadMethodUnknown, 49 SVG_SPREADMETHOD_PAD = SVGSpreadMethodReflect, 50 SVG_SPREADMETHOD_REFLECT = SVGSpreadMethodRepeat, 51 SVG_SPREADMETHOD_REPEAT = SVGSpreadMethodUnknown 52 }; 53 54 Vector<Gradient::ColorStop> buildStops(); 55 56 SVGAnimatedTransformList* gradientTransform() { return m_gradientTransform.get(); } 57 SVGAnimatedEnumeration<SVGSpreadMethodType>* spreadMethod() { return m_spreadMethod.get(); } 58 SVGAnimatedEnumeration<SVGUnitTypes::SVGUnitType>* gradientUnits() { return m_gradientUnits.get(); } 59 60 protected: 61 SVGGradientElement(const QualifiedName&, Document&); 62 63 bool isSupportedAttribute(const QualifiedName&); 64 virtual void parseAttribute(const QualifiedName&, const AtomicString&) OVERRIDE; 65 virtual void svgAttributeChanged(const QualifiedName&) OVERRIDE; 66 67 private: 68 virtual bool needsPendingResourceHandling() const OVERRIDE FINAL { return false; } 69 70 virtual void childrenChanged(const ChildrenChange&) OVERRIDE FINAL; 71 72 RefPtr<SVGAnimatedTransformList> m_gradientTransform; 73 RefPtr<SVGAnimatedEnumeration<SVGSpreadMethodType> > m_spreadMethod; 74 RefPtr<SVGAnimatedEnumeration<SVGUnitTypes::SVGUnitType> > m_gradientUnits; 75 }; 76 77 inline bool isSVGGradientElement(const SVGElement& element) 78 { 79 return element.hasTagName(SVGNames::radialGradientTag) || element.hasTagName(SVGNames::linearGradientTag); 80 } 81 82 DEFINE_SVGELEMENT_TYPE_CASTS_WITH_FUNCTION(SVGGradientElement); 83 84 } // namespace blink 85 86 #endif // SVGGradientElement_h 87