diff options
Diffstat (limited to 'chromium/third_party/WebKit/Source/core/svg/SVGFEDropShadowElement.cpp')
-rw-r--r-- | chromium/third_party/WebKit/Source/core/svg/SVGFEDropShadowElement.cpp | 101 |
1 files changed, 31 insertions, 70 deletions
diff --git a/chromium/third_party/WebKit/Source/core/svg/SVGFEDropShadowElement.cpp b/chromium/third_party/WebKit/Source/core/svg/SVGFEDropShadowElement.cpp index 366eaf3512c..58c7e00bbff 100644 --- a/chromium/third_party/WebKit/Source/core/svg/SVGFEDropShadowElement.cpp +++ b/chromium/third_party/WebKit/Source/core/svg/SVGFEDropShadowElement.cpp @@ -21,63 +21,35 @@ #include "core/svg/SVGFEDropShadowElement.h" -#include "SVGNames.h" +#include "core/SVGNames.h" #include "core/rendering/style/RenderStyle.h" #include "core/rendering/style/SVGRenderStyle.h" -#include "core/svg/SVGElementInstance.h" #include "core/svg/SVGParserUtilities.h" #include "core/svg/graphics/filters/SVGFilterBuilder.h" namespace WebCore { -// Animated property definitions -DEFINE_ANIMATED_STRING(SVGFEDropShadowElement, SVGNames::inAttr, In1, in1) -DEFINE_ANIMATED_NUMBER(SVGFEDropShadowElement, SVGNames::dxAttr, Dx, dx) -DEFINE_ANIMATED_NUMBER(SVGFEDropShadowElement, SVGNames::dyAttr, Dy, dy) -DEFINE_ANIMATED_NUMBER_MULTIPLE_WRAPPERS(SVGFEDropShadowElement, SVGNames::stdDeviationAttr, stdDeviationXIdentifier(), StdDeviationX, stdDeviationX) -DEFINE_ANIMATED_NUMBER_MULTIPLE_WRAPPERS(SVGFEDropShadowElement, SVGNames::stdDeviationAttr, stdDeviationYIdentifier(), StdDeviationY, stdDeviationY) - -BEGIN_REGISTER_ANIMATED_PROPERTIES(SVGFEDropShadowElement) - REGISTER_LOCAL_ANIMATED_PROPERTY(in1) - REGISTER_LOCAL_ANIMATED_PROPERTY(dx) - REGISTER_LOCAL_ANIMATED_PROPERTY(dy) - REGISTER_LOCAL_ANIMATED_PROPERTY(stdDeviationX) - REGISTER_LOCAL_ANIMATED_PROPERTY(stdDeviationY) - REGISTER_PARENT_ANIMATED_PROPERTIES(SVGFilterPrimitiveStandardAttributes) -END_REGISTER_ANIMATED_PROPERTIES - inline SVGFEDropShadowElement::SVGFEDropShadowElement(Document& document) : SVGFilterPrimitiveStandardAttributes(SVGNames::feDropShadowTag, document) - , m_dx(2) - , m_dy(2) - , m_stdDeviationX(2) - , m_stdDeviationY(2) + , m_dx(SVGAnimatedNumber::create(this, SVGNames::dxAttr, SVGNumber::create(2))) + , m_dy(SVGAnimatedNumber::create(this, SVGNames::dyAttr, SVGNumber::create(2))) + , m_stdDeviation(SVGAnimatedNumberOptionalNumber::create(this, SVGNames::stdDeviationAttr, 2, 2)) + , m_in1(SVGAnimatedString::create(this, SVGNames::inAttr, SVGString::create())) { ScriptWrappable::init(this); - registerAnimatedPropertiesForSVGFEDropShadowElement(); -} - -PassRefPtr<SVGFEDropShadowElement> SVGFEDropShadowElement::create(Document& document) -{ - return adoptRef(new SVGFEDropShadowElement(document)); -} -const AtomicString& SVGFEDropShadowElement::stdDeviationXIdentifier() -{ - DEFINE_STATIC_LOCAL(AtomicString, s_identifier, ("SVGStdDeviationX", AtomicString::ConstructFromLiteral)); - return s_identifier; + addToPropertyMap(m_dx); + addToPropertyMap(m_dy); + addToPropertyMap(m_stdDeviation); + addToPropertyMap(m_in1); } -const AtomicString& SVGFEDropShadowElement::stdDeviationYIdentifier() -{ - DEFINE_STATIC_LOCAL(AtomicString, s_identifier, ("SVGStdDeviationY", AtomicString::ConstructFromLiteral)); - return s_identifier; -} +DEFINE_NODE_FACTORY(SVGFEDropShadowElement) void SVGFEDropShadowElement::setStdDeviation(float x, float y) { - setStdDeviationXBaseValue(x); - setStdDeviationYBaseValue(y); + stdDeviationX()->baseValue()->setValue(x); + stdDeviationY()->baseValue()->setValue(y); invalidate(); } @@ -100,31 +72,20 @@ void SVGFEDropShadowElement::parseAttribute(const QualifiedName& name, const Ato return; } - if (name == SVGNames::stdDeviationAttr) { - float x, y; - if (parseNumberOptionalNumber(value, x, y)) { - setStdDeviationXBaseValue(x); - setStdDeviationYBaseValue(y); - } - return; - } + SVGParsingError parseError = NoError; - if (name == SVGNames::inAttr) { - setIn1BaseValue(value); - return; - } - - if (name == SVGNames::dxAttr) { - setDxBaseValue(value.toFloat()); - return; - } + if (name == SVGNames::inAttr) + m_in1->setBaseValueAsString(value, parseError); + else if (name == SVGNames::dxAttr) + m_dx->setBaseValueAsString(value, parseError); + else if (name == SVGNames::dyAttr) + m_dy->setBaseValueAsString(value, parseError); + else if (name == SVGNames::stdDeviationAttr) + m_stdDeviation->setBaseValueAsString(value, parseError); + else + ASSERT_NOT_REACHED(); - if (name == SVGNames::dyAttr) { - setDyBaseValue(value.toFloat()); - return; - } - - ASSERT_NOT_REACHED(); + reportAttributeParsingError(parseError, name, value); } void SVGFEDropShadowElement::svgAttributeChanged(const QualifiedName& attrName) @@ -134,7 +95,7 @@ void SVGFEDropShadowElement::svgAttributeChanged(const QualifiedName& attrName) return; } - SVGElementInstance::InvalidationGuard invalidationGuard(this); + SVGElement::InvalidationGuard invalidationGuard(this); if (attrName == SVGNames::inAttr || attrName == SVGNames::stdDeviationAttr @@ -151,10 +112,10 @@ PassRefPtr<FilterEffect> SVGFEDropShadowElement::build(SVGFilterBuilder* filterB { RenderObject* renderer = this->renderer(); if (!renderer) - return 0; + return nullptr; - if (stdDeviationXCurrentValue() < 0 || stdDeviationYCurrentValue() < 0) - return 0; + if (stdDeviationX()->currentValue()->value() < 0 || stdDeviationY()->currentValue()->value() < 0) + return nullptr; ASSERT(renderer->style()); const SVGRenderStyle* svgStyle = renderer->style()->svgStyle(); @@ -162,11 +123,11 @@ PassRefPtr<FilterEffect> SVGFEDropShadowElement::build(SVGFilterBuilder* filterB Color color = svgStyle->floodColor(); float opacity = svgStyle->floodOpacity(); - FilterEffect* input1 = filterBuilder->getEffectById(in1CurrentValue()); + FilterEffect* input1 = filterBuilder->getEffectById(AtomicString(m_in1->currentValue()->value())); if (!input1) - return 0; + return nullptr; - RefPtr<FilterEffect> effect = FEDropShadow::create(filter, stdDeviationXCurrentValue(), stdDeviationYCurrentValue(), dxCurrentValue(), dyCurrentValue(), color, opacity); + RefPtr<FilterEffect> effect = FEDropShadow::create(filter, stdDeviationX()->currentValue()->value(), stdDeviationY()->currentValue()->value(), m_dx->currentValue()->value(), m_dy->currentValue()->value(), color, opacity); effect->inputEffects().append(input1); return effect.release(); } |