summaryrefslogtreecommitdiffstats
path: root/chromium/third_party/WebKit/Source/core/svg/SVGFEDiffuseLightingElement.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/third_party/WebKit/Source/core/svg/SVGFEDiffuseLightingElement.cpp')
-rw-r--r--chromium/third_party/WebKit/Source/core/svg/SVGFEDiffuseLightingElement.cpp126
1 files changed, 45 insertions, 81 deletions
diff --git a/chromium/third_party/WebKit/Source/core/svg/SVGFEDiffuseLightingElement.cpp b/chromium/third_party/WebKit/Source/core/svg/SVGFEDiffuseLightingElement.cpp
index 9d18e3ccc74..d2aa04c3e52 100644
--- a/chromium/third_party/WebKit/Source/core/svg/SVGFEDiffuseLightingElement.cpp
+++ b/chromium/third_party/WebKit/Source/core/svg/SVGFEDiffuseLightingElement.cpp
@@ -22,7 +22,6 @@
#include "core/svg/SVGFEDiffuseLightingElement.h"
#include "core/rendering/style/RenderStyle.h"
-#include "core/svg/SVGElementInstance.h"
#include "core/svg/SVGParserUtilities.h"
#include "core/svg/graphics/filters/SVGFilterBuilder.h"
#include "platform/graphics/filters/FEDiffuseLighting.h"
@@ -30,47 +29,22 @@
namespace WebCore {
-// Animated property definitions
-DEFINE_ANIMATED_STRING(SVGFEDiffuseLightingElement, SVGNames::inAttr, In1, in1)
-DEFINE_ANIMATED_NUMBER(SVGFEDiffuseLightingElement, SVGNames::diffuseConstantAttr, DiffuseConstant, diffuseConstant)
-DEFINE_ANIMATED_NUMBER(SVGFEDiffuseLightingElement, SVGNames::surfaceScaleAttr, SurfaceScale, surfaceScale)
-DEFINE_ANIMATED_NUMBER_MULTIPLE_WRAPPERS(SVGFEDiffuseLightingElement, SVGNames::kernelUnitLengthAttr, kernelUnitLengthXIdentifier(), KernelUnitLengthX, kernelUnitLengthX)
-DEFINE_ANIMATED_NUMBER_MULTIPLE_WRAPPERS(SVGFEDiffuseLightingElement, SVGNames::kernelUnitLengthAttr, kernelUnitLengthYIdentifier(), KernelUnitLengthY, kernelUnitLengthY)
-
-BEGIN_REGISTER_ANIMATED_PROPERTIES(SVGFEDiffuseLightingElement)
- REGISTER_LOCAL_ANIMATED_PROPERTY(in1)
- REGISTER_LOCAL_ANIMATED_PROPERTY(diffuseConstant)
- REGISTER_LOCAL_ANIMATED_PROPERTY(surfaceScale)
- REGISTER_LOCAL_ANIMATED_PROPERTY(kernelUnitLengthX)
- REGISTER_LOCAL_ANIMATED_PROPERTY(kernelUnitLengthY)
- REGISTER_PARENT_ANIMATED_PROPERTIES(SVGFilterPrimitiveStandardAttributes)
-END_REGISTER_ANIMATED_PROPERTIES
-
inline SVGFEDiffuseLightingElement::SVGFEDiffuseLightingElement(Document& document)
: SVGFilterPrimitiveStandardAttributes(SVGNames::feDiffuseLightingTag, document)
- , m_diffuseConstant(1)
- , m_surfaceScale(1)
+ , m_diffuseConstant(SVGAnimatedNumber::create(this, SVGNames::diffuseConstantAttr, SVGNumber::create(1)))
+ , m_surfaceScale(SVGAnimatedNumber::create(this, SVGNames::surfaceScaleAttr, SVGNumber::create(1)))
+ , m_kernelUnitLength(SVGAnimatedNumberOptionalNumber::create(this, SVGNames::kernelUnitLengthAttr))
+ , m_in1(SVGAnimatedString::create(this, SVGNames::inAttr, SVGString::create()))
{
ScriptWrappable::init(this);
- registerAnimatedPropertiesForSVGFEDiffuseLightingElement();
-}
-
-PassRefPtr<SVGFEDiffuseLightingElement> SVGFEDiffuseLightingElement::create(Document& document)
-{
- return adoptRef(new SVGFEDiffuseLightingElement(document));
-}
-const AtomicString& SVGFEDiffuseLightingElement::kernelUnitLengthXIdentifier()
-{
- DEFINE_STATIC_LOCAL(AtomicString, s_identifier, ("SVGKernelUnitLengthX", AtomicString::ConstructFromLiteral));
- return s_identifier;
+ addToPropertyMap(m_diffuseConstant);
+ addToPropertyMap(m_surfaceScale);
+ addToPropertyMap(m_kernelUnitLength);
+ addToPropertyMap(m_in1);
}
-const AtomicString& SVGFEDiffuseLightingElement::kernelUnitLengthYIdentifier()
-{
- DEFINE_STATIC_LOCAL(AtomicString, s_identifier, ("SVGKernelUnitLengthY", AtomicString::ConstructFromLiteral));
- return s_identifier;
-}
+DEFINE_NODE_FACTORY(SVGFEDiffuseLightingElement)
bool SVGFEDiffuseLightingElement::isSupportedAttribute(const QualifiedName& attrName)
{
@@ -92,31 +66,20 @@ void SVGFEDiffuseLightingElement::parseAttribute(const QualifiedName& name, cons
return;
}
- if (name == SVGNames::inAttr) {
- setIn1BaseValue(value);
- return;
- }
+ SVGParsingError parseError = NoError;
- if (name == SVGNames::surfaceScaleAttr) {
- setSurfaceScaleBaseValue(value.toFloat());
- return;
- }
-
- if (name == SVGNames::diffuseConstantAttr) {
- setDiffuseConstantBaseValue(value.toFloat());
- return;
- }
+ if (name == SVGNames::inAttr)
+ m_in1->setBaseValueAsString(value, parseError);
+ else if (name == SVGNames::diffuseConstantAttr)
+ m_diffuseConstant->setBaseValueAsString(value, parseError);
+ else if (name == SVGNames::surfaceScaleAttr)
+ m_surfaceScale->setBaseValueAsString(value, parseError);
+ else if (name == SVGNames::kernelUnitLengthAttr)
+ m_kernelUnitLength->setBaseValueAsString(value, parseError);
+ else
+ ASSERT_NOT_REACHED();
- if (name == SVGNames::kernelUnitLengthAttr) {
- float x, y;
- if (parseNumberOptionalNumber(value, x, y)) {
- setKernelUnitLengthXBaseValue(x);
- setKernelUnitLengthYBaseValue(y);
- }
- return;
- }
-
- ASSERT_NOT_REACHED();
+ reportAttributeParsingError(parseError, name, value);
}
bool SVGFEDiffuseLightingElement::setFilterEffectAttribute(FilterEffect* effect, const QualifiedName& attrName)
@@ -130,35 +93,35 @@ bool SVGFEDiffuseLightingElement::setFilterEffectAttribute(FilterEffect* effect,
return diffuseLighting->setLightingColor(renderer->style()->svgStyle()->lightingColor());
}
if (attrName == SVGNames::surfaceScaleAttr)
- return diffuseLighting->setSurfaceScale(surfaceScaleCurrentValue());
+ return diffuseLighting->setSurfaceScale(m_surfaceScale->currentValue()->value());
if (attrName == SVGNames::diffuseConstantAttr)
- return diffuseLighting->setDiffuseConstant(diffuseConstantCurrentValue());
+ return diffuseLighting->setDiffuseConstant(m_diffuseConstant->currentValue()->value());
LightSource* lightSource = const_cast<LightSource*>(diffuseLighting->lightSource());
- const SVGFELightElement* lightElement = SVGFELightElement::findLightElement(this);
+ const SVGFELightElement* lightElement = SVGFELightElement::findLightElement(*this);
ASSERT(lightSource);
ASSERT(lightElement);
if (attrName == SVGNames::azimuthAttr)
- return lightSource->setAzimuth(lightElement->azimuthCurrentValue());
+ return lightSource->setAzimuth(lightElement->azimuth()->currentValue()->value());
if (attrName == SVGNames::elevationAttr)
- return lightSource->setElevation(lightElement->elevationCurrentValue());
+ return lightSource->setElevation(lightElement->elevation()->currentValue()->value());
if (attrName == SVGNames::xAttr)
- return lightSource->setX(lightElement->xCurrentValue());
+ return lightSource->setX(lightElement->x()->currentValue()->value());
if (attrName == SVGNames::yAttr)
- return lightSource->setY(lightElement->yCurrentValue());
+ return lightSource->setY(lightElement->y()->currentValue()->value());
if (attrName == SVGNames::zAttr)
- return lightSource->setZ(lightElement->zCurrentValue());
+ return lightSource->setZ(lightElement->z()->currentValue()->value());
if (attrName == SVGNames::pointsAtXAttr)
- return lightSource->setPointsAtX(lightElement->pointsAtXCurrentValue());
+ return lightSource->setPointsAtX(lightElement->pointsAtX()->currentValue()->value());
if (attrName == SVGNames::pointsAtYAttr)
- return lightSource->setPointsAtY(lightElement->pointsAtYCurrentValue());
+ return lightSource->setPointsAtY(lightElement->pointsAtY()->currentValue()->value());
if (attrName == SVGNames::pointsAtZAttr)
- return lightSource->setPointsAtZ(lightElement->pointsAtZCurrentValue());
+ return lightSource->setPointsAtZ(lightElement->pointsAtZ()->currentValue()->value());
if (attrName == SVGNames::specularExponentAttr)
- return lightSource->setSpecularExponent(lightElement->specularExponentCurrentValue());
+ return lightSource->setSpecularExponent(lightElement->specularExponent()->currentValue()->value());
if (attrName == SVGNames::limitingConeAngleAttr)
- return lightSource->setLimitingConeAngle(lightElement->limitingConeAngleCurrentValue());
+ return lightSource->setLimitingConeAngle(lightElement->limitingConeAngle()->currentValue()->value());
ASSERT_NOT_REACHED();
return false;
@@ -171,7 +134,7 @@ void SVGFEDiffuseLightingElement::svgAttributeChanged(const QualifiedName& attrN
return;
}
- SVGElementInstance::InvalidationGuard invalidationGuard(this);
+ SVGElement::InvalidationGuard invalidationGuard(this);
if (attrName == SVGNames::surfaceScaleAttr
|| attrName == SVGNames::diffuseConstantAttr
@@ -191,7 +154,7 @@ void SVGFEDiffuseLightingElement::svgAttributeChanged(const QualifiedName& attrN
void SVGFEDiffuseLightingElement::lightElementAttributeChanged(const SVGFELightElement* lightElement, const QualifiedName& attrName)
{
- if (SVGFELightElement::findLightElement(this) != lightElement)
+ if (SVGFELightElement::findLightElement(*this) != lightElement)
return;
// The light element has different attribute names.
@@ -200,24 +163,25 @@ void SVGFEDiffuseLightingElement::lightElementAttributeChanged(const SVGFELightE
PassRefPtr<FilterEffect> SVGFEDiffuseLightingElement::build(SVGFilterBuilder* filterBuilder, Filter* filter)
{
- FilterEffect* input1 = filterBuilder->getEffectById(in1CurrentValue());
+ FilterEffect* input1 = filterBuilder->getEffectById(AtomicString(m_in1->currentValue()->value()));
if (!input1)
- return 0;
+ return nullptr;
- RefPtr<LightSource> lightSource = SVGFELightElement::findLightSource(this);
- if (!lightSource)
- return 0;
+ SVGFELightElement* lightNode = SVGFELightElement::findLightElement(*this);
+ if (!lightNode)
+ return nullptr;
RenderObject* renderer = this->renderer();
if (!renderer)
- return 0;
+ return nullptr;
ASSERT(renderer->style());
Color color = renderer->style()->svgStyle()->lightingColor();
- RefPtr<FilterEffect> effect = FEDiffuseLighting::create(filter, color, surfaceScaleCurrentValue(), diffuseConstantCurrentValue(),
- kernelUnitLengthXCurrentValue(), kernelUnitLengthYCurrentValue(), lightSource.release());
+ RefPtr<LightSource> lightSource = lightNode->lightSource(filter);
+ RefPtr<FilterEffect> effect = FEDiffuseLighting::create(filter, color, m_surfaceScale->currentValue()->value(), m_diffuseConstant->currentValue()->value(),
+ kernelUnitLengthX()->currentValue()->value(), kernelUnitLengthY()->currentValue()->value(), lightSource.release());
effect->inputEffects().append(input1);
return effect.release();
}