mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-31 13:19:05 +00:00
LibWeb: Add SVGAnimatedEnumeration
This commit is contained in:
parent
1aa50ac34a
commit
aeef179668
Notes:
github-actions[bot]
2025-02-22 09:15:33 +00:00
Author: https://github.com/gmta
Commit: aeef179668
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3657
8 changed files with 115 additions and 0 deletions
67
Libraries/LibWeb/SVG/SVGAnimatedEnumeration.cpp
Normal file
67
Libraries/LibWeb/SVG/SVGAnimatedEnumeration.cpp
Normal file
|
@ -0,0 +1,67 @@
|
|||
/*
|
||||
* Copyright (c) 2025, Jelle Raaijmakers <jelle@ladybird.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <LibWeb/Bindings/Intrinsics.h>
|
||||
#include <LibWeb/Bindings/SVGAnimatedEnumerationPrototype.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)
|
||||
{
|
||||
Base::initialize(realm);
|
||||
WEB_SET_PROTOTYPE_FOR_INTERFACE(SVGAnimatedEnumeration);
|
||||
}
|
||||
|
||||
// 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;
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue