LibWeb/SVG: Add FEGaussianBlurElement

This commit is contained in:
Lucien Fiorini 2025-07-04 21:08:28 +02:00 committed by Sam Atkins
commit 5d85959f5f
Notes: github-actions[bot] 2025-07-09 17:08:34 +00:00
10 changed files with 133 additions and 0 deletions

View file

@ -825,6 +825,7 @@ set(SOURCES
SVG/SVGEllipseElement.cpp SVG/SVGEllipseElement.cpp
SVG/SVGFEBlendElement.cpp SVG/SVGFEBlendElement.cpp
SVG/SVGFEFloodElement.cpp SVG/SVGFEFloodElement.cpp
SVG/SVGFEGaussianBlurElement.cpp
SVG/SVGFilterElement.cpp SVG/SVGFilterElement.cpp
SVG/SVGForeignObjectElement.cpp SVG/SVGForeignObjectElement.cpp
SVG/SVGGElement.cpp SVG/SVGGElement.cpp

View file

@ -93,6 +93,7 @@
#include <LibWeb/SVG/SVGEllipseElement.h> #include <LibWeb/SVG/SVGEllipseElement.h>
#include <LibWeb/SVG/SVGFEBlendElement.h> #include <LibWeb/SVG/SVGFEBlendElement.h>
#include <LibWeb/SVG/SVGFEFloodElement.h> #include <LibWeb/SVG/SVGFEFloodElement.h>
#include <LibWeb/SVG/SVGFEGaussianBlurElement.h>
#include <LibWeb/SVG/SVGFilterElement.h> #include <LibWeb/SVG/SVGFilterElement.h>
#include <LibWeb/SVG/SVGForeignObjectElement.h> #include <LibWeb/SVG/SVGForeignObjectElement.h>
#include <LibWeb/SVG/SVGGElement.h> #include <LibWeb/SVG/SVGGElement.h>
@ -467,6 +468,8 @@ static GC::Ref<SVG::SVGElement> create_svg_element(JS::Realm& realm, Document& d
return realm.create<SVG::SVGFEBlendElement>(document, move(qualified_name)); return realm.create<SVG::SVGFEBlendElement>(document, move(qualified_name));
if (local_name == SVG::TagNames::feFlood) if (local_name == SVG::TagNames::feFlood)
return realm.create<SVG::SVGFEFloodElement>(document, move(qualified_name)); return realm.create<SVG::SVGFEFloodElement>(document, move(qualified_name));
if (local_name == SVG::TagNames::feGaussianBlur)
return realm.create<SVG::SVGFEGaussianBlurElement>(document, move(qualified_name));
if (local_name == SVG::TagNames::filter) if (local_name == SVG::TagNames::filter)
return realm.create<SVG::SVGFilterElement>(document, move(qualified_name)); return realm.create<SVG::SVGFilterElement>(document, move(qualified_name));
if (local_name.equals_ignoring_ascii_case(SVG::TagNames::foreignObject)) if (local_name.equals_ignoring_ascii_case(SVG::TagNames::foreignObject))

View file

@ -969,6 +969,7 @@ class SVGElement;
class SVGEllipseElement; class SVGEllipseElement;
class SVGFEBlendElement; class SVGFEBlendElement;
class SVGFEFloodElement; class SVGFEFloodElement;
class SVGFEGaussianBlurElement;
class SVGFilterElement; class SVGFilterElement;
class SVGForeignObjectElement; class SVGForeignObjectElement;
class SVGGeometryElement; class SVGGeometryElement;

View file

@ -79,6 +79,8 @@ namespace Web::SVG::AttributeNames {
__ENUMERATE_SVG_ATTRIBUTE(spreadMethod, "spreadMethod") \ __ENUMERATE_SVG_ATTRIBUTE(spreadMethod, "spreadMethod") \
__ENUMERATE_SVG_ATTRIBUTE(startOffset, "startOffset") \ __ENUMERATE_SVG_ATTRIBUTE(startOffset, "startOffset") \
__ENUMERATE_SVG_ATTRIBUTE(stdDeviation, "stdDeviation") \ __ENUMERATE_SVG_ATTRIBUTE(stdDeviation, "stdDeviation") \
__ENUMERATE_SVG_ATTRIBUTE(stdDeviationX, "stdDeviationX") \
__ENUMERATE_SVG_ATTRIBUTE(stdDeviationY, "stdDeviationY") \
__ENUMERATE_SVG_ATTRIBUTE(stitchTiles, "stitchTiles") \ __ENUMERATE_SVG_ATTRIBUTE(stitchTiles, "stitchTiles") \
__ENUMERATE_SVG_ATTRIBUTE(stopColor, "stop-color") \ __ENUMERATE_SVG_ATTRIBUTE(stopColor, "stop-color") \
__ENUMERATE_SVG_ATTRIBUTE(stopOpacity, "stop-opacity") \ __ENUMERATE_SVG_ATTRIBUTE(stopOpacity, "stop-opacity") \

View file

@ -0,0 +1,62 @@
/*
* Copyright (c) 2025, Lucien Fiorini <lucienfiorini@gmail.com>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include "SVGAnimatedEnumeration.h"
#include <LibWeb/Bindings/SVGFEGaussianBlurElementPrototype.h>
#include <LibWeb/CSS/Parser/Parser.h>
#include <LibWeb/Layout/Node.h>
#include <LibWeb/SVG/SVGFEGaussianBlurElement.h>
namespace Web::SVG {
GC_DEFINE_ALLOCATOR(SVGFEGaussianBlurElement);
SVGFEGaussianBlurElement::SVGFEGaussianBlurElement(DOM::Document& document, DOM::QualifiedName qualified_name)
: SVGElement(document, qualified_name)
{
}
void SVGFEGaussianBlurElement::initialize(JS::Realm& realm)
{
Base::initialize(realm);
WEB_SET_PROTOTYPE_FOR_INTERFACE(SVGFEGaussianBlurElement);
}
void SVGFEGaussianBlurElement::visit_edges(Cell::Visitor& visitor)
{
Base::visit_edges(visitor);
SVGFilterPrimitiveStandardAttributes::visit_edges(visitor);
visitor.visit(m_in1);
}
GC::Ref<SVGAnimatedString> SVGFEGaussianBlurElement::in1()
{
if (!m_in1)
m_in1 = SVGAnimatedString::create(realm(), *this, AttributeNames::in);
return *m_in1;
}
GC::Ref<SVGAnimatedNumber> SVGFEGaussianBlurElement::std_deviation_x() const
{
// FIXME: Resolve the actual value from AttributeNames::stdDeviationX.
return SVGAnimatedNumber::create(realm(), 125.0f, 125.0f);
}
GC::Ref<SVGAnimatedNumber> SVGFEGaussianBlurElement::std_deviation_y() const
{
// FIXME: Resolve the actual value from AttributeNames::stdDeviationY.
return SVGAnimatedNumber::create(realm(), 125.0f, 125.0f);
}
GC::Ref<SVGAnimatedEnumeration> SVGFEGaussianBlurElement::edge_mode() const
{
// FIXME: Resolve the actual value from AttributeNames::edgeMode.
return SVGAnimatedEnumeration::create(realm(), 0);
}
}

View file

@ -0,0 +1,38 @@
/*
* Copyright (c) 2025, Lucien Fiorini <lucienfiorini@gmail.com>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <LibWeb/SVG/SVGAnimatedNumber.h>
#include <LibWeb/SVG/SVGElement.h>
#include <LibWeb/SVG/SVGFilterPrimitiveStandardAttributes.h>
namespace Web::SVG {
class SVGFEGaussianBlurElement final
: public SVGElement
, public SVGFilterPrimitiveStandardAttributes<SVGFEGaussianBlurElement> {
WEB_PLATFORM_OBJECT(SVGFEGaussianBlurElement, SVGElement);
GC_DECLARE_ALLOCATOR(SVGFEGaussianBlurElement);
public:
virtual ~SVGFEGaussianBlurElement() override = default;
GC::Ref<SVGAnimatedString> in1();
GC::Ref<SVGAnimatedNumber> std_deviation_x() const;
GC::Ref<SVGAnimatedNumber> std_deviation_y() const;
GC::Ref<SVGAnimatedEnumeration> edge_mode() const;
private:
SVGFEGaussianBlurElement(DOM::Document&, DOM::QualifiedName);
virtual void initialize(JS::Realm&) override;
virtual void visit_edges(Cell::Visitor&) override;
GC::Ptr<SVGAnimatedString> m_in1;
};
}

View file

@ -0,0 +1,23 @@
#import <SVG/SVGAnimatedEnumeration.idl>
#import <SVG/SVGAnimatedString.idl>
#import <SVG/SVGFilterPrimitiveStandardAttributes.idl>
// https://www.w3.org/TR/filter-effects-1/#InterfaceSVGFEGaussianBlurElement
[Exposed=Window]
interface SVGFEGaussianBlurElement : SVGElement {
// Edge Mode Values
const unsigned short SVG_EDGEMODE_UNKNOWN = 0;
const unsigned short SVG_EDGEMODE_DUPLICATE = 1;
const unsigned short SVG_EDGEMODE_WRAP = 2;
const unsigned short SVG_EDGEMODE_NONE = 3;
readonly attribute SVGAnimatedString in1;
readonly attribute SVGAnimatedNumber stdDeviationX;
readonly attribute SVGAnimatedNumber stdDeviationY;
readonly attribute SVGAnimatedEnumeration edgeMode;
[FIXME] void setStdDeviation(float stdDeviationX, float stdDeviationY);
};
SVGFEGaussianBlurElement includes SVGFilterPrimitiveStandardAttributes;

View file

@ -19,6 +19,7 @@ namespace Web::SVG::TagNames {
__ENUMERATE_SVG_TAG(ellipse) \ __ENUMERATE_SVG_TAG(ellipse) \
__ENUMERATE_SVG_TAG(feBlend) \ __ENUMERATE_SVG_TAG(feBlend) \
__ENUMERATE_SVG_TAG(feFlood) \ __ENUMERATE_SVG_TAG(feFlood) \
__ENUMERATE_SVG_TAG(feGaussianBlur) \
__ENUMERATE_SVG_TAG(filter) \ __ENUMERATE_SVG_TAG(filter) \
__ENUMERATE_SVG_TAG(foreignObject) \ __ENUMERATE_SVG_TAG(foreignObject) \
__ENUMERATE_SVG_TAG(g) \ __ENUMERATE_SVG_TAG(g) \

View file

@ -342,6 +342,7 @@ libweb_js_bindings(SVG/SVGCircleElement)
libweb_js_bindings(SVG/SVGEllipseElement) libweb_js_bindings(SVG/SVGEllipseElement)
libweb_js_bindings(SVG/SVGFEBlendElement) libweb_js_bindings(SVG/SVGFEBlendElement)
libweb_js_bindings(SVG/SVGFEFloodElement) libweb_js_bindings(SVG/SVGFEFloodElement)
libweb_js_bindings(SVG/SVGFEGaussianBlurElement)
libweb_js_bindings(SVG/SVGFilterElement) libweb_js_bindings(SVG/SVGFilterElement)
libweb_js_bindings(SVG/SVGForeignObjectElement) libweb_js_bindings(SVG/SVGForeignObjectElement)
libweb_js_bindings(SVG/SVGLength) libweb_js_bindings(SVG/SVGLength)

View file

@ -340,6 +340,7 @@ SVGElement
SVGEllipseElement SVGEllipseElement
SVGFEBlendElement SVGFEBlendElement
SVGFEFloodElement SVGFEFloodElement
SVGFEGaussianBlurElement
SVGFilterElement SVGFilterElement
SVGForeignObjectElement SVGForeignObjectElement
SVGGElement SVGGElement