RenderSVGResourceFilterPrimitive.cpp [plain text]
#include "config.h"
#include "RenderSVGResourceFilterPrimitive.h"
#include "SVGFEDiffuseLightingElement.h"
#include "SVGFEFloodElement.h"
#include "SVGFEImage.h"
#include "SVGFESpecularLightingElement.h"
#include "SVGFilterPrimitiveStandardAttributes.h"
#include "SVGNames.h"
#include <wtf/IsoMallocInlines.h>
namespace WebCore {
WTF_MAKE_ISO_ALLOCATED_IMPL(RenderSVGResourceFilterPrimitive);
RenderSVGResourceFilterPrimitive::RenderSVGResourceFilterPrimitive(SVGFilterPrimitiveStandardAttributes& filterPrimitiveElement, RenderStyle&& style)
: RenderSVGHiddenContainer(filterPrimitiveElement, WTFMove(style))
{
}
SVGFilterPrimitiveStandardAttributes& RenderSVGResourceFilterPrimitive::filterPrimitiveElement() const
{
return static_cast<SVGFilterPrimitiveStandardAttributes&>(RenderSVGHiddenContainer::element());
}
void RenderSVGResourceFilterPrimitive::styleDidChange(StyleDifference diff, const RenderStyle* oldStyle)
{
RenderSVGHiddenContainer::styleDidChange(diff, oldStyle);
auto* filter = parent();
if (!filter)
return;
if (diff == StyleDifference::Equal || !oldStyle)
return;
const SVGRenderStyle& newStyle = style().svgStyle();
if (is<SVGFEFloodElement>(filterPrimitiveElement())) {
if (newStyle.floodColor() != oldStyle->svgStyle().floodColor())
downcast<RenderSVGResourceFilter>(*filter).primitiveAttributeChanged(this, SVGNames::flood_colorAttr);
if (newStyle.floodOpacity() != oldStyle->svgStyle().floodOpacity())
downcast<RenderSVGResourceFilter>(*filter).primitiveAttributeChanged(this, SVGNames::flood_opacityAttr);
} else if (is<SVGFEDiffuseLightingElement>(filterPrimitiveElement()) || is<SVGFESpecularLightingElement>(filterPrimitiveElement())) {
if (newStyle.lightingColor() != oldStyle->svgStyle().lightingColor())
downcast<RenderSVGResourceFilter>(*filter).primitiveAttributeChanged(this, SVGNames::lighting_colorAttr);
}
}
}