Skip to content

Truly independent web browser

1.7 KB
Raw Blame
/*
 * Copyright (c) 2025, Lucien Fiorini <[email protected]>
 *
 * SPDX-License-Identifier: BSD-2-Clause
 */

#pragma once

#include <LibWeb/SVG/AttributeNames.h>
#include <LibWeb/SVG/SVGElement.h>

namespace Web::SVG {

template<typename IncludingClass>
class SVGFilterPrimitiveStandardAttributes {
public:
    virtual ~SVGFilterPrimitiveStandardAttributes() = default;

    // https://drafts.csswg.org/filter-effects-1#dom-svgfilterprimitivestandardattributes-x
    REFLECT_ANIMATED_LENGTH_ATTRIBUTE(x, Horizontal, SVGLengthValue::percentage(0));

    // https://drafts.csswg.org/filter-effects-1#dom-svgfilterprimitivestandardattributes-y
    REFLECT_ANIMATED_LENGTH_ATTRIBUTE(y, Vertical, SVGLengthValue::percentage(0));

    // https://drafts.csswg.org/filter-effects-1#dom-svgfilterprimitivestandardattributes-width
    REFLECT_ANIMATED_LENGTH_ATTRIBUTE(width, Horizontal, SVGLengthValue::percentage(100));

    // https://drafts.csswg.org/filter-effects-1#dom-svgfilterprimitivestandardattributes-height
    REFLECT_ANIMATED_LENGTH_ATTRIBUTE(height, Vertical, SVGLengthValue::percentage(100));

    GC::Ref<SVGAnimatedString> result();

protected:
    void visit_edges(JS::Cell::Visitor& visitor)
    {
        visitor.visit(m_result_animated_string);
    }

private:
    SVGElement* this_svg_element() { return static_cast<IncludingClass*>(this); }

    GC::Ref<SVGAnimatedLength> svg_animated_length_for_attribute(Utf16FlyString const& attribute_name, SVGLength::Directionality directionality, SVGLengthValue default_value)
    {
        return this_svg_element()->svg_animated_length_for_attribute(attribute_name, directionality, default_value);
    }

    GC::Ptr<SVGAnimatedString> m_result_animated_string;
};

}