#include "core/svg/SVGFEColorMatrixElement.h"
#include "SVGNames.h"
-#include "core/platform/graphics/filters/FilterEffect.h"
+#include "platform/graphics/filters/FilterEffect.h"
#include "core/svg/SVGElementInstance.h"
#include "core/svg/graphics/filters/SVGFilterBuilder.h"
namespace WebCore {
// Animated property definitions
-DEFINE_ANIMATED_STRING(SVGFEColorMatrixElement, SVGNames::inAttr, In1, in1)
DEFINE_ANIMATED_ENUMERATION(SVGFEColorMatrixElement, SVGNames::typeAttr, Type, type, ColorMatrixType)
-DEFINE_ANIMATED_NUMBER_LIST(SVGFEColorMatrixElement, SVGNames::valuesAttr, Values, values)
BEGIN_REGISTER_ANIMATED_PROPERTIES(SVGFEColorMatrixElement)
- REGISTER_LOCAL_ANIMATED_PROPERTY(in1)
REGISTER_LOCAL_ANIMATED_PROPERTY(type)
- REGISTER_LOCAL_ANIMATED_PROPERTY(values)
REGISTER_PARENT_ANIMATED_PROPERTIES(SVGFilterPrimitiveStandardAttributes)
END_REGISTER_ANIMATED_PROPERTIES
-inline SVGFEColorMatrixElement::SVGFEColorMatrixElement(const QualifiedName& tagName, Document& document)
- : SVGFilterPrimitiveStandardAttributes(tagName, document)
+inline SVGFEColorMatrixElement::SVGFEColorMatrixElement(Document& document)
+ : SVGFilterPrimitiveStandardAttributes(SVGNames::feColorMatrixTag, document)
+ , m_values(SVGAnimatedNumberList::create(this, SVGNames::valuesAttr, SVGNumberList::create()))
+ , m_in1(SVGAnimatedString::create(this, SVGNames::inAttr, SVGString::create()))
, m_type(FECOLORMATRIX_TYPE_MATRIX)
{
- ASSERT(hasTagName(SVGNames::feColorMatrixTag));
ScriptWrappable::init(this);
+
+ addToPropertyMap(m_values);
+ addToPropertyMap(m_in1);
registerAnimatedPropertiesForSVGFEColorMatrixElement();
}
-PassRefPtr<SVGFEColorMatrixElement> SVGFEColorMatrixElement::create(const QualifiedName& tagName, Document& document)
+PassRefPtr<SVGFEColorMatrixElement> SVGFEColorMatrixElement::create(Document& document)
{
- return adoptRef(new SVGFEColorMatrixElement(tagName, document));
+ return adoptRef(new SVGFEColorMatrixElement(document));
}
bool SVGFEColorMatrixElement::isSupportedAttribute(const QualifiedName& attrName)
return;
}
- if (name == SVGNames::inAttr) {
- setIn1BaseValue(value);
- return;
- }
+ SVGParsingError parseError = NoError;
- if (name == SVGNames::valuesAttr) {
- SVGNumberList newList;
- newList.parse(value);
- detachAnimatedValuesListWrappers(newList.size());
- setValuesBaseValue(newList);
- return;
- }
+ if (name == SVGNames::inAttr)
+ m_in1->setBaseValueAsString(value, parseError);
+ else if (name == SVGNames::valuesAttr)
+ m_values->setBaseValueAsString(value, parseError);
+ else
+ ASSERT_NOT_REACHED();
- ASSERT_NOT_REACHED();
+ reportAttributeParsingError(parseError, name, value);
}
bool SVGFEColorMatrixElement::setFilterEffectAttribute(FilterEffect* effect, const QualifiedName& attrName)
if (attrName == SVGNames::typeAttr)
return colorMatrix->setType(typeCurrentValue());
if (attrName == SVGNames::valuesAttr)
- return colorMatrix->setValues(valuesCurrentValue().toFloatVector());
+ return colorMatrix->setValues(m_values->currentValue()->toFloatVector());
ASSERT_NOT_REACHED();
return false;
PassRefPtr<FilterEffect> SVGFEColorMatrixElement::build(SVGFilterBuilder* filterBuilder, Filter* filter)
{
- FilterEffect* input1 = filterBuilder->getEffectById(in1CurrentValue());
+ FilterEffect* input1 = filterBuilder->getEffectById(AtomicString(m_in1->currentValue()->value()));
if (!input1)
return 0;
break;
}
} else {
- SVGNumberList& values = valuesCurrentValue();
- unsigned size = values.size();
+ RefPtr<SVGNumberList> values = m_values->currentValue();
+ size_t size = values->numberOfItems();
if ((filterType == FECOLORMATRIX_TYPE_MATRIX && size != 20)
|| (filterType == FECOLORMATRIX_TYPE_HUEROTATE && size != 1)
|| (filterType == FECOLORMATRIX_TYPE_SATURATE && size != 1))
return 0;
- filterValues = values.toFloatVector();
+ filterValues = values->toFloatVector();
}
RefPtr<FilterEffect> effect = FEColorMatrix::create(filter, filterType, filterValues);