mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-29 04:09:13 +00:00
LibWeb/SVG: Move path data into Path.{h,cpp}
More things need this than just the `<path>` element, so let's avoid having to include `SVGPathElement.h` in places that don't need it. Minor changes at the same time: - Wrap it in a Path class - Specify underlying type for PathInstructionType - Make a couple of free functions into methods - Give PathInstruction an operator== No functionality changes.
This commit is contained in:
parent
07b5b7ffb6
commit
6b53454b68
Notes:
github-actions[bot]
2025-07-17 18:00:44 +00:00
Author: https://github.com/AtkinsSJ
Commit: 6b53454b68
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/5491
Reviewed-by: https://github.com/kalenikaliaksandr ✅
9 changed files with 322 additions and 272 deletions
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* Copyright (c) 2020, Matthew Olsson <mattco@serenityos.org>
|
||||
* Copyright (c) 2022, Sam Atkins <atkinssj@serenityos.org>
|
||||
* Copyright (c) 2022-2025, Sam Atkins <sam@ladybird.org>
|
||||
* Copyright (c) 2024, Tim Ledbetter <timledbetter@gmail.com>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
|
@ -12,29 +12,10 @@
|
|||
#include <AK/Variant.h>
|
||||
#include <AK/Vector.h>
|
||||
#include <LibGfx/Point.h>
|
||||
#include <LibWeb/SVG/Path.h>
|
||||
|
||||
namespace Web::SVG {
|
||||
|
||||
enum class PathInstructionType {
|
||||
Move,
|
||||
ClosePath,
|
||||
Line,
|
||||
HorizontalLine,
|
||||
VerticalLine,
|
||||
Curve,
|
||||
SmoothCurve,
|
||||
QuadraticBezierCurve,
|
||||
SmoothQuadraticBezierCurve,
|
||||
EllipticalArc,
|
||||
Invalid,
|
||||
};
|
||||
|
||||
struct PathInstruction {
|
||||
PathInstructionType type;
|
||||
bool absolute;
|
||||
Vector<float> data;
|
||||
};
|
||||
|
||||
struct Transform {
|
||||
struct Translate {
|
||||
float x;
|
||||
|
@ -154,7 +135,7 @@ public:
|
|||
static Optional<NumberPercentage> parse_number_percentage(StringView input);
|
||||
static Optional<float> parse_positive_length(StringView input);
|
||||
static Vector<Gfx::FloatPoint> parse_points(StringView input);
|
||||
static Vector<PathInstruction> parse_path_data(StringView input);
|
||||
static Path parse_path_data(StringView input);
|
||||
static Optional<Vector<Transform>> parse_transform(StringView input);
|
||||
static Optional<PreserveAspectRatio> parse_preserve_aspect_ratio(StringView input);
|
||||
static Optional<SVGUnits> parse_units(StringView input);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue