mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-10 18:10:56 +09:00
LibWeb: Keep SVG elliptical arc shape when applying viewbox
When doing viewbox transforms, elliptical always had large arc and sweep flag set to false. Preserve these flags so they can be set correctly when applying viewbox transformations.
This commit is contained in:
parent
dd71754d10
commit
f0a1ab6f84
Notes:
sideshowbarker
2024-07-17 17:32:39 +09:00
Author: https://github.com/danners
Commit: f0a1ab6f84
Pull-request: https://github.com/SerenityOS/serenity/pull/13004
Reviewed-by: https://github.com/TobyAsE ✅
3 changed files with 15 additions and 5 deletions
|
@ -110,7 +110,9 @@ void Path::elliptical_arc_to(const FloatPoint& point, const FloatPoint& radii, d
|
|||
{ rx, ry },
|
||||
x_axis_rotation,
|
||||
theta_1,
|
||||
theta_delta);
|
||||
theta_delta,
|
||||
large_arc,
|
||||
sweep);
|
||||
}
|
||||
|
||||
void Path::close()
|
||||
|
|
|
@ -107,13 +107,15 @@ private:
|
|||
|
||||
class EllipticalArcSegment final : public Segment {
|
||||
public:
|
||||
EllipticalArcSegment(const FloatPoint& point, const FloatPoint& center, const FloatPoint radii, float x_axis_rotation, float theta_1, float theta_delta)
|
||||
EllipticalArcSegment(const FloatPoint& point, const FloatPoint& center, const FloatPoint radii, float x_axis_rotation, float theta_1, float theta_delta, bool large_arc, bool sweep)
|
||||
: Segment(point)
|
||||
, m_center(center)
|
||||
, m_radii(radii)
|
||||
, m_x_axis_rotation(x_axis_rotation)
|
||||
, m_theta_1(theta_1)
|
||||
, m_theta_delta(theta_delta)
|
||||
, m_large_arc(large_arc)
|
||||
, m_sweep(sweep)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -124,6 +126,8 @@ public:
|
|||
float x_axis_rotation() const { return m_x_axis_rotation; }
|
||||
float theta_1() const { return m_theta_1; }
|
||||
float theta_delta() const { return m_theta_delta; }
|
||||
bool large_arc() const { return m_large_arc; }
|
||||
bool sweep() const { return m_sweep; }
|
||||
|
||||
private:
|
||||
virtual Type type() const override { return Segment::Type::EllipticalArcTo; }
|
||||
|
@ -133,6 +137,8 @@ private:
|
|||
float m_x_axis_rotation;
|
||||
float m_theta_1;
|
||||
float m_theta_delta;
|
||||
bool m_large_arc;
|
||||
bool m_sweep;
|
||||
};
|
||||
|
||||
class Path {
|
||||
|
@ -185,7 +191,7 @@ public:
|
|||
}
|
||||
|
||||
// Note: This does not do any sanity checks!
|
||||
void elliptical_arc_to(const FloatPoint& endpoint, const FloatPoint& center, const FloatPoint& radii, double x_axis_rotation, double theta, double theta_delta)
|
||||
void elliptical_arc_to(const FloatPoint& endpoint, const FloatPoint& center, const FloatPoint& radii, double x_axis_rotation, double theta, double theta_delta, bool large_arc, bool sweep)
|
||||
{
|
||||
append_segment<EllipticalArcSegment>(
|
||||
endpoint,
|
||||
|
@ -193,7 +199,9 @@ public:
|
|||
radii,
|
||||
x_axis_rotation,
|
||||
theta,
|
||||
theta_delta);
|
||||
theta_delta,
|
||||
large_arc,
|
||||
sweep);
|
||||
|
||||
invalidate_split_lines();
|
||||
}
|
||||
|
|
|
@ -85,7 +85,7 @@ void SVGGeometryPaintable::paint(PaintContext& context, PaintPhase phase) const
|
|||
}
|
||||
case Gfx::Segment::Type::EllipticalArcTo: {
|
||||
auto& elliptical_arc_segment = static_cast<Gfx::EllipticalArcSegment const&>(segment);
|
||||
new_path.elliptical_arc_to(transform_point(elliptical_arc_segment.point()), elliptical_arc_segment.radii().scaled(scaling, scaling), elliptical_arc_segment.x_axis_rotation(), false, false);
|
||||
new_path.elliptical_arc_to(transform_point(elliptical_arc_segment.point()), elliptical_arc_segment.radii().scaled(scaling, scaling), elliptical_arc_segment.x_axis_rotation(), elliptical_arc_segment.large_arc(), elliptical_arc_segment.sweep());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue