LibWeb: Move common SVGViewport code into an SVGFitToViewBox class

Special handling for SVGClipPathElement and SVGMaskElement, which use a
a ViewBox and PreserveAspectRatio value internally, has been moved to
`SVGFormattingContext`.
This commit is contained in:
Tim Ledbetter 2025-08-27 22:17:33 +01:00 committed by Jelle Raaijmakers
commit ea41aba6c7
Notes: github-actions[bot] 2025-08-28 13:44:09 +00:00
16 changed files with 144 additions and 152 deletions

View file

@ -12,7 +12,6 @@
#include <LibWeb/SVG/AttributeNames.h>
#include <LibWeb/SVG/AttributeParser.h>
#include <LibWeb/SVG/SVGCircleElement.h>
#include <LibWeb/SVG/SVGViewport.h>
namespace Web::SVG {
@ -58,6 +57,13 @@ void SVGCircleElement::apply_presentational_hints(GC::Ref<CSS::CascadedPropertie
cascaded_properties->set_property_from_presentational_hint(CSS::PropertyID::R, r_value.release_nonnull());
}
static CSSPixels normalized_diagonal_length(CSSPixelSize viewport_size)
{
if (viewport_size.width() == viewport_size.height())
return viewport_size.width();
return sqrt((viewport_size.width() * viewport_size.width()) + (viewport_size.height() * viewport_size.height())) / CSSPixels::nearest_value_for(AK::Sqrt2<float>);
}
Gfx::Path SVGCircleElement::get_path(CSSPixelSize viewport_size)
{
auto node = layout_node();