SVGFEMergeElement.cpp [plain text]
#include "config.h"
#if ENABLE(SVG) && ENABLE(FILTERS)
#include "SVGFEMergeElement.h"
#include "FilterEffect.h"
#include "SVGFEMergeNodeElement.h"
#include "SVGFilterBuilder.h"
#include "SVGNames.h"
namespace WebCore {
inline SVGFEMergeElement::SVGFEMergeElement(const QualifiedName& tagName, Document* document)
: SVGFilterPrimitiveStandardAttributes(tagName, document)
{
ASSERT(hasTagName(SVGNames::feMergeTag));
}
PassRefPtr<SVGFEMergeElement> SVGFEMergeElement::create(const QualifiedName& tagName, Document* document)
{
return adoptRef(new SVGFEMergeElement(tagName, document));
}
PassRefPtr<FilterEffect> SVGFEMergeElement::build(SVGFilterBuilder* filterBuilder, Filter* filter)
{
RefPtr<FilterEffect> effect = FEMerge::create(filter);
FilterEffectVector& mergeInputs = effect->inputEffects();
for (Node* node = firstChild(); node; node = node->nextSibling()) {
if (node->hasTagName(SVGNames::feMergeNodeTag)) {
FilterEffect* mergeEffect = filterBuilder->getEffectById(static_cast<SVGFEMergeNodeElement*>(node)->in1());
if (!mergeEffect)
return 0;
mergeInputs.append(mergeEffect);
}
}
if (mergeInputs.isEmpty())
return 0;
return effect.release();
}
}
#endif // ENABLE(SVG)