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 12 matching lines...) Expand all Loading... |
23 | 23 |
24 #include "SVGNames.h" | 24 #include "SVGNames.h" |
25 #include "platform/graphics/filters/FilterEffect.h" | 25 #include "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) | |
34 DEFINE_ANIMATED_ENUMERATION(SVGFEMorphologyElement, SVGNames::operatorAttr, SVGO
perator, svgOperator, MorphologyOperatorType) | 33 DEFINE_ANIMATED_ENUMERATION(SVGFEMorphologyElement, SVGNames::operatorAttr, SVGO
perator, svgOperator, MorphologyOperatorType) |
35 | 34 |
36 BEGIN_REGISTER_ANIMATED_PROPERTIES(SVGFEMorphologyElement) | 35 BEGIN_REGISTER_ANIMATED_PROPERTIES(SVGFEMorphologyElement) |
37 REGISTER_LOCAL_ANIMATED_PROPERTY(in1) | |
38 REGISTER_LOCAL_ANIMATED_PROPERTY(svgOperator) | 36 REGISTER_LOCAL_ANIMATED_PROPERTY(svgOperator) |
39 REGISTER_PARENT_ANIMATED_PROPERTIES(SVGFilterPrimitiveStandardAttributes) | 37 REGISTER_PARENT_ANIMATED_PROPERTIES(SVGFilterPrimitiveStandardAttributes) |
40 END_REGISTER_ANIMATED_PROPERTIES | 38 END_REGISTER_ANIMATED_PROPERTIES |
41 | 39 |
42 inline SVGFEMorphologyElement::SVGFEMorphologyElement(Document& document) | 40 inline SVGFEMorphologyElement::SVGFEMorphologyElement(Document& document) |
43 : SVGFilterPrimitiveStandardAttributes(SVGNames::feMorphologyTag, document) | 41 : SVGFilterPrimitiveStandardAttributes(SVGNames::feMorphologyTag, document) |
44 , m_radius(SVGAnimatedNumberOptionalNumber::create(this, SVGNames::radiusAtt
r)) | 42 , m_radius(SVGAnimatedNumberOptionalNumber::create(this, SVGNames::radiusAtt
r)) |
| 43 , m_in1(SVGAnimatedString::create(this, SVGNames::inAttr, SVGString::create(
))) |
45 , m_svgOperator(FEMORPHOLOGY_OPERATOR_ERODE) | 44 , m_svgOperator(FEMORPHOLOGY_OPERATOR_ERODE) |
46 { | 45 { |
47 ScriptWrappable::init(this); | 46 ScriptWrappable::init(this); |
48 | 47 |
49 addToPropertyMap(m_radius); | 48 addToPropertyMap(m_radius); |
| 49 addToPropertyMap(m_in1); |
50 registerAnimatedPropertiesForSVGFEMorphologyElement(); | 50 registerAnimatedPropertiesForSVGFEMorphologyElement(); |
51 } | 51 } |
52 | 52 |
53 PassRefPtr<SVGFEMorphologyElement> SVGFEMorphologyElement::create(Document& docu
ment) | 53 PassRefPtr<SVGFEMorphologyElement> SVGFEMorphologyElement::create(Document& docu
ment) |
54 { | 54 { |
55 return adoptRef(new SVGFEMorphologyElement(document)); | 55 return adoptRef(new SVGFEMorphologyElement(document)); |
56 } | 56 } |
57 | 57 |
58 void SVGFEMorphologyElement::setRadius(float x, float y) | 58 void SVGFEMorphologyElement::setRadius(float x, float y) |
59 { | 59 { |
(...skipping 20 matching lines...) Expand all Loading... |
80 return; | 80 return; |
81 } | 81 } |
82 | 82 |
83 if (name == SVGNames::operatorAttr) { | 83 if (name == SVGNames::operatorAttr) { |
84 MorphologyOperatorType propertyValue = SVGPropertyTraits<MorphologyOpera
torType>::fromString(value); | 84 MorphologyOperatorType propertyValue = SVGPropertyTraits<MorphologyOpera
torType>::fromString(value); |
85 if (propertyValue > 0) | 85 if (propertyValue > 0) |
86 setSVGOperatorBaseValue(propertyValue); | 86 setSVGOperatorBaseValue(propertyValue); |
87 return; | 87 return; |
88 } | 88 } |
89 | 89 |
90 if (name == SVGNames::inAttr) { | |
91 setIn1BaseValue(value); | |
92 return; | |
93 } | |
94 | |
95 SVGParsingError parseError = NoError; | 90 SVGParsingError parseError = NoError; |
96 | 91 |
97 if (name == SVGNames::radiusAttr) | 92 if (name == SVGNames::inAttr) |
| 93 m_in1->setBaseValueAsString(value, parseError); |
| 94 else if (name == SVGNames::radiusAttr) |
98 m_radius->setBaseValueAsString(value, parseError); | 95 m_radius->setBaseValueAsString(value, parseError); |
99 else | 96 else |
100 ASSERT_NOT_REACHED(); | 97 ASSERT_NOT_REACHED(); |
101 | 98 |
102 reportAttributeParsingError(parseError, name, value); | 99 reportAttributeParsingError(parseError, name, value); |
103 } | 100 } |
104 | 101 |
105 bool SVGFEMorphologyElement::setFilterEffectAttribute(FilterEffect* effect, cons
t QualifiedName& attrName) | 102 bool SVGFEMorphologyElement::setFilterEffectAttribute(FilterEffect* effect, cons
t QualifiedName& attrName) |
106 { | 103 { |
107 FEMorphology* morphology = static_cast<FEMorphology*>(effect); | 104 FEMorphology* morphology = static_cast<FEMorphology*>(effect); |
(...skipping 27 matching lines...) Expand all Loading... |
135 if (attrName == SVGNames::inAttr) { | 132 if (attrName == SVGNames::inAttr) { |
136 invalidate(); | 133 invalidate(); |
137 return; | 134 return; |
138 } | 135 } |
139 | 136 |
140 ASSERT_NOT_REACHED(); | 137 ASSERT_NOT_REACHED(); |
141 } | 138 } |
142 | 139 |
143 PassRefPtr<FilterEffect> SVGFEMorphologyElement::build(SVGFilterBuilder* filterB
uilder, Filter* filter) | 140 PassRefPtr<FilterEffect> SVGFEMorphologyElement::build(SVGFilterBuilder* filterB
uilder, Filter* filter) |
144 { | 141 { |
145 FilterEffect* input1 = filterBuilder->getEffectById(AtomicString(in1CurrentV
alue())); | 142 FilterEffect* input1 = filterBuilder->getEffectById(AtomicString(m_in1->curr
entValue()->value())); |
146 float xRadius = radiusX()->currentValue()->value(); | 143 float xRadius = radiusX()->currentValue()->value(); |
147 float yRadius = radiusY()->currentValue()->value(); | 144 float yRadius = radiusY()->currentValue()->value(); |
148 | 145 |
149 if (!input1) | 146 if (!input1) |
150 return 0; | 147 return 0; |
151 | 148 |
152 if (xRadius < 0 || yRadius < 0) | 149 if (xRadius < 0 || yRadius < 0) |
153 return 0; | 150 return 0; |
154 | 151 |
155 RefPtr<FilterEffect> effect = FEMorphology::create(filter, svgOperatorCurren
tValue(), xRadius, yRadius); | 152 RefPtr<FilterEffect> effect = FEMorphology::create(filter, svgOperatorCurren
tValue(), xRadius, yRadius); |
156 effect->inputEffects().append(input1); | 153 effect->inputEffects().append(input1); |
157 return effect.release(); | 154 return effect.release(); |
158 } | 155 } |
159 | 156 |
160 } // namespace WebCore | 157 } // namespace WebCore |
OLD | NEW |