mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-30 19:47:17 +02:00
Previously, the LibWeb bindings generator would output multiple per interface files like Prototype/Constructor/Namespace/GlobalMixin depending on the contents of that IDL file. This complicates the build system as it means that it does not know what files will be generated without knowledge of the contents of that IDL file. Instead, for each IDL file only generate a single Bindings/<IDLFile>.h and Bindings/<IDLFile>.cpp.
68 lines
2.2 KiB
C++
68 lines
2.2 KiB
C++
/*
|
|
* Copyright (c) 2025, Jelle Raaijmakers <jelle@ladybird.org>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#include <LibWeb/Bindings/Intrinsics.h>
|
|
#include <LibWeb/Bindings/SVGAnimatedEnumeration.h>
|
|
#include <LibWeb/SVG/SVGAnimatedEnumeration.h>
|
|
#include <LibWeb/WebIDL/ExceptionOr.h>
|
|
|
|
namespace Web::SVG {
|
|
|
|
GC_DEFINE_ALLOCATOR(SVGAnimatedEnumeration);
|
|
|
|
GC::Ref<SVGAnimatedEnumeration> SVGAnimatedEnumeration::create(JS::Realm& realm, u16 value)
|
|
{
|
|
return realm.create<SVGAnimatedEnumeration>(realm, value);
|
|
}
|
|
|
|
SVGAnimatedEnumeration::SVGAnimatedEnumeration(JS::Realm& realm, u16 value)
|
|
: PlatformObject(realm)
|
|
, m_value(value)
|
|
{
|
|
}
|
|
|
|
SVGAnimatedEnumeration::~SVGAnimatedEnumeration() = default;
|
|
|
|
// https://svgwg.org/svg2-draft/types.html#__svg__SVGAnimatedEnumeration__baseVal
|
|
WebIDL::ExceptionOr<void> SVGAnimatedEnumeration::set_base_val(u16 base_val)
|
|
{
|
|
// 1. Let value be the value being assigned to baseVal.
|
|
auto value = base_val;
|
|
|
|
// FIXME: 2. If value is 0 or is not the numeric type value for any value of the reflected attribute, then throw a
|
|
// TypeError.
|
|
if (value == 0)
|
|
return WebIDL::SimpleException { WebIDL::SimpleExceptionType::TypeError, "invalid value for baseVal"sv };
|
|
|
|
// FIXME: 3. Otherwise, if the reflecting IDL attribute is orientType and value is SVG_MARKER_ORIENT_ANGLE, then set the
|
|
// reflected attribute to the string "0".
|
|
|
|
// FIXME: 4. Otherwise, value is the numeric type value for a specific, single keyword value for the reflected attribute.
|
|
// Set the reflected attribute to that value.
|
|
m_value = value;
|
|
|
|
return {};
|
|
}
|
|
|
|
void SVGAnimatedEnumeration::initialize(JS::Realm& realm)
|
|
{
|
|
WEB_SET_PROTOTYPE_FOR_INTERFACE(SVGAnimatedEnumeration);
|
|
Base::initialize(realm);
|
|
}
|
|
|
|
// https://svgwg.org/svg2-draft/types.html#__svg__SVGAnimatedEnumeration__baseVal
|
|
u16 SVGAnimatedEnumeration::base_or_anim_value() const
|
|
{
|
|
// FIXME: 1. Let value be the value of the reflected attribute (using the attribute's initial value if it is not present or
|
|
// invalid).
|
|
|
|
// FIXME: 2. Return the numeric type value for value, according to the reflecting IDL attribute's definition.
|
|
|
|
return m_value;
|
|
}
|
|
|
|
}
|