mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1024860 - getTotalLength on an empty path should not throw but return 0 instead. r=jwatt,bzbarsky
This commit is contained in:
parent
e3eefacbb9
commit
f8dd9d1270
@ -68,16 +68,10 @@ SVGPathElement::PathLength()
|
||||
}
|
||||
|
||||
float
|
||||
SVGPathElement::GetTotalLength(ErrorResult& rv)
|
||||
SVGPathElement::GetTotalLength()
|
||||
{
|
||||
RefPtr<Path> flat = GetPathForLengthOrPositionMeasuring();
|
||||
|
||||
if (!flat) {
|
||||
rv.Throw(NS_ERROR_FAILURE);
|
||||
return 0.f;
|
||||
}
|
||||
|
||||
return flat->ComputeLength();
|
||||
return flat ? flat->ComputeLength() : 0.f;
|
||||
}
|
||||
|
||||
already_AddRefed<nsISVGPoint>
|
||||
@ -353,7 +347,11 @@ SVGPathElement::GetPathLengthScale(PathLengthScaleForType aFor)
|
||||
float authorsPathLengthEstimate = mPathLength.GetAnimValue();
|
||||
if (authorsPathLengthEstimate > 0) {
|
||||
RefPtr<Path> path = GetPathForLengthOrPositionMeasuring();
|
||||
|
||||
if (!path) {
|
||||
// The path is empty or invalid so its length must be zero and
|
||||
// we know that 0 / authorsPathLengthEstimate = 0.
|
||||
return 0.0;
|
||||
}
|
||||
if (aFor == eForTextPath) {
|
||||
// For textPath, a transform on the referenced path affects the
|
||||
// textPath layout, so when calculating the actual path length
|
||||
@ -365,10 +363,7 @@ SVGPathElement::GetPathLengthScale(PathLengthScaleForType aFor)
|
||||
path = builder->Finish();
|
||||
}
|
||||
}
|
||||
|
||||
if (path) {
|
||||
return path->ComputeLength() / authorsPathLengthEstimate;
|
||||
}
|
||||
return path->ComputeLength() / authorsPathLengthEstimate;
|
||||
}
|
||||
}
|
||||
return 1.0;
|
||||
|
@ -88,7 +88,7 @@ public:
|
||||
|
||||
// WebIDL
|
||||
already_AddRefed<SVGAnimatedNumber> PathLength();
|
||||
float GetTotalLength(ErrorResult& rv);
|
||||
float GetTotalLength();
|
||||
already_AddRefed<nsISVGPoint> GetPointAtLength(float distance, ErrorResult& rv);
|
||||
uint32_t GetPathSegAtLength(float distance);
|
||||
already_AddRefed<DOMSVGPathSegClosePath> CreateSVGPathSegClosePath();
|
||||
|
@ -32,6 +32,12 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1024926
|
||||
|
||||
is(path.getTotalLength(), 150, "Unexpected path length");
|
||||
|
||||
while (path.pathSegList.numberOfItems > 0) {
|
||||
path.pathSegList.removeItem(0);
|
||||
}
|
||||
|
||||
is(path.getTotalLength(), 0, "Unexpected path length");
|
||||
|
||||
SimpleTest.finish();
|
||||
|
||||
</script>
|
||||
|
@ -13,7 +13,6 @@ interface SVGPathElement : SVGGraphicsElement {
|
||||
|
||||
readonly attribute SVGAnimatedNumber pathLength;
|
||||
|
||||
[Throws]
|
||||
float getTotalLength();
|
||||
[NewObject, Throws]
|
||||
SVGPoint getPointAtLength(float distance);
|
||||
|
Loading…
Reference in New Issue
Block a user