diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-23 04:30:02 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-23 04:30:02 +0000 |
commit | 54d9c30a346d86e71c7564b84bff710fb8c49807 (patch) | |
tree | 59afeb0047d195a60511b7a91198de779d49dbdf /dom/canvas | |
parent | Releasing progress-linux version 125.0.1-2~progress7.99u1. (diff) | |
download | firefox-54d9c30a346d86e71c7564b84bff710fb8c49807.tar.xz firefox-54d9c30a346d86e71c7564b84bff710fb8c49807.zip |
Merging upstream version 125.0.2.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dom/canvas')
-rw-r--r-- | dom/canvas/CanvasRenderingContext2D.cpp | 29 | ||||
-rw-r--r-- | dom/canvas/CanvasRenderingContext2D.h | 22 |
2 files changed, 38 insertions, 13 deletions
diff --git a/dom/canvas/CanvasRenderingContext2D.cpp b/dom/canvas/CanvasRenderingContext2D.cpp index 529466cc81..62f6e6443d 100644 --- a/dom/canvas/CanvasRenderingContext2D.cpp +++ b/dom/canvas/CanvasRenderingContext2D.cpp @@ -3463,7 +3463,9 @@ void CanvasRenderingContext2D::ArcTo(double aX1, double aY1, double aX2, return aError.ThrowIndexSizeError("Negative radius"); } - EnsureWritablePath(); + if (!EnsureWritablePath()) { + return; + } // Current point in user space! Point p0 = mPathBuilder->CurrentPoint(); @@ -3535,7 +3537,9 @@ void CanvasRenderingContext2D::Arc(double aX, double aY, double aR, return; } - EnsureWritablePath(); + if (!EnsureWritablePath()) { + return; + } EnsureActivePath(); @@ -3545,7 +3549,9 @@ void CanvasRenderingContext2D::Arc(double aX, double aY, double aR, void CanvasRenderingContext2D::Rect(double aX, double aY, double aW, double aH) { - EnsureWritablePath(); + if (!EnsureWritablePath()) { + return; + } if (!std::isfinite(aX) || !std::isfinite(aY) || !std::isfinite(aW) || !std::isfinite(aH)) { @@ -3741,7 +3747,9 @@ void CanvasRenderingContext2D::RoundRect( const UnrestrictedDoubleOrDOMPointInitOrUnrestrictedDoubleOrDOMPointInitSequence& aRadii, ErrorResult& aError) { - EnsureWritablePath(); + if (!EnsureWritablePath()) { + return; + } PathBuilder* builder = mPathBuilder; Maybe<Matrix> transform = Nothing(); @@ -3759,7 +3767,9 @@ void CanvasRenderingContext2D::Ellipse(double aX, double aY, double aRadiusX, return aError.ThrowIndexSizeError("Negative radius"); } - EnsureWritablePath(); + if (!EnsureWritablePath()) { + return; + } ArcToBezier(this, Point(aX, aY), Size(aRadiusX, aRadiusY), aStartAngle, aEndAngle, aAnticlockwise, aRotation); @@ -3780,10 +3790,14 @@ void CanvasRenderingContext2D::FlushPathTransform() { mPathTransformDirty = false; } -void CanvasRenderingContext2D::EnsureWritablePath() { +bool CanvasRenderingContext2D::EnsureWritablePath() { EnsureTarget(); + // NOTE: IsTargetValid() may be false here (mTarget == sErrorTarget) but we // go ahead and create a path anyway since callers depend on that. + if (NS_WARN_IF(!mTarget)) { + return false; + } FillRule fillRule = CurrentState().fillRule; @@ -3792,7 +3806,7 @@ void CanvasRenderingContext2D::EnsureWritablePath() { } if (mPathBuilder) { - return; + return true; } if (!mPath) { @@ -3800,6 +3814,7 @@ void CanvasRenderingContext2D::EnsureWritablePath() { } else { mPathBuilder = mPath->CopyToBuilder(fillRule); } + return true; } void CanvasRenderingContext2D::EnsureUserSpacePath( diff --git a/dom/canvas/CanvasRenderingContext2D.h b/dom/canvas/CanvasRenderingContext2D.h index 75a57ab14f..bfcbfccec2 100644 --- a/dom/canvas/CanvasRenderingContext2D.h +++ b/dom/canvas/CanvasRenderingContext2D.h @@ -364,14 +364,18 @@ class CanvasRenderingContext2D : public nsICanvasRenderingContextInternal, } void ClosePath() { - EnsureWritablePath(); + if (!EnsureWritablePath()) { + return; + } mPathBuilder->Close(); mPathPruned = false; } void MoveTo(double aX, double aY) { - EnsureWritablePath(); + if (!EnsureWritablePath()) { + return; + } mozilla::gfx::Point pos(ToFloat(aX), ToFloat(aY)); if (!pos.IsFinite()) { @@ -383,13 +387,17 @@ class CanvasRenderingContext2D : public nsICanvasRenderingContextInternal, } void LineTo(double aX, double aY) { - EnsureWritablePath(); + if (!EnsureWritablePath()) { + return; + } LineTo(mozilla::gfx::Point(ToFloat(aX), ToFloat(aY))); } void QuadraticCurveTo(double aCpx, double aCpy, double aX, double aY) { - EnsureWritablePath(); + if (!EnsureWritablePath()) { + return; + } mozilla::gfx::Point cp1(ToFloat(aCpx), ToFloat(aCpy)); mozilla::gfx::Point cp2(ToFloat(aX), ToFloat(aY)); @@ -408,7 +416,9 @@ class CanvasRenderingContext2D : public nsICanvasRenderingContextInternal, void BezierCurveTo(double aCp1x, double aCp1y, double aCp2x, double aCp2y, double aX, double aY) { - EnsureWritablePath(); + if (!EnsureWritablePath()) { + return; + } BezierTo(mozilla::gfx::Point(ToFloat(aCp1x), ToFloat(aCp1y)), mozilla::gfx::Point(ToFloat(aCp2x), ToFloat(aCp2y)), @@ -680,7 +690,7 @@ class CanvasRenderingContext2D : public nsICanvasRenderingContextInternal, /* This function ensures there is a writable pathbuilder available */ - void EnsureWritablePath(); + bool EnsureWritablePath(); // Ensures a path in UserSpace is available. void EnsureUserSpacePath( |