Bug 1323962 - PaintSVG for container should consider CSS transform for its children r=longsonr

Container manages SVG/CSS transform of its children, thus PaintSVG of container
should take children's CSS transform into account.

Differential Revision: https://phabricator.services.mozilla.com/D28273

--HG--
rename : layout/reftests/svg/test_bug1323962-3-ref.html => layout/reftests/svg/clipPath-css-transform-ref.html
rename : layout/reftests/svg/test_bug1323962-3.html => layout/reftests/svg/clipPath-css-transform.html
rename : layout/reftests/svg/test_bug1323962-ref.html => layout/reftests/svg/mask-css-transform-ref.html
rename : layout/reftests/svg/test_bug1323962.html => layout/reftests/svg/mask-css-transform.html
rename : layout/reftests/svg/test_bug1247218-ref.html => layout/reftests/svg/non-scaling-stroke-css-transform-ref.html
rename : layout/reftests/svg/test_bug1247218.html => layout/reftests/svg/non-scaling-stroke-css-transform.html
rename : layout/reftests/svg/test_bug1323962-2-ref.html => layout/reftests/svg/pattern-css-transform-ref.html
rename : layout/reftests/svg/test_bug1323962-2.html => layout/reftests/svg/pattern-css-transform.html
extra : moz-landing-system : lando
This commit is contained in:
violet 2019-04-23 00:03:00 +00:00
parent 09e109dd9a
commit 8afef00f56
14 changed files with 55 additions and 14 deletions

View File

Before

Width:  |  Height:  |  Size: 786 B

After

Width:  |  Height:  |  Size: 786 B

View File

@ -0,0 +1,12 @@
<svg viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg">
<defs>
<marker id="arrow" viewBox="0 0 10 10" refX="5" refY="5"
markerWidth="6" markerHeight="6"
orient="auto-start-reverse">
<path id="ap" transform="scale(2,2)" d="M 0 0 L 5 2.5 L 0 5 z" />
</marker>
</defs>
<polyline points="10,30 90,30" fill="none" stroke="black"
marker-start="url(#arrow)" marker-end="url(#arrow)" />
</svg>

After

Width:  |  Height:  |  Size: 434 B

View File

@ -0,0 +1,17 @@
<style>
#ap {
transform: scale(2,2);
}
</style>
<svg viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg">
<defs>
<marker id="arrow" viewBox="0 0 10 10" refX="5" refY="5"
markerWidth="6" markerHeight="6"
orient="auto-start-reverse">
<path id="ap" d="M 0 0 L 5 2.5 L 0 5 z" />
</marker>
</defs>
<polyline points="10,30 90,30" fill="none" stroke="black"
marker-start="url(#arrow)" marker-end="url(#arrow)" />
</svg>

View File

Before

Width:  |  Height:  |  Size: 287 B

After

Width:  |  Height:  |  Size: 287 B

View File

Before

Width:  |  Height:  |  Size: 265 B

After

Width:  |  Height:  |  Size: 265 B

View File

@ -1,7 +1,8 @@
<svg width="200" height="200">
<defs>
<pattern id="Pattern" x="0" y="0" width=".25" height=".25">
<rect id="rec" x="0" y="0" width="30" height="30" fill="skyblue"/>
<rect x="0" y="0" width="30" height="30" fill="skyblue"/>
<rect x="40" y="40" width="10" height="10" fill="skyblue" />
</pattern>
</defs>

Before

Width:  |  Height:  |  Size: 281 B

After

Width:  |  Height:  |  Size: 339 B

View File

@ -1,12 +1,18 @@
<style>
#rec {
#rec1 {
transform: scale(.6,.6);
}
#rec2 {
transform: translate(40px,40px) scale(.2,.2);
}
</style>
<svg width="200" height="200">
<defs>
<pattern id="Pattern" x="0" y="0" width=".25" height=".25">
<rect id="rec" x="0" y="0" width="50" height="50" fill="skyblue"/>
<rect id="rec1" x="0" y="0" width="50" height="50" fill="skyblue"/>
<g>
<rect id="rec2" x="0" y="0" width="50" height="50" fill="skyblue"/>
</g>
</pattern>
</defs>

