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 15 matching lines...) Expand all Loading... |
26 #include "platform/graphics/filters/FilterEffect.h" | 26 #include "platform/graphics/filters/FilterEffect.h" |
27 #include "core/svg/SVGFEFuncAElement.h" | 27 #include "core/svg/SVGFEFuncAElement.h" |
28 #include "core/svg/SVGFEFuncBElement.h" | 28 #include "core/svg/SVGFEFuncBElement.h" |
29 #include "core/svg/SVGFEFuncGElement.h" | 29 #include "core/svg/SVGFEFuncGElement.h" |
30 #include "core/svg/SVGFEFuncRElement.h" | 30 #include "core/svg/SVGFEFuncRElement.h" |
31 #include "core/svg/graphics/filters/SVGFilterBuilder.h" | 31 #include "core/svg/graphics/filters/SVGFilterBuilder.h" |
32 | 32 |
33 namespace WebCore { | 33 namespace WebCore { |
34 | 34 |
35 // Animated property definitions | 35 // Animated property definitions |
36 DEFINE_ANIMATED_STRING(SVGFEComponentTransferElement, SVGNames::inAttr, In1, in1
) | |
37 | 36 |
38 BEGIN_REGISTER_ANIMATED_PROPERTIES(SVGFEComponentTransferElement) | 37 BEGIN_REGISTER_ANIMATED_PROPERTIES(SVGFEComponentTransferElement) |
39 REGISTER_LOCAL_ANIMATED_PROPERTY(in1) | |
40 REGISTER_PARENT_ANIMATED_PROPERTIES(SVGFilterPrimitiveStandardAttributes) | 38 REGISTER_PARENT_ANIMATED_PROPERTIES(SVGFilterPrimitiveStandardAttributes) |
41 END_REGISTER_ANIMATED_PROPERTIES | 39 END_REGISTER_ANIMATED_PROPERTIES |
42 | 40 |
43 inline SVGFEComponentTransferElement::SVGFEComponentTransferElement(Document& do
cument) | 41 inline SVGFEComponentTransferElement::SVGFEComponentTransferElement(Document& do
cument) |
44 : SVGFilterPrimitiveStandardAttributes(SVGNames::feComponentTransferTag, doc
ument) | 42 : SVGFilterPrimitiveStandardAttributes(SVGNames::feComponentTransferTag, doc
ument) |
| 43 , m_in1(SVGAnimatedString::create(this, SVGNames::inAttr, SVGString::create(
))) |
45 { | 44 { |
46 ScriptWrappable::init(this); | 45 ScriptWrappable::init(this); |
| 46 addToPropertyMap(m_in1); |
47 registerAnimatedPropertiesForSVGFEComponentTransferElement(); | 47 registerAnimatedPropertiesForSVGFEComponentTransferElement(); |
48 } | 48 } |
49 | 49 |
50 PassRefPtr<SVGFEComponentTransferElement> SVGFEComponentTransferElement::create(
Document& document) | 50 PassRefPtr<SVGFEComponentTransferElement> SVGFEComponentTransferElement::create(
Document& document) |
51 { | 51 { |
52 return adoptRef(new SVGFEComponentTransferElement(document)); | 52 return adoptRef(new SVGFEComponentTransferElement(document)); |
53 } | 53 } |
54 | 54 |
55 bool SVGFEComponentTransferElement::isSupportedAttribute(const QualifiedName& at
trName) | 55 bool SVGFEComponentTransferElement::isSupportedAttribute(const QualifiedName& at
trName) |
56 { | 56 { |
57 DEFINE_STATIC_LOCAL(HashSet<QualifiedName>, supportedAttributes, ()); | 57 DEFINE_STATIC_LOCAL(HashSet<QualifiedName>, supportedAttributes, ()); |
58 if (supportedAttributes.isEmpty()) | 58 if (supportedAttributes.isEmpty()) |
59 supportedAttributes.add(SVGNames::inAttr); | 59 supportedAttributes.add(SVGNames::inAttr); |
60 return supportedAttributes.contains<SVGAttributeHashTranslator>(attrName); | 60 return supportedAttributes.contains<SVGAttributeHashTranslator>(attrName); |
61 } | 61 } |
62 | 62 |
63 void SVGFEComponentTransferElement::parseAttribute(const QualifiedName& name, co
nst AtomicString& value) | 63 void SVGFEComponentTransferElement::parseAttribute(const QualifiedName& name, co
nst AtomicString& value) |
64 { | 64 { |
65 if (!isSupportedAttribute(name)) { | 65 if (!isSupportedAttribute(name)) { |
66 SVGFilterPrimitiveStandardAttributes::parseAttribute(name, value); | 66 SVGFilterPrimitiveStandardAttributes::parseAttribute(name, value); |
67 return; | 67 return; |
68 } | 68 } |
69 | 69 |
70 if (name == SVGNames::inAttr) { | 70 SVGParsingError parseError = NoError; |
71 setIn1BaseValue(value); | |
72 return; | |
73 } | |
74 | 71 |
75 ASSERT_NOT_REACHED(); | 72 if (name == SVGNames::inAttr) |
| 73 m_in1->setBaseValueAsString(value, parseError); |
| 74 else |
| 75 ASSERT_NOT_REACHED(); |
| 76 |
| 77 reportAttributeParsingError(parseError, name, value); |
76 } | 78 } |
77 | 79 |
78 PassRefPtr<FilterEffect> SVGFEComponentTransferElement::build(SVGFilterBuilder*
filterBuilder, Filter* filter) | 80 PassRefPtr<FilterEffect> SVGFEComponentTransferElement::build(SVGFilterBuilder*
filterBuilder, Filter* filter) |
79 { | 81 { |
80 FilterEffect* input1 = filterBuilder->getEffectById(AtomicString(in1CurrentV
alue())); | 82 FilterEffect* input1 = filterBuilder->getEffectById(AtomicString(m_in1->curr
entValue()->value())); |
81 | 83 |
82 if (!input1) | 84 if (!input1) |
83 return 0; | 85 return 0; |
84 | 86 |
85 ComponentTransferFunction red; | 87 ComponentTransferFunction red; |
86 ComponentTransferFunction green; | 88 ComponentTransferFunction green; |
87 ComponentTransferFunction blue; | 89 ComponentTransferFunction blue; |
88 ComponentTransferFunction alpha; | 90 ComponentTransferFunction alpha; |
89 | 91 |
90 for (Node* node = firstChild(); node; node = node->nextSibling()) { | 92 for (Node* node = firstChild(); node; node = node->nextSibling()) { |
91 if (node->hasTagName(SVGNames::feFuncRTag)) | 93 if (node->hasTagName(SVGNames::feFuncRTag)) |
92 red = toSVGFEFuncRElement(node)->transferFunction(); | 94 red = toSVGFEFuncRElement(node)->transferFunction(); |
93 else if (node->hasTagName(SVGNames::feFuncGTag)) | 95 else if (node->hasTagName(SVGNames::feFuncGTag)) |
94 green = toSVGFEFuncGElement(node)->transferFunction(); | 96 green = toSVGFEFuncGElement(node)->transferFunction(); |
95 else if (node->hasTagName(SVGNames::feFuncBTag)) | 97 else if (node->hasTagName(SVGNames::feFuncBTag)) |
96 blue = toSVGFEFuncBElement(node)->transferFunction(); | 98 blue = toSVGFEFuncBElement(node)->transferFunction(); |
97 else if (node->hasTagName(SVGNames::feFuncATag)) | 99 else if (node->hasTagName(SVGNames::feFuncATag)) |
98 alpha = toSVGFEFuncAElement(node)->transferFunction(); | 100 alpha = toSVGFEFuncAElement(node)->transferFunction(); |
99 } | 101 } |
100 | 102 |
101 RefPtr<FilterEffect> effect = FEComponentTransfer::create(filter, red, green
, blue, alpha); | 103 RefPtr<FilterEffect> effect = FEComponentTransfer::create(filter, red, green
, blue, alpha); |
102 effect->inputEffects().append(input1); | 104 effect->inputEffects().append(input1); |
103 return effect.release(); | 105 return effect.release(); |
104 } | 106 } |
105 | 107 |
106 } | 108 } |
OLD | NEW |