Bug 1815061 - Fix handling of startOffset and stroke-dasharray when the pathLength attribute is zero r=emilio

See https://github.com/w3c/svgwg/issues/81

Differential Revision: https://phabricator.services.mozilla.com/D168899
This commit is contained in:
Robert Longson 2023-02-04 17:46:57 +00:00
Родитель 191b58a8a0
Коммит 350f9b6199
6 изменённых файлов: 9 добавлений и 11 удалений

Просмотреть файл

@ -184,7 +184,7 @@ static DashState GetStrokeDashData(
pathScale =
static_cast<SVGGeometryElement*>(aElement)->GetPathLengthScale(
SVGGeometryElement::eForStroking);
if (pathScale <= 0) {
if (pathScale <= 0 || !IsFinite(pathScale)) {
return eContinuousStroke;
}
}

Просмотреть файл

@ -253,7 +253,7 @@ float SVGGeometryElement::GetPathLengthScale(PathLengthScaleForType aFor) {
MOZ_ASSERT(aFor == eForTextPath || aFor == eForStroking, "Unknown enum");
if (mPathLength.IsExplicitlySet()) {
float authorsPathLengthEstimate = mPathLength.GetAnimValue();
if (authorsPathLengthEstimate > 0) {
if (authorsPathLengthEstimate >= 0) {
RefPtr<Path> path = GetOrBuildPathForMeasuring();
if (!path) {
// The path is empty or invalid so its length must be zero and

Просмотреть файл

@ -4605,12 +4605,18 @@ gfxFloat SVGTextFrame::GetStartOffset(nsIFrame* aTextPathFrame) {
&tp->mLengthAttributes[SVGTextPathElement::STARTOFFSET];
if (length->IsPercentage()) {
if (!IsFinite(GetOffsetScale(aTextPathFrame))) {
// Either pathLength="0" for this path or the path has 0 length.
return 0.0;
}
RefPtr<Path> data = GetTextPath(aTextPathFrame);
return data ? length->GetAnimValInSpecifiedUnits() * data->ComputeLength() /
100.0
: 0.0;
}
return length->GetAnimValue(tp) * GetOffsetScale(aTextPathFrame);
float lengthValue = length->GetAnimValue(tp);
// If offsetScale is infinity we want to return 0 not NaN
return lengthValue == 0 ? 0.0 : lengthValue * GetOffsetScale(aTextPathFrame);
}
void SVGTextFrame::DoTextPathLayout() {

Просмотреть файл

@ -1,3 +0,0 @@
[pathLength-zero-percentage.svg]
expected:
FAIL

Просмотреть файл

@ -1,3 +0,0 @@
[pathLength-zero.svg]
expected:
FAIL

Просмотреть файл

@ -1,2 +0,0 @@
[pathlength-path-zero.svg]
expected: FAIL