1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 21:57:43 +00:00

LibWeb: Parse the transform attribute when set on SVGGraphicsElements

This uses the new attribute parser functionality, and then resolves the
transform list into a single Gfx::AffineTransform.

This also adds a .get_transform() function which resolves the final
transform, by applying all parent transforms.
This commit is contained in:
MacDue 2023-04-10 12:25:40 +01:00 committed by Andreas Kling
parent 6482c306f1
commit 570d71f869
2 changed files with 58 additions and 3 deletions

View file

@ -9,6 +9,7 @@
#include <LibGfx/Path.h>
#include <LibWeb/DOM/Node.h>
#include <LibWeb/SVG/AttributeParser.h>
#include <LibWeb/SVG/SVGElement.h>
#include <LibWeb/SVG/TagNames.h>
@ -27,12 +28,17 @@ public:
Optional<Gfx::Color> stroke_color() const;
Optional<float> stroke_width() const;
Gfx::AffineTransform get_transform() const;
protected:
SVGGraphicsElement(DOM::Document&, DOM::QualifiedName);
virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override;
Optional<float> m_fill_opacity = {};
Gfx::AffineTransform m_transform = {};
};
Gfx::AffineTransform transform_from_transform_list(ReadonlySpan<Transform> tranform_list);
}