mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-28 19:59:17 +00:00
LibWeb/SVG: Add FEBlendElement
This commit is contained in:
parent
d3684a36b0
commit
f8b12614df
Notes:
github-actions[bot]
2025-07-09 17:08:39 +00:00
Author: https://github.com/ananas-dev
Commit: f8b12614df
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/5028
Reviewed-by: https://github.com/gmta ✅
10 changed files with 139 additions and 0 deletions
|
@ -823,6 +823,7 @@ set(SOURCES
|
|||
SVG/SVGDescElement.cpp
|
||||
SVG/SVGElement.cpp
|
||||
SVG/SVGEllipseElement.cpp
|
||||
SVG/SVGFEBlendElement.cpp
|
||||
SVG/SVGFEFloodElement.cpp
|
||||
SVG/SVGFilterElement.cpp
|
||||
SVG/SVGForeignObjectElement.cpp
|
||||
|
|
|
@ -91,6 +91,7 @@
|
|||
#include <LibWeb/SVG/SVGDefsElement.h>
|
||||
#include <LibWeb/SVG/SVGDescElement.h>
|
||||
#include <LibWeb/SVG/SVGEllipseElement.h>
|
||||
#include <LibWeb/SVG/SVGFEBlendElement.h>
|
||||
#include <LibWeb/SVG/SVGFEFloodElement.h>
|
||||
#include <LibWeb/SVG/SVGFilterElement.h>
|
||||
#include <LibWeb/SVG/SVGForeignObjectElement.h>
|
||||
|
@ -462,6 +463,8 @@ static GC::Ref<SVG::SVGElement> create_svg_element(JS::Realm& realm, Document& d
|
|||
return realm.create<SVG::SVGDescElement>(document, move(qualified_name));
|
||||
if (local_name == SVG::TagNames::ellipse)
|
||||
return realm.create<SVG::SVGEllipseElement>(document, move(qualified_name));
|
||||
if (local_name == SVG::TagNames::feBlend)
|
||||
return realm.create<SVG::SVGFEBlendElement>(document, move(qualified_name));
|
||||
if (local_name == SVG::TagNames::feFlood)
|
||||
return realm.create<SVG::SVGFEFloodElement>(document, move(qualified_name));
|
||||
if (local_name == SVG::TagNames::filter)
|
||||
|
|
|
@ -967,6 +967,7 @@ class SVGDefsElement;
|
|||
class SVGDescElement;
|
||||
class SVGElement;
|
||||
class SVGEllipseElement;
|
||||
class SVGFEBlendElement;
|
||||
class SVGFEFloodElement;
|
||||
class SVGFilterElement;
|
||||
class SVGForeignObjectElement;
|
||||
|
|
|
@ -49,6 +49,7 @@ namespace Web::SVG::AttributeNames {
|
|||
__ENUMERATE_SVG_ATTRIBUTE(markerWidth, "markerWidth") \
|
||||
__ENUMERATE_SVG_ATTRIBUTE(maskContentUnits, "maskContentUnits") \
|
||||
__ENUMERATE_SVG_ATTRIBUTE(maskUnits, "maskUnits") \
|
||||
__ENUMERATE_SVG_ATTRIBUTE(mode, "mode") \
|
||||
__ENUMERATE_SVG_ATTRIBUTE(numOctaves, "numOctaves") \
|
||||
__ENUMERATE_SVG_ATTRIBUTE(offset, "offset") \
|
||||
__ENUMERATE_SVG_ATTRIBUTE(opacity, "opacity") \
|
||||
|
|
58
Libraries/LibWeb/SVG/SVGFEBlendElement.cpp
Normal file
58
Libraries/LibWeb/SVG/SVGFEBlendElement.cpp
Normal file
|
@ -0,0 +1,58 @@
|
|||
/*
|
||||
* Copyright (c) 2025, Lucien Fiorini <lucienfiorini@gmail.com>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <LibWeb/Bindings/SVGFEBlendElementPrototype.h>
|
||||
#include <LibWeb/CSS/Parser/Parser.h>
|
||||
#include <LibWeb/Layout/Node.h>
|
||||
#include <LibWeb/SVG/SVGAnimatedEnumeration.h>
|
||||
#include <LibWeb/SVG/SVGFEBlendElement.h>
|
||||
|
||||
namespace Web::SVG {
|
||||
|
||||
GC_DEFINE_ALLOCATOR(SVGFEBlendElement);
|
||||
|
||||
SVGFEBlendElement::SVGFEBlendElement(DOM::Document& document, DOM::QualifiedName qualified_name)
|
||||
: SVGElement(document, qualified_name)
|
||||
{
|
||||
}
|
||||
|
||||
void SVGFEBlendElement::initialize(JS::Realm& realm)
|
||||
{
|
||||
Base::initialize(realm);
|
||||
WEB_SET_PROTOTYPE_FOR_INTERFACE(SVGFEBlendElement);
|
||||
}
|
||||
|
||||
void SVGFEBlendElement::visit_edges(Cell::Visitor& visitor)
|
||||
{
|
||||
Base::visit_edges(visitor);
|
||||
SVGFilterPrimitiveStandardAttributes::visit_edges(visitor);
|
||||
visitor.visit(m_in1);
|
||||
visitor.visit(m_in2);
|
||||
}
|
||||
|
||||
GC::Ref<SVGAnimatedString> SVGFEBlendElement::in1()
|
||||
{
|
||||
if (!m_in1)
|
||||
m_in1 = SVGAnimatedString::create(realm(), *this, AttributeNames::in);
|
||||
|
||||
return *m_in1;
|
||||
}
|
||||
|
||||
GC::Ref<SVGAnimatedString> SVGFEBlendElement::in2()
|
||||
{
|
||||
if (!m_in2)
|
||||
m_in2 = SVGAnimatedString::create(realm(), *this, AttributeNames::in2);
|
||||
|
||||
return *m_in2;
|
||||
}
|
||||
|
||||
GC::Ref<SVGAnimatedEnumeration> SVGFEBlendElement::mode() const
|
||||
{
|
||||
// FIXME: Resolve the actual value from AttributeName::mode.
|
||||
return SVGAnimatedEnumeration::create(realm(), 1);
|
||||
}
|
||||
|
||||
}
|
39
Libraries/LibWeb/SVG/SVGFEBlendElement.h
Normal file
39
Libraries/LibWeb/SVG/SVGFEBlendElement.h
Normal file
|
@ -0,0 +1,39 @@
|
|||
/*
|
||||
* Copyright (c) 2025, Lucien Fiorini <lucienfiorini@gmail.com>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <LibWeb/SVG/AttributeParser.h>
|
||||
#include <LibWeb/SVG/SVGAnimatedLength.h>
|
||||
#include <LibWeb/SVG/SVGElement.h>
|
||||
#include <LibWeb/SVG/SVGFilterPrimitiveStandardAttributes.h>
|
||||
|
||||
namespace Web::SVG {
|
||||
|
||||
class SVGFEBlendElement final
|
||||
: public SVGElement
|
||||
, public SVGFilterPrimitiveStandardAttributes<SVGFEBlendElement> {
|
||||
WEB_PLATFORM_OBJECT(SVGFEBlendElement, SVGElement);
|
||||
GC_DECLARE_ALLOCATOR(SVGFEBlendElement);
|
||||
|
||||
public:
|
||||
virtual ~SVGFEBlendElement() override = default;
|
||||
|
||||
GC::Ref<SVGAnimatedString> in1();
|
||||
GC::Ref<SVGAnimatedString> in2();
|
||||
GC::Ref<SVGAnimatedEnumeration> mode() const;
|
||||
|
||||
private:
|
||||
SVGFEBlendElement(DOM::Document&, DOM::QualifiedName);
|
||||
|
||||
virtual void initialize(JS::Realm&) override;
|
||||
virtual void visit_edges(Cell::Visitor&) override;
|
||||
|
||||
GC::Ptr<SVGAnimatedString> m_in1;
|
||||
GC::Ptr<SVGAnimatedString> m_in2;
|
||||
};
|
||||
|
||||
}
|
33
Libraries/LibWeb/SVG/SVGFEBlendElement.idl
Normal file
33
Libraries/LibWeb/SVG/SVGFEBlendElement.idl
Normal file
|
@ -0,0 +1,33 @@
|
|||
#import <SVG/SVGAnimatedEnumeration.idl>
|
||||
#import <SVG/SVGAnimatedString.idl>
|
||||
#import <SVG/SVGFilterPrimitiveStandardAttributes.idl>
|
||||
|
||||
// https://www.w3.org/TR/filter-effects-1/#InterfaceSVGFEBlendElement
|
||||
[Exposed=Window]
|
||||
interface SVGFEBlendElement : SVGElement {
|
||||
|
||||
// Blend Mode Types
|
||||
const unsigned short SVG_FEBLEND_MODE_UNKNOWN = 0;
|
||||
const unsigned short SVG_FEBLEND_MODE_NORMAL = 1;
|
||||
const unsigned short SVG_FEBLEND_MODE_MULTIPLY = 2;
|
||||
const unsigned short SVG_FEBLEND_MODE_SCREEN = 3;
|
||||
const unsigned short SVG_FEBLEND_MODE_DARKEN = 4;
|
||||
const unsigned short SVG_FEBLEND_MODE_LIGHTEN = 5;
|
||||
const unsigned short SVG_FEBLEND_MODE_OVERLAY = 6;
|
||||
const unsigned short SVG_FEBLEND_MODE_COLOR_DODGE = 7;
|
||||
const unsigned short SVG_FEBLEND_MODE_COLOR_BURN = 8;
|
||||
const unsigned short SVG_FEBLEND_MODE_HARD_LIGHT = 9;
|
||||
const unsigned short SVG_FEBLEND_MODE_SOFT_LIGHT = 10;
|
||||
const unsigned short SVG_FEBLEND_MODE_DIFFERENCE = 11;
|
||||
const unsigned short SVG_FEBLEND_MODE_EXCLUSION = 12;
|
||||
const unsigned short SVG_FEBLEND_MODE_HUE = 13;
|
||||
const unsigned short SVG_FEBLEND_MODE_SATURATION = 14;
|
||||
const unsigned short SVG_FEBLEND_MODE_COLOR = 15;
|
||||
const unsigned short SVG_FEBLEND_MODE_LUMINOSITY = 16;
|
||||
|
||||
readonly attribute SVGAnimatedString in1;
|
||||
readonly attribute SVGAnimatedString in2;
|
||||
readonly attribute SVGAnimatedEnumeration mode;
|
||||
};
|
||||
|
||||
SVGFEBlendElement includes SVGFilterPrimitiveStandardAttributes;
|
|
@ -17,6 +17,7 @@ namespace Web::SVG::TagNames {
|
|||
__ENUMERATE_SVG_TAG(defs) \
|
||||
__ENUMERATE_SVG_TAG(desc) \
|
||||
__ENUMERATE_SVG_TAG(ellipse) \
|
||||
__ENUMERATE_SVG_TAG(feBlend) \
|
||||
__ENUMERATE_SVG_TAG(feFlood) \
|
||||
__ENUMERATE_SVG_TAG(filter) \
|
||||
__ENUMERATE_SVG_TAG(foreignObject) \
|
||||
|
|
|
@ -340,6 +340,7 @@ libweb_js_bindings(SVG/SVGGraphicsElement)
|
|||
libweb_js_bindings(SVG/SVGImageElement)
|
||||
libweb_js_bindings(SVG/SVGCircleElement)
|
||||
libweb_js_bindings(SVG/SVGEllipseElement)
|
||||
libweb_js_bindings(SVG/SVGFEBlendElement)
|
||||
libweb_js_bindings(SVG/SVGFEFloodElement)
|
||||
libweb_js_bindings(SVG/SVGFilterElement)
|
||||
libweb_js_bindings(SVG/SVGForeignObjectElement)
|
||||
|
|
|
@ -338,6 +338,7 @@ SVGDefsElement
|
|||
SVGDescElement
|
||||
SVGElement
|
||||
SVGEllipseElement
|
||||
SVGFEBlendElement
|
||||
SVGFEFloodElement
|
||||
SVGFilterElement
|
||||
SVGForeignObjectElement
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue