Bug 1682919 - Avoid creating a new DisplayPortMargins object as a side effect of querying the displayport. r=tnikkel
authorBotond Ballo <botond@mozilla.com>
Sun, 24 Jan 2021 04:08:00 +0000
changeset 564393 e65982f456435928e5ed52db9a96d12836663e7a
parent 564392 3837805e531398c01dcc75d0ff93fafe792b8c96
child 564394 ff31d767beaac803ae4f238a86dcc66bc668bb8e
push id38137
push usersmolnar@mozilla.com
push dateSun, 24 Jan 2021 09:14:50 +0000
treeherdermozilla-central@e65982f45643 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstnikkel
bugs1682919
milestone86.0a1
first release with
nightly linux32
e65982f45643 / 86.0a1 / 20210124091450 / files
nightly linux64
e65982f45643 / 86.0a1 / 20210124091450 / files
nightly mac
e65982f45643 / 86.0a1 / 20210124091450 / files
nightly win32
e65982f45643 / 86.0a1 / 20210124091450 / files
nightly win64
e65982f45643 / 86.0a1 / 20210124091450 / files
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
releases
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1682919 - Avoid creating a new DisplayPortMargins object as a side effect of querying the displayport. r=tnikkel DisplayPortMargins objects are only meant to be created when setting display port margins, not when querying them, because the object's constructor records the visual and layout scroll offsets at the time of construction to use for adjusting the margins to be layout-relative. Differential Revision: https://phabricator.services.mozilla.com/D102075
layout/base/DisplayPortUtils.cpp
--- a/layout/base/DisplayPortUtils.cpp
+++ b/layout/base/DisplayPortUtils.cpp
@@ -546,19 +546,23 @@ static bool GetDisplayPortImpl(nsIConten
     isDisplayportSuppressed = presShell->IsDisplayportSuppressed();
   }
 
   nsRect result;
   if (rectData) {
     result = GetDisplayPortFromRectData(aContent, rectData, aMultiplier);
   } else if (isDisplayportSuppressed ||
              nsLayoutUtils::ShouldDisableApzForElement(aContent)) {
-    DisplayPortMarginsPropertyData noMargins(
-        DisplayPortMargins::Empty(aContent), 1,
-        /*painted=*/false);
+    // Make a copy of the margins data but set the margins to empty.
+    // Do not create a new DisplayPortMargins object with
+    // DisplayPortMargins::Empty(), because that will record the visual
+    // and layout scroll offsets in place right now on the DisplayPortMargins,
+    // and those are only meant to be recorded when the margins are stored.
+    DisplayPortMarginsPropertyData noMargins = *marginsData;
+    noMargins.mMargins.mMargins = ScreenMargin();
     result = GetDisplayPortFromMarginsData(aContent, &noMargins, aMultiplier,
                                            aOptions);
   } else {
     result = GetDisplayPortFromMarginsData(aContent, marginsData, aMultiplier,
                                            aOptions);
   }
 
   if (!StaticPrefs::layers_enable_tiles_AtStartup()) {