mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-12-08 06:09:58 +00:00
LibWeb: Implement SVGFEColorMatrixElement and feColorMatrix
This commit is contained in:
parent
b50b89b4a8
commit
5ee1031b89
Notes:
github-actions[bot]
2025-10-23 11:37:46 +00:00
Author: https://github.com/shlyakpavel
Commit: 5ee1031b89
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/6262
Reviewed-by: https://github.com/gmta ✅
Reviewed-by: https://github.com/konradekk
21 changed files with 367 additions and 0 deletions
69
Libraries/LibWeb/SVG/SVGFEColorMatrixElement.cpp
Normal file
69
Libraries/LibWeb/SVG/SVGFEColorMatrixElement.cpp
Normal file
|
|
@ -0,0 +1,69 @@
|
|||
/*
|
||||
* Copyright (c) 2025, Pavel Shliak <shlyakpavel@gmail.com>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <LibWeb/Bindings/SVGFEColorMatrixElementPrototype.h>
|
||||
#include <LibWeb/SVG/SVGAnimatedEnumeration.h>
|
||||
#include <LibWeb/SVG/SVGAnimatedString.h>
|
||||
#include <LibWeb/SVG/SVGFEColorMatrixElement.h>
|
||||
|
||||
namespace Web::SVG {
|
||||
|
||||
GC_DEFINE_ALLOCATOR(SVGFEColorMatrixElement);
|
||||
|
||||
SVGFEColorMatrixElement::SVGFEColorMatrixElement(DOM::Document& document, DOM::QualifiedName qualified_name)
|
||||
: SVGElement(document, qualified_name)
|
||||
{
|
||||
}
|
||||
|
||||
void SVGFEColorMatrixElement::initialize(JS::Realm& realm)
|
||||
{
|
||||
WEB_SET_PROTOTYPE_FOR_INTERFACE(SVGFEColorMatrixElement);
|
||||
Base::initialize(realm);
|
||||
}
|
||||
|
||||
void SVGFEColorMatrixElement::visit_edges(Cell::Visitor& visitor)
|
||||
{
|
||||
Base::visit_edges(visitor);
|
||||
SVGFilterPrimitiveStandardAttributes::visit_edges(visitor);
|
||||
visitor.visit(m_in1);
|
||||
visitor.visit(m_values);
|
||||
}
|
||||
|
||||
GC::Ref<SVGAnimatedString> SVGFEColorMatrixElement::in1()
|
||||
{
|
||||
if (!m_in1)
|
||||
m_in1 = SVGAnimatedString::create(realm(), *this, AttributeNames::in);
|
||||
return *m_in1;
|
||||
}
|
||||
|
||||
GC::Ref<SVGAnimatedEnumeration> SVGFEColorMatrixElement::type() const
|
||||
{
|
||||
// https://www.w3.org/TR/filter-effects-1/#InterfaceSVGFEColorMatrixElement
|
||||
// Map the 'type' attribute to the IDL enumeration values.
|
||||
// Defaults to MATRIX when omitted.
|
||||
auto type_attribute = attribute(AttributeNames::type).value_or(String {});
|
||||
|
||||
u16 enum_value = SVGFEColorMatrixElement::SVG_FECOLORMATRIX_TYPE_UNKNOWN;
|
||||
if (type_attribute.is_empty() || type_attribute.equals_ignoring_ascii_case("matrix"sv))
|
||||
enum_value = SVGFEColorMatrixElement::SVG_FECOLORMATRIX_TYPE_MATRIX;
|
||||
else if (type_attribute.equals_ignoring_ascii_case("saturate"sv))
|
||||
enum_value = SVGFEColorMatrixElement::SVG_FECOLORMATRIX_TYPE_SATURATE;
|
||||
else if (type_attribute.equals_ignoring_ascii_case("hueRotate"sv))
|
||||
enum_value = SVGFEColorMatrixElement::SVG_FECOLORMATRIX_TYPE_HUEROTATE;
|
||||
else if (type_attribute.equals_ignoring_ascii_case("luminanceToAlpha"sv))
|
||||
enum_value = SVGFEColorMatrixElement::SVG_FECOLORMATRIX_TYPE_LUMINANCETOALPHA;
|
||||
|
||||
return SVGAnimatedEnumeration::create(realm(), enum_value);
|
||||
}
|
||||
|
||||
GC::Ref<SVGAnimatedString> SVGFEColorMatrixElement::values()
|
||||
{
|
||||
if (!m_values)
|
||||
m_values = SVGAnimatedString::create(realm(), *this, AttributeNames::values);
|
||||
return *m_values;
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue