diff --git a/Userland/Libraries/LibWeb/CMakeLists.txt b/Userland/Libraries/LibWeb/CMakeLists.txt index aabfab54be..c036e24801 100644 --- a/Userland/Libraries/LibWeb/CMakeLists.txt +++ b/Userland/Libraries/LibWeb/CMakeLists.txt @@ -310,6 +310,7 @@ set(SOURCES ResizeObserver/ResizeObserver.cpp SVG/AttributeNames.cpp SVG/AttributeParser.cpp + SVG/SVGAnimatedLength.cpp SVG/SVGElement.cpp SVG/SVGGElement.cpp SVG/SVGGeometryElement.cpp @@ -571,6 +572,7 @@ libweb_js_wrapper(IntersectionObserver/IntersectionObserver) libweb_js_wrapper(NavigationTiming/PerformanceTiming) libweb_js_wrapper(RequestIdleCallback/IdleDeadline) libweb_js_wrapper(ResizeObserver/ResizeObserver) +libweb_js_wrapper(SVG/SVGAnimatedLength) libweb_js_wrapper(SVG/SVGElement) libweb_js_wrapper(SVG/SVGGeometryElement) libweb_js_wrapper(SVG/SVGGraphicsElement) diff --git a/Userland/Libraries/LibWeb/Forward.h b/Userland/Libraries/LibWeb/Forward.h index 0749d21b6c..981936578e 100644 --- a/Userland/Libraries/LibWeb/Forward.h +++ b/Userland/Libraries/LibWeb/Forward.h @@ -286,6 +286,7 @@ class ResizeObserver; } namespace Web::SVG { +class SVGAnimatedLength; class SVGCircleElement; class SVGElement; class SVGEllipseElement; @@ -510,6 +511,7 @@ class StyleSheetListWrapper; class StyleSheetWrapper; class SubmitEventWrapper; class SubtleCryptoWrapper; +class SVGAnimatedLengthWrapper; class SVGCircleElementWrapper; class SVGElementWrapper; class SVGEllipseElementWrapper; diff --git a/Userland/Libraries/LibWeb/SVG/SVGAnimatedLength.cpp b/Userland/Libraries/LibWeb/SVG/SVGAnimatedLength.cpp new file mode 100644 index 0000000000..cca546d9d3 --- /dev/null +++ b/Userland/Libraries/LibWeb/SVG/SVGAnimatedLength.cpp @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2022, Tim Flynn + * + * SPDX-License-Identifier: BSD-2-Clause + */ + +#include + +namespace Web::SVG { + +NonnullRefPtr SVGAnimatedLength::create(NonnullRefPtr base_val, NonnullRefPtr anim_val) +{ + return adopt_ref(*new SVGAnimatedLength(move(base_val), move(anim_val))); +} + +SVGAnimatedLength::SVGAnimatedLength(NonnullRefPtr base_val, NonnullRefPtr anim_val) + : m_base_val(move(base_val)) + , m_anim_val(move(anim_val)) +{ + // The object referenced by animVal will always be distinct from the one referenced by baseVal, even when the attribute is not animated. + VERIFY(m_base_val.ptr() != m_anim_val.ptr()); +} + +} diff --git a/Userland/Libraries/LibWeb/SVG/SVGAnimatedLength.h b/Userland/Libraries/LibWeb/SVG/SVGAnimatedLength.h new file mode 100644 index 0000000000..72c338cfed --- /dev/null +++ b/Userland/Libraries/LibWeb/SVG/SVGAnimatedLength.h @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2022, Tim Flynn + * + * SPDX-License-Identifier: BSD-2-Clause + */ + +#pragma once + +#include +#include +#include +#include + +namespace Web::SVG { + +// https://www.w3.org/TR/SVG11/types.html#InterfaceSVGAnimatedLength +class SVGAnimatedLength + : public RefCounted + , public Bindings::Wrappable + , public Weakable { +public: + using WrapperType = Bindings::SVGAnimatedLengthWrapper; + + static NonnullRefPtr create(NonnullRefPtr base_val, NonnullRefPtr anim_val); + virtual ~SVGAnimatedLength() = default; + + NonnullRefPtr const& base_val() const { return m_base_val; } + NonnullRefPtr const& anim_val() const { return m_anim_val; } + +private: + SVGAnimatedLength(NonnullRefPtr base_val, NonnullRefPtr anim_val); + + NonnullRefPtr m_base_val; + NonnullRefPtr m_anim_val; +}; + +} diff --git a/Userland/Libraries/LibWeb/SVG/SVGAnimatedLength.idl b/Userland/Libraries/LibWeb/SVG/SVGAnimatedLength.idl new file mode 100644 index 0000000000..3f20ce712f --- /dev/null +++ b/Userland/Libraries/LibWeb/SVG/SVGAnimatedLength.idl @@ -0,0 +1,6 @@ +#import + +interface SVGAnimatedLength { + readonly attribute SVGLength baseVal; + readonly attribute SVGLength animVal; +};