diff --git a/layout/reftests/svg/reftest.list b/layout/reftests/svg/reftest.list
index 6adb0ec08af4..119a7cc1da71 100644
--- a/layout/reftests/svg/reftest.list
+++ b/layout/reftests/svg/reftest.list
@@ -145,6 +145,7 @@ fuzzy-if(d2d||skiaContent,0-1,0-10000) == dynamic-filter-contents-01b.svg dynami
== 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
== dynamic-opacity-property-01.svg pass.svg
== dynamic-pattern-01.svg pass.svg
== dynamic-pattern-02.svg pass.svg
diff --git a/layout/reftests/svg/test_bug1323962-2-ref.html b/layout/reftests/svg/test_bug1323962-2-ref.html
new file mode 100644
index 000000000000..dde1fe3c8a58
--- /dev/null
+++ b/layout/reftests/svg/test_bug1323962-2-ref.html
@@ -0,0 +1,9 @@
+
diff --git a/layout/reftests/svg/test_bug1323962-2.html b/layout/reftests/svg/test_bug1323962-2.html
new file mode 100644
index 000000000000..288ab57d4470
--- /dev/null
+++ b/layout/reftests/svg/test_bug1323962-2.html
@@ -0,0 +1,14 @@
+
+
diff --git a/layout/svg/nsSVGPatternFrame.cpp b/layout/svg/nsSVGPatternFrame.cpp
index b290a585400b..e2aed8a0719f 100644
--- a/layout/svg/nsSVGPatternFrame.cpp
+++ b/layout/svg/nsSVGPatternFrame.cpp
@@ -355,15 +355,13 @@ already_AddRefed nsSVGPatternFrame::PaintPattern(
NS_FRAME_DRAWING_AS_PAINTSERVER)) {
AutoSetRestorePaintServerState paintServer(patternWithChildren);
for (nsIFrame *kid = firstKid; kid; kid = kid->GetNextSibling()) {
+ gfxMatrix tm = *(patternWithChildren->mCTM);
+
// The CTM of each frame referencing us can be different
nsSVGDisplayableFrame *SVGFrame = do_QueryFrame(kid);
if (SVGFrame) {
SVGFrame->NotifySVGChanged(nsSVGDisplayableFrame::TRANSFORM_CHANGED);
- }
- gfxMatrix tm = *(patternWithChildren->mCTM);
- if (kid->GetContent()->IsSVGElement()) {
- tm = static_cast(kid->GetContent())
- ->PrependLocalTransformsTo(tm, eUserSpaceToParent);
+ tm = nsSVGUtils::GetTransformMatrixInUserSpace(kid, patternWithChildren) * tm;
}
nsSVGUtils::PaintFrameWithEffects(kid, *ctx, tm, aImgParams);