@@ -245,7 +245,6 @@ static already_AddRefed<Path> BuildPathInternal(
245245
246246 for (const auto & cmd : aPath) {
247247 seg = &cmd;
248- bool isRelative = false ;
249248 switch (cmd.tag ) {
250249 case Command::Tag::Close:
251250 // set this early to allow drawing of square caps for "M{x},{y} Z":
@@ -272,13 +271,15 @@ static already_AddRefed<Path> BuildPathInternal(
272271 break ;
273272 }
274273 case Command::Tag::CubicCurve:
275- isRelative = cmd.cubic_curve .point .IsByCoordinate ();
274+ cp1 = cmd.cubic_curve .control1 .ToGfxPoint (aPercentageBasis);
275+ cp2 = cmd.cubic_curve .control2 .ToGfxPoint (aPercentageBasis);
276276 segEnd = cmd.cubic_curve .point .ToGfxPoint (aPercentageBasis);
277- segEnd = isRelative ? segEnd + segStart : segEnd;
278- cp1 = cmd.cubic_curve .control1 .ToGfxPoint (segStart, segEnd, isRelative,
279- aPercentageBasis);
280- cp2 = cmd.cubic_curve .control2 .ToGfxPoint (segStart, segEnd, isRelative,
281- aPercentageBasis);
277+
278+ if (cmd.cubic_curve .point .IsByCoordinate ()) {
279+ cp1 += segStart;
280+ cp2 += segStart;
281+ segEnd += segStart;
282+ }
282283
283284 if (segEnd != segStart || segEnd != cp1 || segEnd != cp2) {
284285 subpathHasLength = true ;
@@ -287,12 +288,13 @@ static already_AddRefed<Path> BuildPathInternal(
287288 break ;
288289
289290 case Command::Tag::QuadCurve:
290- isRelative = cmd.quad_curve .point . IsByCoordinate ( );
291+ cp1 = cmd.quad_curve .control1 . ToGfxPoint (aPercentageBasis );
291292 segEnd = cmd.quad_curve .point .ToGfxPoint (aPercentageBasis);
292- segEnd = isRelative ? segEnd + segStart
293- : segEnd; // set before setting tcp2!
294- cp1 = cmd.quad_curve .control1 .ToGfxPoint (segStart, segEnd, isRelative,
295- aPercentageBasis);
293+
294+ if (cmd.quad_curve .point .IsByCoordinate ()) {
295+ cp1 += segStart;
296+ segEnd += segStart; // set before setting tcp2!
297+ }
296298
297299 // Convert quadratic curve to cubic curve:
298300 tcp1 = segStart + (cp1 - segStart) * 2 / 3 ;
@@ -357,12 +359,14 @@ static already_AddRefed<Path> BuildPathInternal(
357359 break ;
358360 }
359361 case Command::Tag::SmoothCubic:
360- isRelative = cmd.smooth_cubic .point .IsByCoordinate ();
361- segEnd = cmd.smooth_cubic .point .ToGfxPoint (aPercentageBasis);
362- segEnd = isRelative ? segEnd + segStart : segEnd;
363362 cp1 = prevSeg && prevSeg->IsCubicType () ? segStart * 2 - cp2 : segStart;
364- cp2 = cmd.smooth_cubic .control2 .ToGfxPoint (segStart, segEnd, isRelative,
365- aPercentageBasis);
363+ cp2 = cmd.smooth_cubic .control2 .ToGfxPoint (aPercentageBasis);
364+ segEnd = cmd.smooth_cubic .point .ToGfxPoint (aPercentageBasis);
365+
366+ if (cmd.smooth_cubic .point .IsByCoordinate ()) {
367+ cp2 += segStart;
368+ segEnd += segStart;
369+ }
366370
367371 if (segEnd != segStart || segEnd != cp1 || segEnd != cp2) {
368372 subpathHasLength = true ;
@@ -542,7 +546,6 @@ void SVGPathData::GetMarkerPositioningData(Span<const StylePathCommand> aPath,
542546 Point& segStart = prevSegEnd;
543547 Point segEnd;
544548 float segStartAngle, segEndAngle;
545- bool isRelative = false ;
546549
547550 switch (cmd.tag ) // to find segStartAngle, segEnd and segEndAngle
548551 {
@@ -567,15 +570,15 @@ void SVGPathData::GetMarkerPositioningData(Span<const StylePathCommand> aPath,
567570 break ;
568571 }
569572 case StylePathCommand::Tag::CubicCurve: {
570- isRelative = cmd.cubic_curve .point .IsByCoordinate ();
573+ Point cp1 = cmd.cubic_curve .control1 .ToGfxPoint () * aZoom;
574+ Point cp2 = cmd.cubic_curve .control2 .ToGfxPoint () * aZoom;
571575 segEnd = cmd.cubic_curve .point .ToGfxPoint () * aZoom;
572- segEnd = isRelative ? segEnd + segStart : segEnd;
573- Point cp1 =
574- cmd.cubic_curve .control1 .ToGfxPoint (segStart, segEnd, isRelative) *
575- aZoom;
576- Point cp2 =
577- cmd.cubic_curve .control2 .ToGfxPoint (segStart, segEnd, isRelative) *
578- aZoom;
576+
577+ if (cmd.cubic_curve .point .IsByCoordinate ()) {
578+ cp1 += segStart;
579+ cp2 += segStart;
580+ segEnd += segStart;
581+ }
579582
580583 prevCP = cp2;
581584 segStartAngle = AngleOfVector (
@@ -585,13 +588,13 @@ void SVGPathData::GetMarkerPositioningData(Span<const StylePathCommand> aPath,
585588 break ;
586589 }
587590 case StylePathCommand::Tag::QuadCurve: {
588- isRelative = cmd.quad_curve .point . IsByCoordinate () ;
591+ Point cp1 = cmd.quad_curve .control1 . ToGfxPoint () * aZoom ;
589592 segEnd = cmd.quad_curve .point .ToGfxPoint () * aZoom;
590- segEnd = isRelative ? segEnd + segStart
591- : segEnd; // set before setting tcp2!
592- Point cp1 =
593- cmd. quad_curve . control1 . ToGfxPoint ( segStart, segEnd, isRelative) *
594- aZoom;
593+
594+ if (cmd. quad_curve . point . IsByCoordinate ()) {
595+ cp1 += segStart;
596+ segEnd += segStart; // set before setting tcp2!
597+ }
595598
596599 prevCP = cp1;
597600 segStartAngle = AngleOfVector (cp1 == segStart ? segEnd : cp1, segStart);
@@ -662,12 +665,13 @@ void SVGPathData::GetMarkerPositioningData(Span<const StylePathCommand> aPath,
662665 const Point& cp1 = prevSeg && prevSeg->IsCubicType ()
663666 ? segStart * 2 - prevCP
664667 : segStart;
665- isRelative = cmd.smooth_cubic .point . IsByCoordinate () ;
668+ Point cp2 = cmd.smooth_cubic .control2 . ToGfxPoint () * aZoom ;
666669 segEnd = cmd.smooth_cubic .point .ToGfxPoint () * aZoom;
667- segEnd = isRelative ? segEnd + segStart : segEnd;
668- Point cp2 =
669- cmd.smooth_cubic .control2 .ToGfxPoint (segStart, segEnd, isRelative) *
670- aZoom;
670+
671+ if (cmd.smooth_cubic .point .IsByCoordinate ()) {
672+ cp2 += segStart;
673+ segEnd += segStart;
674+ }
671675
672676 prevCP = cp2;
673677 segStartAngle = AngleOfVector (
0 commit comments