summaryrefslogtreecommitdiff
path: root/Source/WebCore/svg/SVGFELightElement.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Source/WebCore/svg/SVGFELightElement.cpp')
-rw-r--r--Source/WebCore/svg/SVGFELightElement.cpp80
1 files changed, 21 insertions, 59 deletions
diff --git a/Source/WebCore/svg/SVGFELightElement.cpp b/Source/WebCore/svg/SVGFELightElement.cpp
index dc56f36ae..9a85b408b 100644
--- a/Source/WebCore/svg/SVGFELightElement.cpp
+++ b/Source/WebCore/svg/SVGFELightElement.cpp
@@ -20,17 +20,16 @@
*/
#include "config.h"
-
-#if ENABLE(SVG) && ENABLE(FILTERS)
#include "SVGFELightElement.h"
-#include "Attribute.h"
#include "ElementIterator.h"
#include "RenderObject.h"
#include "RenderSVGResource.h"
-#include "SVGElementInstance.h"
#include "SVGFEDiffuseLightingElement.h"
+#include "SVGFEDistantLightElement.h"
+#include "SVGFEPointLightElement.h"
#include "SVGFESpecularLightingElement.h"
+#include "SVGFESpotLightElement.h"
#include "SVGFilterElement.h"
#include "SVGFilterPrimitiveStandardAttributes.h"
#include "SVGNames.h"
@@ -72,13 +71,13 @@ SVGFELightElement::SVGFELightElement(const QualifiedName& tagName, Document& doc
SVGFELightElement* SVGFELightElement::findLightElement(const SVGElement* svgElement)
{
for (auto& child : childrenOfType<SVGElement>(*svgElement)) {
- if (isSVGFEDistantLightElement(child) || isSVGFEPointLightElement(child) || isSVGFESpotLightElement(child))
+ if (is<SVGFEDistantLightElement>(child) || is<SVGFEPointLightElement>(child) || is<SVGFESpotLightElement>(child))
return static_cast<SVGFELightElement*>(const_cast<SVGElement*>(&child));
}
return nullptr;
}
-PassRefPtr<LightSource> SVGFELightElement::findLightSource(const SVGElement* svgElement)
+RefPtr<LightSource> SVGFELightElement::findLightSource(const SVGElement* svgElement)
{
SVGFELightElement* lightNode = findLightElement(svgElement);
if (!lightNode)
@@ -86,31 +85,8 @@ PassRefPtr<LightSource> SVGFELightElement::findLightSource(const SVGElement* svg
return lightNode->lightSource();
}
-bool SVGFELightElement::isSupportedAttribute(const QualifiedName& attrName)
-{
- DEFINE_STATIC_LOCAL(HashSet<QualifiedName>, supportedAttributes, ());
- if (supportedAttributes.isEmpty()) {
- supportedAttributes.add(SVGNames::azimuthAttr);
- supportedAttributes.add(SVGNames::elevationAttr);
- supportedAttributes.add(SVGNames::xAttr);
- supportedAttributes.add(SVGNames::yAttr);
- supportedAttributes.add(SVGNames::zAttr);
- supportedAttributes.add(SVGNames::pointsAtXAttr);
- supportedAttributes.add(SVGNames::pointsAtYAttr);
- supportedAttributes.add(SVGNames::pointsAtZAttr);
- supportedAttributes.add(SVGNames::specularExponentAttr);
- supportedAttributes.add(SVGNames::limitingConeAngleAttr);
- }
- return supportedAttributes.contains<SVGAttributeHashTranslator>(attrName);
-}
-
void SVGFELightElement::parseAttribute(const QualifiedName& name, const AtomicString& value)
{
- if (!isSupportedAttribute(name)) {
- SVGElement::parseAttribute(name, value);
- return;
- }
-
if (name == SVGNames::azimuthAttr) {
setAzimuthBaseValue(value.toFloat());
return;
@@ -161,48 +137,36 @@ void SVGFELightElement::parseAttribute(const QualifiedName& name, const AtomicSt
return;
}
- ASSERT_NOT_REACHED();
+ SVGElement::parseAttribute(name, value);
}
void SVGFELightElement::svgAttributeChanged(const QualifiedName& attrName)
{
- if (!isSupportedAttribute(attrName)) {
- SVGElement::svgAttributeChanged(attrName);
- return;
- }
+ if (attrName == SVGNames::azimuthAttr || attrName == SVGNames::elevationAttr
+ || attrName == SVGNames::xAttr || attrName == SVGNames::yAttr || attrName == SVGNames::zAttr
+ || attrName == SVGNames::pointsAtXAttr || attrName == SVGNames::pointsAtYAttr || attrName == SVGNames::pointsAtZAttr
+ || attrName == SVGNames::specularExponentAttr || attrName == SVGNames::limitingConeAngleAttr) {
- SVGElementInstance::InvalidationGuard invalidationGuard(this);
-
- if (attrName == SVGNames::azimuthAttr
- || attrName == SVGNames::elevationAttr
- || attrName == SVGNames::xAttr
- || attrName == SVGNames::yAttr
- || attrName == SVGNames::zAttr
- || attrName == SVGNames::pointsAtXAttr
- || attrName == SVGNames::pointsAtYAttr
- || attrName == SVGNames::pointsAtZAttr
- || attrName == SVGNames::specularExponentAttr
- || attrName == SVGNames::limitingConeAngleAttr) {
- ContainerNode* parent = parentNode();
+ auto* parent = parentElement();
if (!parent)
return;
- RenderObject* renderer = parent->renderer();
+ auto* renderer = parent->renderer();
if (!renderer || !renderer->isSVGResourceFilterPrimitive())
return;
- if (parent->hasTagName(SVGNames::feDiffuseLightingTag)) {
- SVGFEDiffuseLightingElement* diffuseLighting = static_cast<SVGFEDiffuseLightingElement*>(parent);
- diffuseLighting->lightElementAttributeChanged(this, attrName);
- return;
- } else if (parent->hasTagName(SVGNames::feSpecularLightingTag)) {
- SVGFESpecularLightingElement* specularLighting = static_cast<SVGFESpecularLightingElement*>(parent);
- specularLighting->lightElementAttributeChanged(this, attrName);
- return;
+ if (is<SVGFEDiffuseLightingElement>(*parent)) {
+ InstanceInvalidationGuard guard(*this);
+ downcast<SVGFEDiffuseLightingElement>(*parent).lightElementAttributeChanged(this, attrName);
+ } else if (is<SVGFESpecularLightingElement>(*parent)) {
+ InstanceInvalidationGuard guard(*this);
+ downcast<SVGFESpecularLightingElement>(*parent).lightElementAttributeChanged(this, attrName);
}
+
+ return;
}
- ASSERT_NOT_REACHED();
+ SVGElement::svgAttributeChanged(attrName);
}
void SVGFELightElement::childrenChanged(const ChildChange& change)
@@ -220,5 +184,3 @@ void SVGFELightElement::childrenChanged(const ChildChange& change)
}
}
-
-#endif // ENABLE(SVG)