Skip to content

Commit 03a8de5

Browse files
committed
LibWeb: Add SVGFEComponentTransferElement
1 parent c0630c7 commit 03a8de5

11 files changed

+139
-41
lines changed

Libraries/LibWeb/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -914,6 +914,7 @@ set(SOURCES
914914
SVG/SVGEllipseElement.cpp
915915
SVG/SVGFEBlendElement.cpp
916916
SVG/SVGFEColorMatrixElement.cpp
917+
SVG/SVGFEComponentTransferElement.cpp
917918
SVG/SVGFECompositeElement.cpp
918919
SVG/SVGFEFloodElement.cpp
919920
SVG/SVGFEGaussianBlurElement.cpp

Libraries/LibWeb/DOM/ElementFactory.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@
9595
#include <LibWeb/SVG/SVGEllipseElement.h>
9696
#include <LibWeb/SVG/SVGFEBlendElement.h>
9797
#include <LibWeb/SVG/SVGFEColorMatrixElement.h>
98+
#include <LibWeb/SVG/SVGFEComponentTransferElement.h>
9899
#include <LibWeb/SVG/SVGFECompositeElement.h>
99100
#include <LibWeb/SVG/SVGFEFloodElement.h>
100101
#include <LibWeb/SVG/SVGFEGaussianBlurElement.h>
@@ -475,12 +476,14 @@ static GC::Ref<SVG::SVGElement> create_svg_element(JS::Realm& realm, Document& d
475476
return realm.create<SVG::SVGEllipseElement>(document, move(qualified_name));
476477
if (local_name == SVG::TagNames::feBlend)
477478
return realm.create<SVG::SVGFEBlendElement>(document, move(qualified_name));
479+
if (local_name == SVG::TagNames::feColorMatrix)
480+
return realm.create<SVG::SVGFEColorMatrixElement>(document, move(qualified_name));
481+
if (local_name == SVG::TagNames::feComponentTransfer)
482+
return realm.create<SVG::SVGFEComponentTransferElement>(document, move(qualified_name));
478483
if (local_name == SVG::TagNames::feComposite)
479484
return realm.create<SVG::SVGFECompositeElement>(document, move(qualified_name));
480485
if (local_name == SVG::TagNames::feFlood)
481486
return realm.create<SVG::SVGFEFloodElement>(document, move(qualified_name));
482-
if (local_name == SVG::TagNames::feColorMatrix)
483-
return realm.create<SVG::SVGFEColorMatrixElement>(document, move(qualified_name));
484487
if (local_name == SVG::TagNames::feGaussianBlur)
485488
return realm.create<SVG::SVGFEGaussianBlurElement>(document, move(qualified_name));
486489
if (local_name == SVG::TagNames::feImage)

Libraries/LibWeb/Forward.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1105,6 +1105,7 @@ class SVGElement;
11051105
class SVGEllipseElement;
11061106
class SVGFEBlendElement;
11071107
class SVGFEColorMatrixElement;
1108+
class SVGFEComponentTransferElement;
11081109
class SVGFECompositeElement;
11091110
class SVGFEFloodElement;
11101111
class SVGFEGaussianBlurElement;
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/*
2+
* Copyright (c) 2025, Jelle Raaijmakers <jelle@ladybird.org>
3+
*
4+
* SPDX-License-Identifier: BSD-2-Clause
5+
*/
6+
7+
#include <LibWeb/Bindings/SVGFEComponentTransferElementPrototype.h>
8+
#include <LibWeb/SVG/SVGFEComponentTransferElement.h>
9+
10+
namespace Web::SVG {
11+
12+
GC_DEFINE_ALLOCATOR(SVGFEComponentTransferElement);
13+
14+
SVGFEComponentTransferElement::SVGFEComponentTransferElement(DOM::Document& document, DOM::QualifiedName qualified_name)
15+
: SVGElement(document, move(qualified_name))
16+
{
17+
}
18+
19+
void SVGFEComponentTransferElement::initialize(JS::Realm& realm)
20+
{
21+
WEB_SET_PROTOTYPE_FOR_INTERFACE(SVGFEComponentTransferElement);
22+
Base::initialize(realm);
23+
}
24+
25+
void SVGFEComponentTransferElement::visit_edges(Visitor& visitor)
26+
{
27+
Base::visit_edges(visitor);
28+
SVGFilterPrimitiveStandardAttributes::visit_edges(visitor);
29+
visitor.visit(m_in1);
30+
}
31+
32+
GC::Ref<SVGAnimatedString> SVGFEComponentTransferElement::in1()
33+
{
34+
if (!m_in1)
35+
m_in1 = SVGAnimatedString::create(realm(), *this, DOM::QualifiedName { AttributeNames::in, {}, {} });
36+
return *m_in1;
37+
}
38+
39+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/*
2+
* Copyright (c) 2025, Jelle Raaijmakers <jelle@ladybird.org>
3+
*
4+
* SPDX-License-Identifier: BSD-2-Clause
5+
*/
6+
7+
#pragma once
8+
9+
#include <LibWeb/SVG/SVGAnimatedString.h>
10+
#include <LibWeb/SVG/SVGElement.h>
11+
#include <LibWeb/SVG/SVGFilterPrimitiveStandardAttributes.h>
12+
13+
namespace Web::SVG {
14+
15+
// https://www.w3.org/TR/filter-effects-1/#InterfaceSVGFEComponentTransferElement
16+
class SVGFEComponentTransferElement final
17+
: public SVGElement
18+
, public SVGFilterPrimitiveStandardAttributes<SVGFEComponentTransferElement> {
19+
WEB_PLATFORM_OBJECT(SVGFEComponentTransferElement, SVGElement);
20+
GC_DECLARE_ALLOCATOR(SVGFEComponentTransferElement);
21+
22+
public:
23+
virtual ~SVGFEComponentTransferElement() override = default;
24+
25+
GC::Ref<SVGAnimatedString> in1();
26+
27+
private:
28+
SVGFEComponentTransferElement(DOM::Document&, DOM::QualifiedName);
29+
30+
virtual void initialize(JS::Realm&) override;
31+
virtual void visit_edges(Cell::Visitor&) override;
32+
33+
GC::Ptr<SVGAnimatedString> m_in1;
34+
};
35+
36+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#import <SVG/SVGElement.idl>
2+
#import <SVG/SVGFilterPrimitiveStandardAttributes.idl>
3+
4+
// https://www.w3.org/TR/filter-effects-1/#InterfaceSVGFEComponentTransferElement
5+
[Exposed=Window]
6+
interface SVGFEComponentTransferElement : SVGElement {
7+
readonly attribute SVGAnimatedString in1;
8+
};
9+
10+
SVGFEComponentTransferElement includes SVGFilterPrimitiveStandardAttributes;

Libraries/LibWeb/SVG/SVGFilterElement.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include <LibWeb/Painting/PaintableBox.h>
1616
#include <LibWeb/SVG/SVGFEBlendElement.h>
1717
#include <LibWeb/SVG/SVGFEColorMatrixElement.h>
18+
#include <LibWeb/SVG/SVGFEComponentTransferElement.h>
1819
#include <LibWeb/SVG/SVGFECompositeElement.h>
1920
#include <LibWeb/SVG/SVGFEFloodElement.h>
2021
#include <LibWeb/SVG/SVGFEGaussianBlurElement.h>
@@ -99,6 +100,8 @@ Optional<Gfx::Filter> SVGFilterElement::gfx_filter(Layout::NodeWithStyle const&
99100

100101
root_filter = Gfx::Filter::blend(background, foreground, blend_mode);
101102
update_result_map(*blend_primitive);
103+
} else if (auto* component_transfer = as_if<SVGFEComponentTransferElement>(node)) {
104+
dbgln("FIXME: Implement support for SVGFEComponentTransferElement");
102105
} else if (auto* composite_primitive = as_if<SVGFECompositeElement>(node)) {
103106
auto foreground = resolve_input_filter(composite_primitive->in1()->base_val());
104107
auto background = resolve_input_filter(composite_primitive->in2()->base_val());

Libraries/LibWeb/SVG/SVGFilterPrimitiveStandardAttributes.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include <LibWeb/CSS/PropertyID.h>
1010
#include <LibWeb/SVG/SVGFEBlendElement.h>
1111
#include <LibWeb/SVG/SVGFEColorMatrixElement.h>
12+
#include <LibWeb/SVG/SVGFEComponentTransferElement.h>
1213
#include <LibWeb/SVG/SVGFECompositeElement.h>
1314
#include <LibWeb/SVG/SVGFEFloodElement.h>
1415
#include <LibWeb/SVG/SVGFEGaussianBlurElement.h>
@@ -53,6 +54,7 @@ GC::Ref<SVGAnimatedString> SVGFilterPrimitiveStandardAttributes<IncludingClass>:
5354

5455
template class SVGFilterPrimitiveStandardAttributes<SVGFEBlendElement>;
5556
template class SVGFilterPrimitiveStandardAttributes<SVGFEColorMatrixElement>;
57+
template class SVGFilterPrimitiveStandardAttributes<SVGFEComponentTransferElement>;
5658
template class SVGFilterPrimitiveStandardAttributes<SVGFECompositeElement>;
5759
template class SVGFilterPrimitiveStandardAttributes<SVGFEFloodElement>;
5860
template class SVGFilterPrimitiveStandardAttributes<SVGFEGaussianBlurElement>;

Libraries/LibWeb/SVG/TagNames.h

Lines changed: 40 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -10,45 +10,46 @@
1010

1111
namespace Web::SVG::TagNames {
1212

13-
#define ENUMERATE_SVG_TAGS \
14-
__ENUMERATE_SVG_TAG(a) \
15-
__ENUMERATE_SVG_TAG(circle) \
16-
__ENUMERATE_SVG_TAG(clipPath) \
17-
__ENUMERATE_SVG_TAG(defs) \
18-
__ENUMERATE_SVG_TAG(desc) \
19-
__ENUMERATE_SVG_TAG(ellipse) \
20-
__ENUMERATE_SVG_TAG(feBlend) \
21-
__ENUMERATE_SVG_TAG(feColorMatrix) \
22-
__ENUMERATE_SVG_TAG(feComposite) \
23-
__ENUMERATE_SVG_TAG(feFlood) \
24-
__ENUMERATE_SVG_TAG(feGaussianBlur) \
25-
__ENUMERATE_SVG_TAG(feImage) \
26-
__ENUMERATE_SVG_TAG(feMerge) \
27-
__ENUMERATE_SVG_TAG(feMergeNode) \
28-
__ENUMERATE_SVG_TAG(feOffset) \
29-
__ENUMERATE_SVG_TAG(filter) \
30-
__ENUMERATE_SVG_TAG(foreignObject) \
31-
__ENUMERATE_SVG_TAG(g) \
32-
__ENUMERATE_SVG_TAG(image) \
33-
__ENUMERATE_SVG_TAG(line) \
34-
__ENUMERATE_SVG_TAG(linearGradient) \
35-
__ENUMERATE_SVG_TAG(mask) \
36-
__ENUMERATE_SVG_TAG(metadata) \
37-
__ENUMERATE_SVG_TAG(path) \
38-
__ENUMERATE_SVG_TAG(polygon) \
39-
__ENUMERATE_SVG_TAG(polyline) \
40-
__ENUMERATE_SVG_TAG(radialGradient) \
41-
__ENUMERATE_SVG_TAG(rect) \
42-
__ENUMERATE_SVG_TAG(script) \
43-
__ENUMERATE_SVG_TAG(stop) \
44-
__ENUMERATE_SVG_TAG(style) \
45-
__ENUMERATE_SVG_TAG(svg) \
46-
__ENUMERATE_SVG_TAG(symbol) \
47-
__ENUMERATE_SVG_TAG(text) \
48-
__ENUMERATE_SVG_TAG(textPath) \
49-
__ENUMERATE_SVG_TAG(title) \
50-
__ENUMERATE_SVG_TAG(tspan) \
51-
__ENUMERATE_SVG_TAG(use) \
13+
#define ENUMERATE_SVG_TAGS \
14+
__ENUMERATE_SVG_TAG(a) \
15+
__ENUMERATE_SVG_TAG(circle) \
16+
__ENUMERATE_SVG_TAG(clipPath) \
17+
__ENUMERATE_SVG_TAG(defs) \
18+
__ENUMERATE_SVG_TAG(desc) \
19+
__ENUMERATE_SVG_TAG(ellipse) \
20+
__ENUMERATE_SVG_TAG(feBlend) \
21+
__ENUMERATE_SVG_TAG(feColorMatrix) \
22+
__ENUMERATE_SVG_TAG(feComponentTransfer) \
23+
__ENUMERATE_SVG_TAG(feComposite) \
24+
__ENUMERATE_SVG_TAG(feFlood) \
25+
__ENUMERATE_SVG_TAG(feGaussianBlur) \
26+
__ENUMERATE_SVG_TAG(feImage) \
27+
__ENUMERATE_SVG_TAG(feMerge) \
28+
__ENUMERATE_SVG_TAG(feMergeNode) \
29+
__ENUMERATE_SVG_TAG(feOffset) \
30+
__ENUMERATE_SVG_TAG(filter) \
31+
__ENUMERATE_SVG_TAG(foreignObject) \
32+
__ENUMERATE_SVG_TAG(g) \
33+
__ENUMERATE_SVG_TAG(image) \
34+
__ENUMERATE_SVG_TAG(line) \
35+
__ENUMERATE_SVG_TAG(linearGradient) \
36+
__ENUMERATE_SVG_TAG(mask) \
37+
__ENUMERATE_SVG_TAG(metadata) \
38+
__ENUMERATE_SVG_TAG(path) \
39+
__ENUMERATE_SVG_TAG(polygon) \
40+
__ENUMERATE_SVG_TAG(polyline) \
41+
__ENUMERATE_SVG_TAG(radialGradient) \
42+
__ENUMERATE_SVG_TAG(rect) \
43+
__ENUMERATE_SVG_TAG(script) \
44+
__ENUMERATE_SVG_TAG(stop) \
45+
__ENUMERATE_SVG_TAG(style) \
46+
__ENUMERATE_SVG_TAG(svg) \
47+
__ENUMERATE_SVG_TAG(symbol) \
48+
__ENUMERATE_SVG_TAG(text) \
49+
__ENUMERATE_SVG_TAG(textPath) \
50+
__ENUMERATE_SVG_TAG(title) \
51+
__ENUMERATE_SVG_TAG(tspan) \
52+
__ENUMERATE_SVG_TAG(use) \
5253
__ENUMERATE_SVG_TAG(view)
5354

5455
#define __ENUMERATE_SVG_TAG(name) extern FlyString name;

Libraries/LibWeb/idl_files.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,7 @@ libweb_js_bindings(SVG/SVGCircleElement)
390390
libweb_js_bindings(SVG/SVGEllipseElement)
391391
libweb_js_bindings(SVG/SVGFEBlendElement)
392392
libweb_js_bindings(SVG/SVGFEColorMatrixElement)
393+
libweb_js_bindings(SVG/SVGFEComponentTransferElement)
393394
libweb_js_bindings(SVG/SVGFECompositeElement)
394395
libweb_js_bindings(SVG/SVGFEFloodElement)
395396
libweb_js_bindings(SVG/SVGFEGaussianBlurElement)

0 commit comments

Comments
 (0)