Bug 1917604 - Fix non-scaling-stroke on inner <svg>. r=longsonr

Weird no test caught this.

Differential Revision: https://phabricator.services.mozilla.com/D221515
This commit is contained in:
Emilio Cobos Álvarez 2024-09-09 20:51:16 +00:00
parent d41ed60f58
commit 4c44dbe784
3 changed files with 27 additions and 7 deletions

View File

@ -521,15 +521,17 @@ static gfx::Matrix GetCTMInternal(SVGElement* aElement, CTMType aCTMType,
while (ancestor && ancestor->IsSVGElement() &&
!ancestor->IsSVGElement(nsGkAtoms::foreignObject)) {
element = static_cast<SVGElement*>(ancestor);
if (aCTMType == CTMType::NonScalingStroke &&
element->IsSVGElement(nsGkAtoms::svg)) {
if (SVGOuterSVGFrame* frame = do_QueryFrame(element->GetPrimaryFrame())) {
Matrix childTransform;
if (frame->HasChildrenOnlyTransform(&childTransform)) {
return gfx::ToMatrix(matrix) * childTransform;
if (aCTMType == CTMType::NonScalingStroke) {
if (auto* el = SVGSVGElement::FromNode(element); el && !el->IsInner()) {
if (SVGOuterSVGFrame* frame =
do_QueryFrame(element->GetPrimaryFrame())) {
Matrix childTransform;
if (frame->HasChildrenOnlyTransform(&childTransform)) {
return gfx::ToMatrix(matrix) * childTransform;
}
}
return gfx::ToMatrix(matrix);
}
return gfx::ToMatrix(matrix);
}
matrix *= getLocalTransformHelper(element, true);
if (aCTMType == CTMType::NearestViewport &&

View File

@ -0,0 +1,5 @@
<!doctype html>
<title>CSS Test Reference</title>
<svg width="100" height="100">
<path d="M 0 0 L 0 300 L 300 0 z" fill="none" stroke="currentColor" stroke-width="20"></path>
</svg>

View File

@ -0,0 +1,13 @@
<!doctype html>
<meta charset="utf-8">
<title>non-scaling-stroke on a nested SVG</title>
<link rel="author" title="Emilio Cobos Álvarez" href="mailto:emilio@crisal.io">
<link rel="author" title="Mozilla" href="https://mozilla.org">
<link rel="help" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1917604">
<link rel="help" href="https://svgwg.org/svg2-draft/painting.html#PaintingVectorEffects">
<link rel="match" href="non-scaling-stroke-007-ref.html">
<svg width="100" height="100">
<svg width="100%" height="100%" viewBox="0 0 1 1" preserveAspectRatio="none">
<path d="M 0 0 L 0 50 L 50 0 z" fill="none" stroke="currentColor" stroke-width="20" vector-effect="non-scaling-stroke"></path>
</svg>
</svg>