OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2004, 2005, 2007 Nikolas Zimmermann <zimmermann@kde.org> | 2 * Copyright (C) 2004, 2005, 2007 Nikolas Zimmermann <zimmermann@kde.org> |
3 * Copyright (C) 2004, 2005 Rob Buis <buis@kde.org> | 3 * Copyright (C) 2004, 2005 Rob Buis <buis@kde.org> |
4 * | 4 * |
5 * This library is free software; you can redistribute it and/or | 5 * This library is free software; you can redistribute it and/or |
6 * modify it under the terms of the GNU Library General Public | 6 * modify it under the terms of the GNU Library General Public |
7 * License as published by the Free Software Foundation; either | 7 * License as published by the Free Software Foundation; either |
8 * version 2 of the License, or (at your option) any later version. | 8 * version 2 of the License, or (at your option) any later version. |
9 * | 9 * |
10 * This library is distributed in the hope that it will be useful, | 10 * This library is distributed in the hope that it will be useful, |
(...skipping 12 matching lines...) Expand all Loading... |
23 #include "core/svg/SVGFEOffsetElement.h" | 23 #include "core/svg/SVGFEOffsetElement.h" |
24 | 24 |
25 #include "SVGNames.h" | 25 #include "SVGNames.h" |
26 #include "platform/graphics/filters/FilterEffect.h" | 26 #include "platform/graphics/filters/FilterEffect.h" |
27 #include "core/svg/SVGElementInstance.h" | 27 #include "core/svg/SVGElementInstance.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(SVGFEOffsetElement, SVGNames::inAttr, In1, in1) | |
34 | 33 |
35 BEGIN_REGISTER_ANIMATED_PROPERTIES(SVGFEOffsetElement) | 34 BEGIN_REGISTER_ANIMATED_PROPERTIES(SVGFEOffsetElement) |
36 REGISTER_LOCAL_ANIMATED_PROPERTY(in1) | |
37 REGISTER_PARENT_ANIMATED_PROPERTIES(SVGFilterPrimitiveStandardAttributes) | 35 REGISTER_PARENT_ANIMATED_PROPERTIES(SVGFilterPrimitiveStandardAttributes) |
38 END_REGISTER_ANIMATED_PROPERTIES | 36 END_REGISTER_ANIMATED_PROPERTIES |
39 | 37 |
40 inline SVGFEOffsetElement::SVGFEOffsetElement(Document& document) | 38 inline SVGFEOffsetElement::SVGFEOffsetElement(Document& document) |
41 : SVGFilterPrimitiveStandardAttributes(SVGNames::feOffsetTag, document) | 39 : SVGFilterPrimitiveStandardAttributes(SVGNames::feOffsetTag, document) |
42 , m_dx(SVGAnimatedNumber::create(this, SVGNames::dxAttr, SVGNumber::create()
)) | 40 , m_dx(SVGAnimatedNumber::create(this, SVGNames::dxAttr, SVGNumber::create()
)) |
43 , m_dy(SVGAnimatedNumber::create(this, SVGNames::dyAttr, SVGNumber::create()
)) | 41 , m_dy(SVGAnimatedNumber::create(this, SVGNames::dyAttr, SVGNumber::create()
)) |
| 42 , m_in1(SVGAnimatedString::create(this, SVGNames::inAttr, SVGString::create(
))) |
44 { | 43 { |
45 ScriptWrappable::init(this); | 44 ScriptWrappable::init(this); |
46 | 45 |
47 addToPropertyMap(m_dx); | 46 addToPropertyMap(m_dx); |
48 addToPropertyMap(m_dy); | 47 addToPropertyMap(m_dy); |
| 48 addToPropertyMap(m_in1); |
49 registerAnimatedPropertiesForSVGFEOffsetElement(); | 49 registerAnimatedPropertiesForSVGFEOffsetElement(); |
50 } | 50 } |
51 | 51 |
52 PassRefPtr<SVGFEOffsetElement> SVGFEOffsetElement::create(Document& document) | 52 PassRefPtr<SVGFEOffsetElement> SVGFEOffsetElement::create(Document& document) |
53 { | 53 { |
54 return adoptRef(new SVGFEOffsetElement(document)); | 54 return adoptRef(new SVGFEOffsetElement(document)); |
55 } | 55 } |
56 | 56 |
57 bool SVGFEOffsetElement::isSupportedAttribute(const QualifiedName& attrName) | 57 bool SVGFEOffsetElement::isSupportedAttribute(const QualifiedName& attrName) |
58 { | 58 { |
59 DEFINE_STATIC_LOCAL(HashSet<QualifiedName>, supportedAttributes, ()); | 59 DEFINE_STATIC_LOCAL(HashSet<QualifiedName>, supportedAttributes, ()); |
60 if (supportedAttributes.isEmpty()) { | 60 if (supportedAttributes.isEmpty()) { |
61 supportedAttributes.add(SVGNames::inAttr); | 61 supportedAttributes.add(SVGNames::inAttr); |
62 supportedAttributes.add(SVGNames::dxAttr); | 62 supportedAttributes.add(SVGNames::dxAttr); |
63 supportedAttributes.add(SVGNames::dyAttr); | 63 supportedAttributes.add(SVGNames::dyAttr); |
64 } | 64 } |
65 return supportedAttributes.contains<SVGAttributeHashTranslator>(attrName); | 65 return supportedAttributes.contains<SVGAttributeHashTranslator>(attrName); |
66 } | 66 } |
67 | 67 |
68 void SVGFEOffsetElement::parseAttribute(const QualifiedName& name, const AtomicS
tring& value) | 68 void SVGFEOffsetElement::parseAttribute(const QualifiedName& name, const AtomicS
tring& value) |
69 { | 69 { |
70 if (!isSupportedAttribute(name)) { | 70 if (!isSupportedAttribute(name)) { |
71 SVGFilterPrimitiveStandardAttributes::parseAttribute(name, value); | 71 SVGFilterPrimitiveStandardAttributes::parseAttribute(name, value); |
72 return; | 72 return; |
73 } | 73 } |
74 | 74 |
75 if (name == SVGNames::inAttr) { | |
76 setIn1BaseValue(value); | |
77 return; | |
78 } | |
79 | |
80 SVGParsingError parseError = NoError; | 75 SVGParsingError parseError = NoError; |
81 | 76 |
82 if (name == SVGNames::dxAttr) | 77 if (name == SVGNames::inAttr) |
| 78 m_in1->setBaseValueAsString(value, parseError); |
| 79 else if (name == SVGNames::dxAttr) |
83 m_dx->setBaseValueAsString(value, parseError); | 80 m_dx->setBaseValueAsString(value, parseError); |
84 else if (name == SVGNames::dyAttr) | 81 else if (name == SVGNames::dyAttr) |
85 m_dy->setBaseValueAsString(value, parseError); | 82 m_dy->setBaseValueAsString(value, parseError); |
86 else | 83 else |
87 ASSERT_NOT_REACHED(); | 84 ASSERT_NOT_REACHED(); |
88 | 85 |
89 reportAttributeParsingError(parseError, name, value); | 86 reportAttributeParsingError(parseError, name, value); |
90 } | 87 } |
91 | 88 |
92 void SVGFEOffsetElement::svgAttributeChanged(const QualifiedName& attrName) | 89 void SVGFEOffsetElement::svgAttributeChanged(const QualifiedName& attrName) |
93 { | 90 { |
94 if (!isSupportedAttribute(attrName)) { | 91 if (!isSupportedAttribute(attrName)) { |
95 SVGFilterPrimitiveStandardAttributes::svgAttributeChanged(attrName); | 92 SVGFilterPrimitiveStandardAttributes::svgAttributeChanged(attrName); |
96 return; | 93 return; |
97 } | 94 } |
98 | 95 |
99 SVGElementInstance::InvalidationGuard invalidationGuard(this); | 96 SVGElementInstance::InvalidationGuard invalidationGuard(this); |
100 | 97 |
101 if (attrName == SVGNames::inAttr || attrName == SVGNames::dxAttr || attrName
== SVGNames::dyAttr) { | 98 if (attrName == SVGNames::inAttr || attrName == SVGNames::dxAttr || attrName
== SVGNames::dyAttr) { |
102 invalidate(); | 99 invalidate(); |
103 return; | 100 return; |
104 } | 101 } |
105 | 102 |
106 ASSERT_NOT_REACHED(); | 103 ASSERT_NOT_REACHED(); |
107 } | 104 } |
108 | 105 |
109 PassRefPtr<FilterEffect> SVGFEOffsetElement::build(SVGFilterBuilder* filterBuild
er, Filter* filter) | 106 PassRefPtr<FilterEffect> SVGFEOffsetElement::build(SVGFilterBuilder* filterBuild
er, Filter* filter) |
110 { | 107 { |
111 FilterEffect* input1 = filterBuilder->getEffectById(AtomicString(in1CurrentV
alue())); | 108 FilterEffect* input1 = filterBuilder->getEffectById(AtomicString(m_in1->curr
entValue()->value())); |
112 | 109 |
113 if (!input1) | 110 if (!input1) |
114 return 0; | 111 return 0; |
115 | 112 |
116 RefPtr<FilterEffect> effect = FEOffset::create(filter, m_dx->currentValue()-
>value(), m_dy->currentValue()->value()); | 113 RefPtr<FilterEffect> effect = FEOffset::create(filter, m_dx->currentValue()-
>value(), m_dy->currentValue()->value()); |
117 effect->inputEffects().append(input1); | 114 effect->inputEffects().append(input1); |
118 return effect.release(); | 115 return effect.release(); |
119 } | 116 } |
120 | 117 |
121 } | 118 } |
OLD | NEW |