Bug 1501195 - Fix snapping issues caused by translation only transforms. r=jrmuizel
authorAndrew Osmond <aosmond@mozilla.com>
Wed, 23 Jan 2019 09:30:07 -0500
changeset 455180 524a6613a2ce63c3b760ea7f67cfb6e2cc5280c6
parent 455179 784f80261f91d29e8a6ac0674ffdd10d4b28f137
child 455181 e1020adb02480eb2025017f8cad4dec9b8d384c1
push id35422
push useraciure@mozilla.com
push dateThu, 24 Jan 2019 03:45:05 +0000
treeherdermozilla-central@3e5f4a8daaee [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjrmuizel
bugs1501195
milestone66.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1501195 - Fix snapping issues caused by translation only transforms. r=jrmuizel In nsDisplayTransform::CreateWebRenderCommands we should be rounding the translation from the reference frame if there is no other transformation to better match non-WebRender which performs similar rounding in ChooseScaleAndSetTransform. Differential Revision: https://phabricator.services.mozilla.com/D14265
gfx/tests/reftest/1501195-ref.html
gfx/tests/reftest/1501195.html
gfx/tests/reftest/reftest.list
layout/painting/nsDisplayList.cpp
new file mode 100644
--- /dev/null
+++ b/gfx/tests/reftest/1501195-ref.html
@@ -0,0 +1,30 @@
+<html reftest-zoom="1.1">
+<head>
+<style type="text/css">
+.parent {
+display: flex;
+overflow: hidden;
+}
+
+.bg {
+background-color: lime;
+width: 200px;
+height: 200px;
+transform: scale(1.05);
+}
+
+.bg_overlay {
+background-color: red;
+width: 100px;
+height: 100px;
+position: absolute;
+}
+</style>
+</head>
+<body>
+<div class="parent">
+	<div class="bg"></div>
+	<div class="bg_overlay"></div>
+</div>
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/gfx/tests/reftest/1501195.html
@@ -0,0 +1,31 @@
+<html reftest-zoom="1.1">
+<head>
+<style type="text/css">
+.parent {
+display: flex;
+transform: translate3d(0px, 0px, 0px);
+overflow: hidden;
+}
+
+.bg {
+background-color: lime;
+width: 200px;
+height: 200px;
+transform: scale(1.05);
+}
+
+.bg_overlay {
+background-color: red;
+width: 100px;
+height: 100px;
+position: absolute;
+}
+</style>
+</head>
+<body>
+<div class="parent">
+	<div class="bg"></div>
+	<div class="bg_overlay"></div>
+</div>
+</body>
+</html>
--- a/gfx/tests/reftest/reftest.list
+++ b/gfx/tests/reftest/reftest.list
@@ -11,9 +11,10 @@ fuzzy(0-100,0-30) == 1149923.html 114992
 == 1424673.html 1424673-ref.html
 == 1429411.html 1429411-ref.html
 == 1435143.html 1435143-ref.html
 == 1444904.html 1444904-ref.html
 == 1451168.html 1451168-ref.html
 == 1461313.html 1461313-ref.html
 fuzzy(5-32,21908-26621) fuzzy-if(webrender,0-1,0-3) == 1463802.html 1463802-ref.html
 fuzzy(0-11,0-4) == 1474722.html 1474722-ref.html
+== 1501195.html 1501195-ref.html
 == 1519754.html 1519754-ref.html
--- a/layout/painting/nsDisplayList.cpp
+++ b/layout/painting/nsDisplayList.cpp
@@ -7859,16 +7859,21 @@ bool nsDisplayTransform::CreateWebRender
   Matrix4x4 newTransformMatrix = GetTransformForRendering(&position);
 
   gfx::Matrix4x4* transformForSC = &newTransformMatrix;
   if (newTransformMatrix.IsIdentity()) {
     // If the transform is an identity transform, strip it out so that WR
     // doesn't turn this stacking context into a reference frame, as it
     // affects positioning. Bug 1345577 tracks a better fix.
     transformForSC = nullptr;
+
+    // In ChooseScaleAndSetTransform, we round the offset from the reference
+    // frame used to adjust the transform, if there is no transform, or it
+    // is just a translation. We need to do the same here.
+    position.Round();
   }
 
   uint64_t animationsId = AddAnimationsForWebRender(
       this, eCSSProperty_transform, aManager, aDisplayListBuilder);
   wr::WrAnimationProperty prop{
       wr::WrAnimationType::Transform,
       animationsId,
   };