LibWeb: Add SVGFEComponentTransferElement

This commit is contained in:
Jelle Raaijmakers 2025-11-05 10:32:56 +01:00 committed by Jelle Raaijmakers
parent c0630c700f
commit 03a8de566b
Notes: github-actions[bot] 2025-11-09 00:24:05 +00:00
11 changed files with 139 additions and 41 deletions

View file

@ -0,0 +1,39 @@
/*
* Copyright (c) 2025, Jelle Raaijmakers <jelle@ladybird.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <LibWeb/Bindings/SVGFEComponentTransferElementPrototype.h>
#include <LibWeb/SVG/SVGFEComponentTransferElement.h>
namespace Web::SVG {
GC_DEFINE_ALLOCATOR(SVGFEComponentTransferElement);
SVGFEComponentTransferElement::SVGFEComponentTransferElement(DOM::Document& document, DOM::QualifiedName qualified_name)
: SVGElement(document, move(qualified_name))
{
}
void SVGFEComponentTransferElement::initialize(JS::Realm& realm)
{
WEB_SET_PROTOTYPE_FOR_INTERFACE(SVGFEComponentTransferElement);
Base::initialize(realm);
}
void SVGFEComponentTransferElement::visit_edges(Visitor& visitor)
{
Base::visit_edges(visitor);
SVGFilterPrimitiveStandardAttributes::visit_edges(visitor);
visitor.visit(m_in1);
}
GC::Ref<SVGAnimatedString> SVGFEComponentTransferElement::in1()
{
if (!m_in1)
m_in1 = SVGAnimatedString::create(realm(), *this, DOM::QualifiedName { AttributeNames::in, {}, {} });
return *m_in1;
}
}

View file

@ -0,0 +1,36 @@
/*
* Copyright (c) 2025, Jelle Raaijmakers <jelle@ladybird.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <LibWeb/SVG/SVGAnimatedString.h>
#include <LibWeb/SVG/SVGElement.h>
#include <LibWeb/SVG/SVGFilterPrimitiveStandardAttributes.h>
namespace Web::SVG {
// https://www.w3.org/TR/filter-effects-1/#InterfaceSVGFEComponentTransferElement
class SVGFEComponentTransferElement final
: public SVGElement
, public SVGFilterPrimitiveStandardAttributes<SVGFEComponentTransferElement> {
WEB_PLATFORM_OBJECT(SVGFEComponentTransferElement, SVGElement);
GC_DECLARE_ALLOCATOR(SVGFEComponentTransferElement);
public:
virtual ~SVGFEComponentTransferElement() override = default;
GC::Ref<SVGAnimatedString> in1();
private:
SVGFEComponentTransferElement(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,10 @@
#import <SVG/SVGElement.idl>
#import <SVG/SVGFilterPrimitiveStandardAttributes.idl>
// https://www.w3.org/TR/filter-effects-1/#InterfaceSVGFEComponentTransferElement
[Exposed=Window]
interface SVGFEComponentTransferElement : SVGElement {
readonly attribute SVGAnimatedString in1;
};
SVGFEComponentTransferElement includes SVGFilterPrimitiveStandardAttributes;

View file

@ -15,6 +15,7 @@
#include <LibWeb/Painting/PaintableBox.h>
#include <LibWeb/SVG/SVGFEBlendElement.h>
#include <LibWeb/SVG/SVGFEColorMatrixElement.h>
#include <LibWeb/SVG/SVGFEComponentTransferElement.h>
#include <LibWeb/SVG/SVGFECompositeElement.h>
#include <LibWeb/SVG/SVGFEFloodElement.h>
#include <LibWeb/SVG/SVGFEGaussianBlurElement.h>
@ -99,6 +100,8 @@ Optional<Gfx::Filter> SVGFilterElement::gfx_filter(Layout::NodeWithStyle const&
root_filter = Gfx::Filter::blend(background, foreground, blend_mode);
update_result_map(*blend_primitive);
} else if (auto* component_transfer = as_if<SVGFEComponentTransferElement>(node)) {
dbgln("FIXME: Implement support for SVGFEComponentTransferElement");
} else if (auto* composite_primitive = as_if<SVGFECompositeElement>(node)) {
auto foreground = resolve_input_filter(composite_primitive->in1()->base_val());
auto background = resolve_input_filter(composite_primitive->in2()->base_val());

View file

@ -9,6 +9,7 @@
#include <LibWeb/CSS/PropertyID.h>
#include <LibWeb/SVG/SVGFEBlendElement.h>
#include <LibWeb/SVG/SVGFEColorMatrixElement.h>
#include <LibWeb/SVG/SVGFEComponentTransferElement.h>
#include <LibWeb/SVG/SVGFECompositeElement.h>
#include <LibWeb/SVG/SVGFEFloodElement.h>
#include <LibWeb/SVG/SVGFEGaussianBlurElement.h>
@ -53,6 +54,7 @@ GC::Ref<SVGAnimatedString> SVGFilterPrimitiveStandardAttributes<IncludingClass>:
template class SVGFilterPrimitiveStandardAttributes<SVGFEBlendElement>;
template class SVGFilterPrimitiveStandardAttributes<SVGFEColorMatrixElement>;
template class SVGFilterPrimitiveStandardAttributes<SVGFEComponentTransferElement>;
template class SVGFilterPrimitiveStandardAttributes<SVGFECompositeElement>;
template class SVGFilterPrimitiveStandardAttributes<SVGFEFloodElement>;
template class SVGFilterPrimitiveStandardAttributes<SVGFEGaussianBlurElement>;

View file

@ -10,45 +10,46 @@
namespace Web::SVG::TagNames {
#define ENUMERATE_SVG_TAGS \
__ENUMERATE_SVG_TAG(a) \
__ENUMERATE_SVG_TAG(circle) \
__ENUMERATE_SVG_TAG(clipPath) \
__ENUMERATE_SVG_TAG(defs) \
__ENUMERATE_SVG_TAG(desc) \
__ENUMERATE_SVG_TAG(ellipse) \
__ENUMERATE_SVG_TAG(feBlend) \
__ENUMERATE_SVG_TAG(feColorMatrix) \
__ENUMERATE_SVG_TAG(feComposite) \
__ENUMERATE_SVG_TAG(feFlood) \
__ENUMERATE_SVG_TAG(feGaussianBlur) \
__ENUMERATE_SVG_TAG(feImage) \
__ENUMERATE_SVG_TAG(feMerge) \
__ENUMERATE_SVG_TAG(feMergeNode) \
__ENUMERATE_SVG_TAG(feOffset) \
__ENUMERATE_SVG_TAG(filter) \
__ENUMERATE_SVG_TAG(foreignObject) \
__ENUMERATE_SVG_TAG(g) \
__ENUMERATE_SVG_TAG(image) \
__ENUMERATE_SVG_TAG(line) \
__ENUMERATE_SVG_TAG(linearGradient) \
__ENUMERATE_SVG_TAG(mask) \
__ENUMERATE_SVG_TAG(metadata) \
__ENUMERATE_SVG_TAG(path) \
__ENUMERATE_SVG_TAG(polygon) \
__ENUMERATE_SVG_TAG(polyline) \
__ENUMERATE_SVG_TAG(radialGradient) \
__ENUMERATE_SVG_TAG(rect) \
__ENUMERATE_SVG_TAG(script) \
__ENUMERATE_SVG_TAG(stop) \
__ENUMERATE_SVG_TAG(style) \
__ENUMERATE_SVG_TAG(svg) \
__ENUMERATE_SVG_TAG(symbol) \
__ENUMERATE_SVG_TAG(text) \
__ENUMERATE_SVG_TAG(textPath) \
__ENUMERATE_SVG_TAG(title) \
__ENUMERATE_SVG_TAG(tspan) \
__ENUMERATE_SVG_TAG(use) \
#define ENUMERATE_SVG_TAGS \
__ENUMERATE_SVG_TAG(a) \
__ENUMERATE_SVG_TAG(circle) \
__ENUMERATE_SVG_TAG(clipPath) \
__ENUMERATE_SVG_TAG(defs) \
__ENUMERATE_SVG_TAG(desc) \
__ENUMERATE_SVG_TAG(ellipse) \
__ENUMERATE_SVG_TAG(feBlend) \
__ENUMERATE_SVG_TAG(feColorMatrix) \
__ENUMERATE_SVG_TAG(feComponentTransfer) \
__ENUMERATE_SVG_TAG(feComposite) \
__ENUMERATE_SVG_TAG(feFlood) \
__ENUMERATE_SVG_TAG(feGaussianBlur) \
__ENUMERATE_SVG_TAG(feImage) \
__ENUMERATE_SVG_TAG(feMerge) \
__ENUMERATE_SVG_TAG(feMergeNode) \
__ENUMERATE_SVG_TAG(feOffset) \
__ENUMERATE_SVG_TAG(filter) \
__ENUMERATE_SVG_TAG(foreignObject) \
__ENUMERATE_SVG_TAG(g) \
__ENUMERATE_SVG_TAG(image) \
__ENUMERATE_SVG_TAG(line) \
__ENUMERATE_SVG_TAG(linearGradient) \
__ENUMERATE_SVG_TAG(mask) \
__ENUMERATE_SVG_TAG(metadata) \
__ENUMERATE_SVG_TAG(path) \
__ENUMERATE_SVG_TAG(polygon) \
__ENUMERATE_SVG_TAG(polyline) \
__ENUMERATE_SVG_TAG(radialGradient) \
__ENUMERATE_SVG_TAG(rect) \
__ENUMERATE_SVG_TAG(script) \
__ENUMERATE_SVG_TAG(stop) \
__ENUMERATE_SVG_TAG(style) \
__ENUMERATE_SVG_TAG(svg) \
__ENUMERATE_SVG_TAG(symbol) \
__ENUMERATE_SVG_TAG(text) \
__ENUMERATE_SVG_TAG(textPath) \
__ENUMERATE_SVG_TAG(title) \
__ENUMERATE_SVG_TAG(tspan) \
__ENUMERATE_SVG_TAG(use) \
__ENUMERATE_SVG_TAG(view)
#define __ENUMERATE_SVG_TAG(name) extern FlyString name;