| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2009 Dirk Schulze <krit@webkit.org> | 2 * Copyright (C) 2009 Dirk Schulze <krit@webkit.org> |
| 3 * | 3 * |
| 4 * This library is free software; you can redistribute it and/or | 4 * This library is free software; you can redistribute it and/or |
| 5 * modify it under the terms of the GNU Library General Public | 5 * modify it under the terms of the GNU Library General Public |
| 6 * License as published by the Free Software Foundation; either | 6 * License as published by the Free Software Foundation; either |
| 7 * version 2 of the License, or (at your option) any later version. | 7 * version 2 of the License, or (at your option) any later version. |
| 8 * | 8 * |
| 9 * This library is distributed in the hope that it will be useful, | 9 * This library is distributed in the hope that it will be useful, |
| 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 #include "SVGNames.h" | 24 #include "SVGNames.h" |
| 25 #include "core/platform/graphics/filters/FilterEffect.h" | 25 #include "core/platform/graphics/filters/FilterEffect.h" |
| 26 #include "core/svg/SVGElementInstance.h" | 26 #include "core/svg/SVGElementInstance.h" |
| 27 #include "core/svg/SVGParserUtilities.h" | 27 #include "core/svg/SVGParserUtilities.h" |
| 28 #include "core/svg/graphics/filters/SVGFilterBuilder.h" | 28 #include "core/svg/graphics/filters/SVGFilterBuilder.h" |
| 29 | 29 |
| 30 namespace WebCore { | 30 namespace WebCore { |
| 31 | 31 |
| 32 // Animated property definitions | 32 // Animated property definitions |
| 33 DEFINE_ANIMATED_STRING(SVGFEMorphologyElement, SVGNames::inAttr, In1, in1) | 33 DEFINE_ANIMATED_STRING(SVGFEMorphologyElement, SVGNames::inAttr, In1, in1) |
| 34 DEFINE_ANIMATED_ENUMERATION(SVGFEMorphologyElement, SVGNames::operatorAttr, _ope
rator, _operator, MorphologyOperatorType) | 34 DEFINE_ANIMATED_ENUMERATION(SVGFEMorphologyElement, SVGNames::operatorAttr, SVGO
perator, svgOperator, MorphologyOperatorType) |
| 35 DEFINE_ANIMATED_NUMBER_MULTIPLE_WRAPPERS(SVGFEMorphologyElement, SVGNames::radiu
sAttr, radiusXIdentifier(), RadiusX, radiusX) | 35 DEFINE_ANIMATED_NUMBER_MULTIPLE_WRAPPERS(SVGFEMorphologyElement, SVGNames::radiu
sAttr, radiusXIdentifier(), RadiusX, radiusX) |
| 36 DEFINE_ANIMATED_NUMBER_MULTIPLE_WRAPPERS(SVGFEMorphologyElement, SVGNames::radiu
sAttr, radiusYIdentifier(), RadiusY, radiusY) | 36 DEFINE_ANIMATED_NUMBER_MULTIPLE_WRAPPERS(SVGFEMorphologyElement, SVGNames::radiu
sAttr, radiusYIdentifier(), RadiusY, radiusY) |
| 37 | 37 |
| 38 BEGIN_REGISTER_ANIMATED_PROPERTIES(SVGFEMorphologyElement) | 38 BEGIN_REGISTER_ANIMATED_PROPERTIES(SVGFEMorphologyElement) |
| 39 REGISTER_LOCAL_ANIMATED_PROPERTY(in1) | 39 REGISTER_LOCAL_ANIMATED_PROPERTY(in1) |
| 40 REGISTER_LOCAL_ANIMATED_PROPERTY(_operator) | 40 REGISTER_LOCAL_ANIMATED_PROPERTY(svgOperator) |
| 41 REGISTER_LOCAL_ANIMATED_PROPERTY(radiusX) | 41 REGISTER_LOCAL_ANIMATED_PROPERTY(radiusX) |
| 42 REGISTER_LOCAL_ANIMATED_PROPERTY(radiusY) | 42 REGISTER_LOCAL_ANIMATED_PROPERTY(radiusY) |
| 43 REGISTER_PARENT_ANIMATED_PROPERTIES(SVGFilterPrimitiveStandardAttributes) | 43 REGISTER_PARENT_ANIMATED_PROPERTIES(SVGFilterPrimitiveStandardAttributes) |
| 44 END_REGISTER_ANIMATED_PROPERTIES | 44 END_REGISTER_ANIMATED_PROPERTIES |
| 45 | 45 |
| 46 inline SVGFEMorphologyElement::SVGFEMorphologyElement(const QualifiedName& tagNa
me, Document* document) | 46 inline SVGFEMorphologyElement::SVGFEMorphologyElement(const QualifiedName& tagNa
me, Document* document) |
| 47 : SVGFilterPrimitiveStandardAttributes(tagName, document) | 47 : SVGFilterPrimitiveStandardAttributes(tagName, document) |
| 48 , m__operator(FEMORPHOLOGY_OPERATOR_ERODE) | 48 , m_svgOperator(FEMORPHOLOGY_OPERATOR_ERODE) |
| 49 { | 49 { |
| 50 ASSERT(hasTagName(SVGNames::feMorphologyTag)); | 50 ASSERT(hasTagName(SVGNames::feMorphologyTag)); |
| 51 ScriptWrappable::init(this); | 51 ScriptWrappable::init(this); |
| 52 registerAnimatedPropertiesForSVGFEMorphologyElement(); | 52 registerAnimatedPropertiesForSVGFEMorphologyElement(); |
| 53 } | 53 } |
| 54 | 54 |
| 55 PassRefPtr<SVGFEMorphologyElement> SVGFEMorphologyElement::create(const Qualifie
dName& tagName, Document* document) | 55 PassRefPtr<SVGFEMorphologyElement> SVGFEMorphologyElement::create(const Qualifie
dName& tagName, Document* document) |
| 56 { | 56 { |
| 57 return adoptRef(new SVGFEMorphologyElement(tagName, document)); | 57 return adoptRef(new SVGFEMorphologyElement(tagName, document)); |
| 58 } | 58 } |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 void SVGFEMorphologyElement::parseAttribute(const QualifiedName& name, const Ato
micString& value) | 90 void SVGFEMorphologyElement::parseAttribute(const QualifiedName& name, const Ato
micString& value) |
| 91 { | 91 { |
| 92 if (!isSupportedAttribute(name)) { | 92 if (!isSupportedAttribute(name)) { |
| 93 SVGFilterPrimitiveStandardAttributes::parseAttribute(name, value); | 93 SVGFilterPrimitiveStandardAttributes::parseAttribute(name, value); |
| 94 return; | 94 return; |
| 95 } | 95 } |
| 96 | 96 |
| 97 if (name == SVGNames::operatorAttr) { | 97 if (name == SVGNames::operatorAttr) { |
| 98 MorphologyOperatorType propertyValue = SVGPropertyTraits<MorphologyOpera
torType>::fromString(value); | 98 MorphologyOperatorType propertyValue = SVGPropertyTraits<MorphologyOpera
torType>::fromString(value); |
| 99 if (propertyValue > 0) | 99 if (propertyValue > 0) |
| 100 set_operatorBaseValue(propertyValue); | 100 setSVGOperatorBaseValue(propertyValue); |
| 101 return; | 101 return; |
| 102 } | 102 } |
| 103 | 103 |
| 104 if (name == SVGNames::inAttr) { | 104 if (name == SVGNames::inAttr) { |
| 105 setIn1BaseValue(value); | 105 setIn1BaseValue(value); |
| 106 return; | 106 return; |
| 107 } | 107 } |
| 108 | 108 |
| 109 if (name == SVGNames::radiusAttr) { | 109 if (name == SVGNames::radiusAttr) { |
| 110 float x, y; | 110 float x, y; |
| 111 if (parseNumberOptionalNumber(value, x, y)) { | 111 if (parseNumberOptionalNumber(value, x, y)) { |
| 112 setRadiusXBaseValue(x); | 112 setRadiusXBaseValue(x); |
| 113 setRadiusYBaseValue(y); | 113 setRadiusYBaseValue(y); |
| 114 } | 114 } |
| 115 return; | 115 return; |
| 116 } | 116 } |
| 117 | 117 |
| 118 ASSERT_NOT_REACHED(); | 118 ASSERT_NOT_REACHED(); |
| 119 } | 119 } |
| 120 | 120 |
| 121 bool SVGFEMorphologyElement::setFilterEffectAttribute(FilterEffect* effect, cons
t QualifiedName& attrName) | 121 bool SVGFEMorphologyElement::setFilterEffectAttribute(FilterEffect* effect, cons
t QualifiedName& attrName) |
| 122 { | 122 { |
| 123 FEMorphology* morphology = static_cast<FEMorphology*>(effect); | 123 FEMorphology* morphology = static_cast<FEMorphology*>(effect); |
| 124 if (attrName == SVGNames::operatorAttr) | 124 if (attrName == SVGNames::operatorAttr) |
| 125 return morphology->setMorphologyOperator(_operatorCurrentValue()); | 125 return morphology->setMorphologyOperator(svgOperatorCurrentValue()); |
| 126 if (attrName == SVGNames::radiusAttr) { | 126 if (attrName == SVGNames::radiusAttr) { |
| 127 // Both setRadius functions should be evaluated separately. | 127 // Both setRadius functions should be evaluated separately. |
| 128 bool isRadiusXChanged = morphology->setRadiusX(radiusXCurrentValue()); | 128 bool isRadiusXChanged = morphology->setRadiusX(radiusXCurrentValue()); |
| 129 bool isRadiusYChanged = morphology->setRadiusY(radiusYCurrentValue()); | 129 bool isRadiusYChanged = morphology->setRadiusY(radiusYCurrentValue()); |
| 130 return isRadiusXChanged || isRadiusYChanged; | 130 return isRadiusXChanged || isRadiusYChanged; |
| 131 } | 131 } |
| 132 | 132 |
| 133 ASSERT_NOT_REACHED(); | 133 ASSERT_NOT_REACHED(); |
| 134 return false; | 134 return false; |
| 135 } | 135 } |
| (...skipping 25 matching lines...) Expand all Loading... |
| 161 FilterEffect* input1 = filterBuilder->getEffectById(in1CurrentValue()); | 161 FilterEffect* input1 = filterBuilder->getEffectById(in1CurrentValue()); |
| 162 float xRadius = radiusXCurrentValue(); | 162 float xRadius = radiusXCurrentValue(); |
| 163 float yRadius = radiusYCurrentValue(); | 163 float yRadius = radiusYCurrentValue(); |
| 164 | 164 |
| 165 if (!input1) | 165 if (!input1) |
| 166 return 0; | 166 return 0; |
| 167 | 167 |
| 168 if (xRadius < 0 || yRadius < 0) | 168 if (xRadius < 0 || yRadius < 0) |
| 169 return 0; | 169 return 0; |
| 170 | 170 |
| 171 RefPtr<FilterEffect> effect = FEMorphology::create(filter, _operatorCurrentV
alue(), xRadius, yRadius); | 171 RefPtr<FilterEffect> effect = FEMorphology::create(filter, svgOperatorCurren
tValue(), xRadius, yRadius); |
| 172 effect->inputEffects().append(input1); | 172 effect->inputEffects().append(input1); |
| 173 return effect.release(); | 173 return effect.release(); |
| 174 } | 174 } |
| 175 | 175 |
| 176 } // namespace WebCore | 176 } // namespace WebCore |
| OLD | NEW |