1/* 2 * Copyright (C) 2009 Dirk Schulze <krit@webkit.org> 3 * 4 * This library is free software; you can redistribute it and/or 5 * modify it under the terms of the GNU Library General Public 6 * License as published by the Free Software Foundation; either 7 * version 2 of the License, or (at your option) any later version. 8 * 9 * This library is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 * Library General Public License for more details. 13 * 14 * You should have received a copy of the GNU Library General Public License 15 * along with this library; see the file COPYING.LIB. If not, write to 16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 * Boston, MA 02110-1301, USA. 18 */ 19 20#ifndef SVGFEMorphologyElement_h 21#define SVGFEMorphologyElement_h 22 23#if ENABLE(FILTERS) 24#include "FEMorphology.h" 25#include "SVGAnimatedEnumeration.h" 26#include "SVGAnimatedNumber.h" 27#include "SVGFilterPrimitiveStandardAttributes.h" 28 29namespace WebCore { 30 31template<> 32struct SVGPropertyTraits<MorphologyOperatorType> { 33 static unsigned highestEnumValue() { return FEMORPHOLOGY_OPERATOR_DILATE; } 34 35 static String toString(MorphologyOperatorType type) 36 { 37 switch (type) { 38 case FEMORPHOLOGY_OPERATOR_UNKNOWN: 39 return emptyString(); 40 case FEMORPHOLOGY_OPERATOR_ERODE: 41 return "erode"; 42 case FEMORPHOLOGY_OPERATOR_DILATE: 43 return "dilate"; 44 } 45 46 ASSERT_NOT_REACHED(); 47 return emptyString(); 48 } 49 50 static MorphologyOperatorType fromString(const String& value) 51 { 52 if (value == "erode") 53 return FEMORPHOLOGY_OPERATOR_ERODE; 54 if (value == "dilate") 55 return FEMORPHOLOGY_OPERATOR_DILATE; 56 return FEMORPHOLOGY_OPERATOR_UNKNOWN; 57 } 58}; 59 60class SVGFEMorphologyElement final : public SVGFilterPrimitiveStandardAttributes { 61public: 62 static PassRefPtr<SVGFEMorphologyElement> create(const QualifiedName&, Document&); 63 64 void setRadius(float radiusX, float radiusY); 65 66private: 67 SVGFEMorphologyElement(const QualifiedName&, Document&); 68 69 bool isSupportedAttribute(const QualifiedName&); 70 virtual void parseAttribute(const QualifiedName&, const AtomicString&) override; 71 virtual bool setFilterEffectAttribute(FilterEffect*, const QualifiedName&) override; 72 virtual void svgAttributeChanged(const QualifiedName&) override; 73 virtual PassRefPtr<FilterEffect> build(SVGFilterBuilder*, Filter*) override; 74 75 static const AtomicString& radiusXIdentifier(); 76 static const AtomicString& radiusYIdentifier(); 77 78 BEGIN_DECLARE_ANIMATED_PROPERTIES(SVGFEMorphologyElement) 79 DECLARE_ANIMATED_STRING(In1, in1) 80 DECLARE_ANIMATED_ENUMERATION(SVGOperator, svgOperator, MorphologyOperatorType) 81 DECLARE_ANIMATED_NUMBER(RadiusX, radiusX) 82 DECLARE_ANIMATED_NUMBER(RadiusY, radiusY) 83 END_DECLARE_ANIMATED_PROPERTIES 84}; 85 86} // namespace WebCore 87 88#endif // ENABLE(FILTERS) 89#endif 90