/* * Copyright (c) 2025, Tim Ledbetter * * SPDX-License-Identifier: BSD-2-Clause */ #include #include #include #include #include namespace Web::SVG { void SVGFitToViewBox::initialize(JS::Realm& realm) { m_view_box_for_bindings = realm.create(realm); } void SVGFitToViewBox::visit_edges(JS::Cell::Visitor& visitor) { visitor.visit(m_view_box_for_bindings); } void SVGFitToViewBox::attribute_changed(DOM::Element&, FlyString const& name, Optional const& value) { if (name.equals_ignoring_ascii_case(SVG::AttributeNames::viewBox)) { if (!value.has_value()) { m_view_box_for_bindings->set_nulled(true); } else { m_view_box = try_parse_view_box(value.value_or(String {})); m_view_box_for_bindings->set_nulled(!m_view_box.has_value()); if (m_view_box.has_value()) { m_view_box_for_bindings->set_base_val(Gfx::DoubleRect { m_view_box->min_x, m_view_box->min_y, m_view_box->width, m_view_box->height }); m_view_box_for_bindings->set_anim_val(Gfx::DoubleRect { m_view_box->min_x, m_view_box->min_y, m_view_box->width, m_view_box->height }); } } } else if (name.equals_ignoring_ascii_case(SVG::AttributeNames::preserveAspectRatio)) { m_preserve_aspect_ratio = AttributeParser::parse_preserve_aspect_ratio(value.value_or(String {})); } } }