Skip to content

Commit 2006a44

Browse files
committed
Bug 1967479 - Clear vertices if GetOrBuildPathForMeasuring() fails. r=longsonr
It's failing here: https://searchfox.org/mozilla-central/rev/02d33f4bf984f65bd394bfd2d19d66569ae2cfe1/dom/svg/SVGEllipseElement.cpp#157-159 Which makes sense I think, because off the zero radii. Keep the state consistent in that case. Differential Revision: https://phabricator.services.mozilla.com/D250624 UltraBlame original commit: a461f768187b29cc5ebd11eda635bff41434dfcc
1 parent cb6d415 commit 2006a44

File tree

2 files changed

+34
-13
lines changed

2 files changed

+34
-13
lines changed

dom/svg/SVGMotionSMILAnimationFunction.cpp

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -208,17 +208,21 @@ void SVGMotionSMILAnimationFunction::RebuildPathAndVerticesFromMpathElem(
208208
mPathSourceType = ePathSourceType_Mpath;
209209

210210

211-
SVGGeometryElement* shapeElem = aMpathElem->GetReferencedPath();
212-
if (shapeElem && shapeElem->HasValidDimensions()) {
213-
bool ok = shapeElem->GetDistancesFromOriginToEndsOfVisibleSegments(
214-
&mPathVertices);
215-
if (!ok) {
216-
mPathVertices.Clear();
217-
return;
218-
}
219-
if (mPathVertices.Length()) {
220-
mPath = shapeElem->GetOrBuildPathForMeasuring();
221-
}
211+
SVGGeometryElement* shape = aMpathElem->GetReferencedPath();
212+
if (!shape || !shape->HasValidDimensions()) {
213+
return;
214+
}
215+
if (!shape->GetDistancesFromOriginToEndsOfVisibleSegments(&mPathVertices)) {
216+
mPathVertices.Clear();
217+
return;
218+
}
219+
if (mPathVertices.IsEmpty()) {
220+
return;
221+
}
222+
mPath = shape->GetOrBuildPathForMeasuring();
223+
if (!mPath) {
224+
mPathVertices.Clear();
225+
return;
222226
}
223227
}
224228

@@ -237,7 +241,7 @@ void SVGMotionSMILAnimationFunction::RebuildPathAndVerticesFromPathAttr() {
237241

238242
mPath = path.BuildPathForMeasuring(1.0f);
239243
bool ok = path.GetDistancesFromOriginToEndsOfVisibleSegments(&mPathVertices);
240-
if (!ok || !mPathVertices.Length()) {
244+
if (!ok || mPathVertices.IsEmpty() || !mPath) {
241245
mPath = nullptr;
242246
mPathVertices.Clear();
243247
}
@@ -265,7 +269,6 @@ void SVGMotionSMILAnimationFunction::RebuildPathAndVertices(
265269
mValueNeedsReparsingEverySample = false;
266270
} else {
267271

268-
269272
RebuildPathAndVerticesFromBasicAttrs(aTargetElement);
270273
mValueNeedsReparsingEverySample = true;
271274
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<html>
2+
<head>
3+
<script>
4+
document.addEventListener("DOMContentLoaded", async () => {
5+
const frame = document.createElementNS("http://www.w3.org/1999/xhtml", "frame")
6+
document.documentElement.appendChild(frame)
7+
frame.src = `data:text/html,` + encodeURIComponent(`<!doctype html>
8+
<svg>
9+
<ellipse id="id_8" ry="100pt"></ellipse>
10+
<animateMotion>
11+
<desc></desc>
12+
<mpath xlink:href="#id_8"></mpath>
13+
</animateMotion>
14+
</svg>`);
15+
})
16+
</script>
17+
</head>
18+
</html>

0 commit comments

Comments
 (0)