mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 16:47:36 +00:00
LibWeb: Add SVGSVGElement.viewBox attribute
This attribute has some compatbility issues... - The spec says it should be an SVGAnimatedRect which contains a DOMRect and a DOMReadOnlyRect. - Blink gives you an SVGAnimatedRect with 2x SVGRect - Gecko gives you an SVGAnimatedRect with 2x SVGRect? (nullable) I ended up with something similar to Gecko, an SVGAnimatedRect with 2x DOMRect? (nullable) With this fixed, we can now load https://polar.sh/ :^)
This commit is contained in:
parent
2fd034d1df
commit
b12541b286
12 changed files with 228 additions and 2 deletions
73
Userland/Libraries/LibWeb/SVG/SVGAnimatedRect.cpp
Normal file
73
Userland/Libraries/LibWeb/SVG/SVGAnimatedRect.cpp
Normal file
|
@ -0,0 +1,73 @@
|
|||
/*
|
||||
* Copyright (c) 2024, Andreas Kling <kling@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <LibWeb/Bindings/ExceptionOrUtils.h>
|
||||
#include <LibWeb/Bindings/Intrinsics.h>
|
||||
#include <LibWeb/Bindings/SVGAnimatedRectPrototype.h>
|
||||
#include <LibWeb/SVG/SVGAnimatedRect.h>
|
||||
|
||||
namespace Web::SVG {
|
||||
|
||||
JS_DEFINE_ALLOCATOR(SVGAnimatedRect);
|
||||
|
||||
SVGAnimatedRect::SVGAnimatedRect(JS::Realm& realm)
|
||||
: Bindings::PlatformObject(realm)
|
||||
{
|
||||
}
|
||||
|
||||
SVGAnimatedRect::~SVGAnimatedRect() = default;
|
||||
|
||||
void SVGAnimatedRect::initialize(JS::Realm& realm)
|
||||
{
|
||||
Base::initialize(realm);
|
||||
set_prototype(&Bindings::ensure_web_prototype<Bindings::SVGAnimatedRectPrototype>(realm, "SVGAnimatedRect"_fly_string));
|
||||
m_base_val = Geometry::DOMRect::create(realm, { 0, 0, 0, 0 });
|
||||
m_anim_val = Geometry::DOMRect::create(realm, { 0, 0, 0, 0 });
|
||||
}
|
||||
|
||||
void SVGAnimatedRect::visit_edges(Visitor& visitor)
|
||||
{
|
||||
Base::visit_edges(visitor);
|
||||
visitor.visit(m_base_val);
|
||||
visitor.visit(m_anim_val);
|
||||
}
|
||||
|
||||
JS::GCPtr<Geometry::DOMRect> SVGAnimatedRect::base_val() const
|
||||
{
|
||||
if (m_nulled)
|
||||
return nullptr;
|
||||
return m_base_val;
|
||||
}
|
||||
|
||||
JS::GCPtr<Geometry::DOMRect> SVGAnimatedRect::anim_val() const
|
||||
{
|
||||
if (m_nulled)
|
||||
return nullptr;
|
||||
return m_anim_val;
|
||||
}
|
||||
|
||||
void SVGAnimatedRect::set_nulled(bool nulled)
|
||||
{
|
||||
m_nulled = nulled;
|
||||
}
|
||||
|
||||
void SVGAnimatedRect::set_base_val(Gfx::DoubleRect const& rect)
|
||||
{
|
||||
m_base_val->set_x(rect.x());
|
||||
m_base_val->set_y(rect.y());
|
||||
m_base_val->set_width(rect.width());
|
||||
m_base_val->set_height(rect.height());
|
||||
}
|
||||
|
||||
void SVGAnimatedRect::set_anim_val(Gfx::DoubleRect const& rect)
|
||||
{
|
||||
m_anim_val->set_x(rect.x());
|
||||
m_anim_val->set_y(rect.y());
|
||||
m_anim_val->set_width(rect.width());
|
||||
m_anim_val->set_height(rect.height());
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue