From 14a3ded3775c0cf340981ea9d94ecd64961ce518 Mon Sep 17 00:00:00 2001 From: violet Date: Fri, 5 Apr 2019 09:03:52 +0000 Subject: [PATCH] Bug 1523343 - Should not round translation for SVG frame r=longsonr When computing transform matrix, translation in SVG should not be rounded. Checking !IsSVGTransformed() isn't the correct way, since an SVG frame may have CSS transform applied. Differential Revision: https://phabricator.services.mozilla.com/D26271 --HG-- extra : moz-landing-system : lando --- layout/painting/nsDisplayList.cpp | 10 ++++++++-- layout/reftests/svg/css-transform-svg-ref.html | 10 ++++++++++ layout/reftests/svg/css-transform-svg.html | 13 +++++++++++++ layout/reftests/svg/reftest.list | 1 + 4 files changed, 32 insertions(+), 2 deletions(-) create mode 100644 layout/reftests/svg/css-transform-svg-ref.html create mode 100644 layout/reftests/svg/css-transform-svg.html diff --git a/layout/painting/nsDisplayList.cpp b/layout/painting/nsDisplayList.cpp index e6b2511d90a5..311ebb35ff5c 100644 --- a/layout/painting/nsDisplayList.cpp +++ b/layout/painting/nsDisplayList.cpp @@ -7783,6 +7783,12 @@ Matrix4x4 nsDisplayTransform::GetResultingTransformMatrixInternal( bool hasSVGTransforms = frame && frame->IsSVGTransformed(&svgTransform, &parentsChildrenOnlyTransform); + + // An SVG frame should not have its translation rounded. + // Note it's possible that the SVG frame doesn't have an SVG + // transform but only has a CSS transform. + bool shouldRound = !(frame && frame->IsFrameOfType(nsIFrame::eSVG)); + /* Transformed frames always have a transform, or are preserving 3d (and might * still have perspective!) */ if (aProperties.HasTransform()) { @@ -7852,7 +7858,7 @@ Matrix4x4 nsDisplayTransform::GetResultingTransformMatrixInternal( // space. if (frame->IsTransformed()) { nsLayoutUtils::PostTranslate(result, frame->GetPosition(), - aAppUnitsPerPixel, !hasSVGTransforms); + aAppUnitsPerPixel, shouldRound); } Matrix4x4 parent = GetResultingTransformMatrixInternal( props, nsPoint(0, 0), aAppUnitsPerPixel, flags, nullptr); @@ -7861,7 +7867,7 @@ Matrix4x4 nsDisplayTransform::GetResultingTransformMatrixInternal( if (aFlags & OFFSET_BY_ORIGIN) { nsLayoutUtils::PostTranslate(result, aOrigin, aAppUnitsPerPixel, - !hasSVGTransforms); + shouldRound); } return result; diff --git a/layout/reftests/svg/css-transform-svg-ref.html b/layout/reftests/svg/css-transform-svg-ref.html new file mode 100644 index 000000000000..6167442e7443 --- /dev/null +++ b/layout/reftests/svg/css-transform-svg-ref.html @@ -0,0 +1,10 @@ + + + + + + diff --git a/layout/reftests/svg/css-transform-svg.html b/layout/reftests/svg/css-transform-svg.html new file mode 100644 index 000000000000..c1c63a83974a --- /dev/null +++ b/layout/reftests/svg/css-transform-svg.html @@ -0,0 +1,13 @@ + + + + + + diff --git a/layout/reftests/svg/reftest.list b/layout/reftests/svg/reftest.list index f2b13d5f1a5d..254637f90847 100644 --- a/layout/reftests/svg/reftest.list +++ b/layout/reftests/svg/reftest.list @@ -490,6 +490,7 @@ random-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) == textPath-line-01.svg tex == thin-stroke-01.svg pass.svg == transform-outer-svg-01.svg transform-outer-svg-01-ref.svg +== css-transform-svg.html css-transform-svg-ref.html == tspan-dxdy-01.svg tspan-dxdy-ref.svg == tspan-dxdy-02.svg tspan-dxdy-ref.svg