View File

@ -79,6 +79,7 @@ fuzzy-if(/^Windows\x20NT\x2010\.0/.test(http.oscpu)||/^Windows\x20NT\x206\.[12]/
== clipPath-basic-06.svg pass.svg
== clipPath-basic-07.svg pass.svg
== clipPath-basic-08.svg pass.svg
== clipPath-css-transform.html clipPath-css-transform-ref.html
== clipPath-on-outflowElement-01a.html clipPath-on-outflowElement-01-ref.html
== clipPath-on-outflowElement-01b.html clipPath-on-outflowElement-01-ref.html
fuzzy(0-1,0-32400) == clipPath-on-outflowElement-02a.html clipPath-on-outflowElement-02-ref.html
@ -144,9 +145,6 @@ fuzzy-if(d2d||skiaContent,0-1,0-10000) == dynamic-filter-contents-01b.svg dynami
== dynamic-mask-01.svg pass.svg
== dynamic-mask-contents-01.svg pass.svg
== dynamic-mask-pre-effects-bbox.html dynamic-mask-pre-effects-bbox-ref.html
== test_bug1323962.html test_bug1323962-ref.html
== test_bug1323962-2.html test_bug1323962-2-ref.html
== test_bug1323962-3.html test_bug1323962-3-ref.html
== dynamic-opacity-property-01.svg pass.svg
== dynamic-pattern-01.svg pass.svg
== dynamic-pattern-02.svg pass.svg
@ -163,7 +161,6 @@ fuzzy-if(d2d&&layersGPUAccelerated,0-3,0-1200) == dynamic-rect-02.svg dynamic-re
== dynamic-stroke-01.svg pass.svg
== dynamic-stroke-opacity-01.svg pass.svg
== dynamic-stroke-width-01.svg pass.svg
== test_bug1247218.html test_bug1247218-ref.html
== dynamic-switch-01.svg pass.svg
random-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) == dynamic-text-01.svg dynamic-text-01-ref.svg # bug 1392106
fuzzy-if(d2d&&layersGPUAccelerated,0-3,0-12739) == dynamic-text-02.svg dynamic-text-02-ref.svg # bug 776038 for Win7, Win8
@ -268,6 +265,7 @@ fuzzy-if(cocoaWidget,0-15,0-19679) fuzzy-if(winWidget,0-1,0-8800) fuzzy-if(!coco
fuzzy-if(/^Windows\x20NT\x2010\.0/.test(http.oscpu)||skiaContent,0-1,0-800000) == markers-and-group-opacity-01.svg markers-and-group-opacity-01-ref.svg
== marker-attribute-01.svg pass.svg
fuzzy-if(skiaContent,0-1,0-1) == marker-dynamic-opacity.html marker-dynamic-opacity-ref.html
== marker-css-transform.html marker-css-transform-ref.html
== marker-effects-01.svg marker-effects-01-ref.svg
fuzzy-if(skiaContent,0-1,0-100) == marker-viewBox-01.svg marker-viewBox-01-ref.svg
fuzzy-if(skiaContent,0-1,0-100) == marker-orientation-01.svg marker-orientation-01-ref.svg
@ -287,6 +285,7 @@ fuzzy-if(skiaContent,0-1,0-10000) == mask-basic-02.svg mask-basic-02-ref.svg
== mask-containing-masked-content-01.svg pass.svg
== mask-contains-inner-svg-01.svg pass.svg
== mask-contains-inner-svg-02.svg pass.svg
== mask-css-transform.html mask-css-transform-ref.html
== mask-empty-size.svg about:blank
== mask-extref-dataURI-01.svg pass.svg
fuzzy(0-128,0-141) == mask-img.html mask-img-ref.html
@ -306,6 +305,8 @@ fuzzy-if(d2d||skiaContent,0-1,0-6400) == mask-type-04.svg mask-type-01-ref.svg
!= nested-mask-mode.svg about:blank
== nested-viewBox-01.svg pass.svg
== non-scaling-stroke-css-transform.html non-scaling-stroke-css-transform-ref.html
fuzzy-if(skiaContent,0-3,0-448000) == nesting-invalid-01.svg nesting-invalid-01-ref.svg
fuzzy-if(d2d&&/^Windows\x20NT\x20(6\.1|10\.0)/.test(http.oscpu),0-63,0-168) fuzzy-if(cocoaWidget,0-1,0-122) fuzzy-if(skiaContent,0-2,0-1000) == non-scaling-stroke-01.svg non-scaling-stroke-01-ref.svg # bug 1074161 for Win7 and OSX 10.8
@ -361,6 +362,7 @@ fuzzy-if(skiaContent,0-1,0-400) == path-06.svg path-06-ref.svg
== pattern-basic-01.svg pass.svg
fuzzy(0-1,0-5) skip-if(Android) == pattern-big-image.html pattern-big-image-ref.html
== pattern-css-transform.html pattern-css-transform-ref.html
== pattern-invalid-01.svg pattern-invalid-01-ref.svg
fuzzy-if(skiaContent,0-1,0-5) == pattern-live-01a.svg pattern-live-01-ref.svg
fuzzy-if(skiaContent,0-1,0-5) == pattern-live-01b.svg pattern-live-01-ref.svg

View File

@ -260,7 +260,8 @@ void nsSVGDisplayContainerFrame::PaintSVG(gfxContext& aContext,
if (!element->HasValidDimensions()) {
continue; // nothing to paint for kid
}
m = element->PrependLocalTransformsTo(m, eUserSpaceToParent);
m = nsSVGUtils::GetTransformMatrixInUserSpace(kid, this) * m;
if (m.IsSingular()) {
continue;
}
@ -390,7 +391,9 @@ SVGBBox nsSVGDisplayContainerFrame::GetBBoxContribution(
gfxMatrix transform = gfx::ThebesMatrix(aToBBoxUserspace);
if (content->IsSVGElement()) {
transform = static_cast<SVGElement*>(content)->PrependLocalTransformsTo(
transform);
{}, eChildToUserSpace) *
nsSVGUtils::GetTransformMatrixInUserSpace(kid, this) *
transform;
}
// We need to include zero width/height vertical/horizontal lines, so we
// have to use UnionEdges.

View File

@ -103,8 +103,7 @@ void nsSVGSwitchFrame::PaintSVG(gfxContext& aContext,
if (kid) {
gfxMatrix tm = aTransform;
if (kid->GetContent()->IsSVGElement()) {
tm = static_cast<SVGElement*>(kid->GetContent())
->PrependLocalTransformsTo(tm, eUserSpaceToParent);
tm = nsSVGUtils::GetTransformMatrixInUserSpace(kid, this) * tm;
}
nsSVGUtils::PaintFrameWithEffects(kid, aContext, tm, aImgParams,
aDirtyRect);
@ -255,7 +254,9 @@ SVGBBox nsSVGSwitchFrame::GetBBoxContribution(const Matrix& aToBBoxUserspace,
gfxMatrix transform = ThebesMatrix(aToBBoxUserspace);
if (content->IsSVGElement()) {
transform = static_cast<SVGElement*>(content)->PrependLocalTransformsTo(
transform);
{}, eChildToUserSpace) *
nsSVGUtils::GetTransformMatrixInUserSpace(kid, this) *
transform;
}
return svgKid->GetBBoxContribution(ToMatrix(transform), aFlags);
}

View File

@ -1641,8 +1641,7 @@ void nsSVGUtils::PaintSVGGlyph(Element* aElement, gfxContext* aContext) {
if (frame->GetContent()->IsSVGElement()) {
// PaintSVG() expects the passed transform to be the transform to its own
// SVG user space, so we need to account for any 'transform' attribute:
m = static_cast<SVGElement*>(frame->GetContent())
->PrependLocalTransformsTo(gfxMatrix(), eUserSpaceToParent);
m = nsSVGUtils::GetTransformMatrixInUserSpace(frame, frame->GetParent());
}
// SVG-in-OpenType is not allowed to paint external resources, so we can