don't discard iframe children.
[kdelibs.git] / khtml / svg / SVGFEDisplacementMapElement.cpp
blob8852a65257b3ac37667d8cdd7d907db7474acfad
1 /*
2 Copyright (C) 2006 Oliver Hunt <oliver@nerget.com>
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.
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.
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.
21 #include "config.h"
23 #if ENABLE(SVG) && ENABLE(SVG_FILTERS)
24 #include "SVGFEDisplacementMapElement.h"
26 #include "SVGResourceFilter.h"
28 namespace WebCore {
30 SVGFEDisplacementMapElement::SVGFEDisplacementMapElement(const QualifiedName& tagName, Document* doc)
31 : SVGFilterPrimitiveStandardAttributes(tagName, doc)
32 , m_xChannelSelector(SVG_CHANNEL_A)
33 , m_yChannelSelector(SVG_CHANNEL_A)
34 , m_scale(0.0f)
35 , m_filterEffect(0)
39 SVGFEDisplacementMapElement::~SVGFEDisplacementMapElement()
41 delete m_filterEffect;
44 ANIMATED_PROPERTY_DEFINITIONS(SVGFEDisplacementMapElement, String, String, string, In1, in1, SVGNames::inAttr, m_in1)
45 ANIMATED_PROPERTY_DEFINITIONS(SVGFEDisplacementMapElement, String, String, string, In2, in2, SVGNames::in2Attr, m_in2)
46 ANIMATED_PROPERTY_DEFINITIONS(SVGFEDisplacementMapElement, int, Enumeration, enumeration, XChannelSelector, xChannelSelector, SVGNames::xChannelSelectorAttr, m_xChannelSelector)
47 ANIMATED_PROPERTY_DEFINITIONS(SVGFEDisplacementMapElement, int, Enumeration, enumeration, YChannelSelector, yChannelSelector, SVGNames::yChannelSelectorAttr, m_yChannelSelector)
48 ANIMATED_PROPERTY_DEFINITIONS(SVGFEDisplacementMapElement, float, Number, number, Scale, scale, SVGNames::scaleAttr, m_scale)
50 SVGChannelSelectorType SVGFEDisplacementMapElement::stringToChannel(const String& key)
52 if (key == "R")
53 return SVG_CHANNEL_R;
54 else if (key == "G")
55 return SVG_CHANNEL_G;
56 else if (key == "B")
57 return SVG_CHANNEL_B;
58 else if (key == "A")
59 return SVG_CHANNEL_A;
61 return SVG_CHANNEL_UNKNOWN;
64 void SVGFEDisplacementMapElement::parseMappedAttribute(MappedAttribute* attr)
66 const String& value = attr->value();
67 if (attr->name() == SVGNames::xChannelSelectorAttr)
68 setXChannelSelectorBaseValue(stringToChannel(value));
69 else if (attr->name() == SVGNames::yChannelSelectorAttr)
70 setYChannelSelectorBaseValue(stringToChannel(value));
71 else if (attr->name() == SVGNames::inAttr)
72 setIn1BaseValue(value);
73 else if (attr->name() == SVGNames::in2Attr)
74 setIn2BaseValue(value);
75 else if (attr->name() == SVGNames::scaleAttr)
76 setScaleBaseValue(value.toFloat());
77 else
78 SVGFilterPrimitiveStandardAttributes::parseMappedAttribute(attr);
81 SVGFEDisplacementMap* SVGFEDisplacementMapElement::filterEffect(SVGResourceFilter* filter) const
83 if (!m_filterEffect)
84 m_filterEffect = new SVGFEDisplacementMap(filter);
86 m_filterEffect->setXChannelSelector((SVGChannelSelectorType) xChannelSelector());
87 m_filterEffect->setYChannelSelector((SVGChannelSelectorType) yChannelSelector());
88 m_filterEffect->setIn(in1());
89 m_filterEffect->setIn2(in2());
90 m_filterEffect->setScale(scale());
92 setStandardAttributes(m_filterEffect);
93 return m_filterEffect;
98 #endif // ENABLE(SVG)
100 // vim:ts=4:noet